For review: PEP 308 - If-then-else expression

Evan evan at
Sun Feb 9 02:21:07 CET 2003

Michele Simionato wrote:
> Not convincing. For multiple choices one should use a dictionary. I am favorable
> to a ternary operator but against a "case" operator.

Please explain how the following could be implemented with a dictionary 
(note that f and g have side-effects, and should only be called if we 
need their value):

x = {if a == 1: f(),
         g() == 'asdf': 'g',
         c > 4.5: 'yep'

A lot of lambdas, perhaps?


Evan @ 4-am

More information about the Python-list mailing list