Any simpler way to do this

Christian Heimes lists at cheimes.de
Fri Dec 7 04:17:13 EST 2007


Lars Johansen wrote:
> I have a function that looks like this:
> 
> def Chooser(color):
> 
>         if color == "RED":
>                 x = term.RED
>         elif color == "BLUE":
>                 x = term.BLUE
>         elif color == "GREEN":
>                 x = term.GREEN
>         elif color == "YELLOW":
>                 x = term.YELLOW
>         elif color == "CYAN":
>                 x = term.CYAN
>         elif color == "MAGENTA":
>                 x = term.MAGENTA
>         return x

return getattr(term, color, color)

:)

Christian



More information about the Python-list mailing list