For review: PEP 308 - If-then-else expression

Andrew Koenig ark at research.att.com
Mon Feb 10 13:21:49 EST 2003


Tim> Well, if you try to prove that a piece of code is correct when
Tim> you don't understand what it does, it's going to be very easy
Tim> indeed to find "not obvious" stuff.  What's more surprising to me
Tim> is that you found half the instances obvious despite not knowing
Tim> the code's intent <wink>.

What I think is more interesting is this code from Lib/unittest.py:

        self.stream.writeln("Ran %d test%s in %.3fs" %
                            (run, run == 1 and "" or "s", timeTaken))

When the and/or idiom causes a bug in the standard library's test module,
I think it's time to seek a more robust alternative :-)

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




More information about the Python-list mailing list