PEP 308: A PEP Writer's Experience - PRO

Andrew Koenig ark at research.att.com
Mon Feb 10 03:39:22 CET 2003


Tim> The problem with the example is that it's already easily
Tim> expressed safely by the and/or idiom,

Tim>     print "Processing", filename == "-" and "<stdin>" or filename

But it's safe only by coincidence.  In particular, if you change
"<stdin>" to "", it breaks.

To me, the apparently widespread use of an idiom that works only
because the middle value happens to be nonempty is strong evidence
that we should have a more robust and universal way of expressing
this particular idea.

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list