a dict trick
Bruno Desthuilliers
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Aug 2 05:30:35 EDT 2007
james_027 a écrit :
> Hi,
>
> what if we're not dealing with dict? is there a pythonic way of doing
> ternary? the bool ? x:y
Python 2.5 introduced the following syntax:
expr1 if condition else expr2
In older Python versions, one has to use and/or (like you wrongly did)
or tuple/dict dispatch or other ad-hoc tricks. Or use a plain old
if/else branch.
More information about the Python-list
mailing list