[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Is there some type of hex codes to rgb converter or something?



Lamonte Harris wrote:
I came up w/ this for my class:
    def hex_converter(self,hexcolorcode):
        hexcolorcode = hexcolorcode[1:]
        red = hexcolorcode[0:2]
        red = int(red,16)
        blue = hexcolorcode[2:4]
        blue = int(blue,16)
        green = hexcolorcode[4:6]
        green = int(green,16)
        return (red,green,blue)

Thanks. again
Sure. Are you sure you're using your classes right, though? A method of a class should change instance attributes, and only secondly return values. That shouldn't be its primary focus. If you have more questions that are python-specific but not pygame-specific, try asking on the python-tutor mailing list. It's a nice list geared specifically toward people learning Python.
-Luke