For review: PEP 308 - If-then-else expression
Andrew Koenig
ark at research.att.com
Fri Feb 7 21:58:08 EST 2003
Andrew> My scan of the linux source suggests that most uses of ?: are of this
Andrew> sort, eg
Andrew> mode_wanted ? "en" : "dis"
Andrew> could be written in Python as
Andrew> ["en", "dis"][mode_wanted]
Yes, they could be -- but in the process of translating the code, you
inverted the condition! The original yields "en" if mode_wanted is
true, and the rewrite yields "en" if mode_wanted is false.
To me, that fact is a strong argument in favor of PEP 308 :-)
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list