ternary operator

Christopher A. Craig list-python at ccraig.org
Wed Feb 5 09:49:33 EST 2003


gausebec-spam at paypal.com (David Gausebeck) writes:

> 2) Is there any better workaround than the ones I've listed above?

if a: x = b
else: x = c
do_something(x)

Quite clear, I would think. <.8 wink>

Python is generally thought to have caught on as a language because of
its simplicity.  The developers really do try to make sure there is
always one, and only one obvious way to do things.  Listcomps and
generators have detracted from this some, but I think the
expresiveness of them outweighs the syntactic complexity they add.  I
do not feel the same about the ternary function.

-- 
Christopher A. Craig <list-python at ccraig.org>
"In the beginning the Universe was created.  This has made a lot of people
very angry and been widely regarded as a bad move." Douglas Adams





More information about the Python-list mailing list