ternary operator

Chad Netzer cnetzer at mail.arc.nasa.gov
Tue Feb 4 18:25:03 EST 2003


On Tue, 2003-02-04 at 14:44, David Gausebeck wrote:
> I've recently started using python from a primarily C/C++ background,
> and one of the annoyances that I ran into right away was the lack of a
> ternary ?: operator.

Some people have advocated:

(b,c)[not a]

which is comparable (except for the shortcutting evaluation) to:

a ? b : c

Best to use it sparingly, or only when you require a lot of it at once
(and can write a brief local comment to explain it), IMO.

-- 
Bay Area Python Interest Group - http://www.baypiggies.net/

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)







More information about the Python-list mailing list