Trinary operator?

Grant Edwards grante at visi.com
Fri Apr 19 15:40:29 EDT 2002


In article <mailman.1019240861.31256.python-list at python.org>, Cliff Wells wrote:

> Interesting.  It hadn't occurred to me that exceptions would be
> any faster than .get().  I didn't use a predefined dictionary
> since the OP was looking for an equivalent to C's ternary
> operator (which I took to mean "one line"), but that's clearly
> the most important optimization if speed is a concern (athough
> it's arguably more readable as well).

When somebody asks about a ternary operator they usually don't
really care about a ternary operator.  What they _really_ want
to do is to know how to solve in Python a problem that was
sovled in C by using a ternary operator.

-- 
Grant Edwards                   grante             Yow!  I'm encased in the
                                  at               lining of a pure pork
                               visi.com            sausage!!



More information about the Python-list mailing list