The ternary operator: more than one way to do it?

Erik Max Francis max at alcyone.com
Mon Mar 10 15:23:38 EST 2003


Paul Boddie wrote:

> The whole PEP 308 debate seems to reveal a secret desire in the
> community to have more than one way of doing the ternary operator
> thing - after all, there wouldn't have been so many creative
> suggestions if this were not so.

The oft-misquoted Python precept isn't "There's only one way to do it,"
it's more like, "There's (usually) only one _right_ way to do it." 
There is always more than one way to do something in any general,
powerful, expressive programming language, and Python is no exception.

The addition of a conditional operator to Python would resolve the issue
of which is the right way to do it (conditional evaluation within an
expression with short circuiting), so on the contrary, its addition
would not only be not un-Pythonic, but highly Pythonic.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ There I was / There I was / Splitting atoms with my desire
\__/ Lamya
    CSBuddy / http://www.alcyone.com/pyos/csbuddy/
 A Counter-Strike server log file monitor in Python.




More information about the Python-list mailing list