def to_rgb(self, arg):
try: return self.cache[arg]<EOL>except KeyError: pass<EOL>except TypeError: <EOL><INDENT>arg = tuple(arg)<EOL>try: return self.cache[arg]<EOL>except KeyError: pass<EOL>except TypeError:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>% (str(arg),))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if cbook.is_string_like(arg):<EOL><INDENT>color = self.colors.get(arg, None)<EOL>if color is None:<EOL><INDENT>str1 = cnames.get(arg, arg)<EOL>if str1.startswith('<STR_LIT:#>'):<EOL><INDENT>color = hex2color(str1)<EOL><DEDENT>else:<EOL><INDENT>fl = float(arg)<EOL>if fl < <NUM_LIT:0> or fl > <NUM_LIT:1>:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>color = tuple([fl]*<NUM_LIT:3>)<EOL><DEDENT><DEDENT><DEDENT>elif cbook.iterable(arg):<EOL><INDENT>if len(arg) > <NUM_LIT:4> or len(arg) < <NUM_LIT:3>:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'%len(arg))<EOL><DEDENT>color = tuple(arg[:<NUM_LIT:3>])<EOL>if [x for x in color if (float(x) < <NUM_LIT:0>) or  (x > <NUM_LIT:1>)]:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>self.cache[arg] = color<EOL><DEDENT>except (KeyError, ValueError, TypeError) as exc:<EOL><INDENT>raise ValueError('<STR_LIT>' % (str(arg), exc))<EOL><DEDENT>return color<EOL>
Returns an *RGB* tuple of three floats from 0-1.

*arg* can be an *RGB* or *RGBA* sequence or a string in any of
several forms:

    1) a letter from the set 'rgbcmykw'
    2) a hex color string, like '#00FFFF'
    3) a standard name, like 'aqua'
    4) a float, like '0.4', indicating gray on a 0-1 scale

if *arg* is *RGBA*, the *A* will simply be discarded.