Any simpler way to do this
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Dec 7 17:26:07 EST 2007
On Fri, 07 Dec 2007 09:37:22 +0100, Lars Johansen wrote:
> I have a function that looks like this:
>
> def Chooser(color):
>
> if color == "RED":
> x = term.RED
[snip]
> Wouldn there been easier if I could just skip all the "*if's" and just
> "return term.color", however this gives a syntax error, are there any
> clever way to do this ?
Others have answered the immediate question, but I'm kind of surprised
that nobody seems to have noticed that Lars is reporting a syntax error
instead of an attribute error.
I suspect that Lars is actually misreporting the error he gets. That's
probably not a good habit to get into :)
--
Steven
More information about the Python-list
mailing list