def rgb_to_xyz(r, g=None, b=None):
if type(r) in [list,tuple]:<EOL><INDENT>r, g, b = r<EOL><DEDENT>r, g, b = [((v <= <NUM_LIT>) and [v / <NUM_LIT>] or [((v+<NUM_LIT>) / <NUM_LIT>) **<NUM_LIT>])[<NUM_LIT:0>] for v in (r, g, b)]<EOL>x = (r * <NUM_LIT>) + (g * <NUM_LIT>) + (b * <NUM_LIT>)<EOL>y = (r * <NUM_LIT>) + (g * <NUM_LIT>) + (b * <NUM_LIT>)<EOL>z = (r * <NUM_LIT>) + (g * <NUM_LIT>) + (b * <NUM_LIT>)<EOL>return (x, y, z)<EOL>
Convert the color from sRGB to CIE XYZ.

    The methods assumes that the RGB coordinates are given in the sRGB
    colorspace (D65).

    .. note::

       Compensation for the sRGB gamma correction is applied before converting.

    Parameters:
      :r:
        The Red component value [0...1]
      :g:
        The Green component value [0...1]
      :b:
        The Blue component value [0...1]

    Returns:
      The color as an (x, y, z) tuple in the range:
      x[0...1],
      y[0...1],
      z[0...1]

    >>> '(%g, %g, %g)' % rgb_to_xyz(1, 0.5, 0)
    '(0.488941, 0.365682, 0.0448137)'