def string_to_rgb(s):
 orig_s = s
 s = s.strip()
 if s.startswith('#'):
  s = s[1:]
 if (not (len(s) == 6)):
  raise ValueError(("String %s doesn't look like a hex string" % orig_s))
 return (int(s[:2], 16), int(s[2:4], 16), int(s[4:], 16))

def string_to_rgb ( s ) : orig_s = s s = s . strip ( ) if s . startswith ( '#' ) : s = s [ 1 : ] if ( not ( len ( s ) == 6 ) ) : raise ValueError ( ( "String %s doesn't look like a hex string" % orig_s ) ) return ( int ( s [ : 2 ] , 16 ) , int ( s [ 2 : 4 ] , 16 ) , int ( s [ 4 : ] , 16 ) )
converts hex string to rgb .