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

Tim Peters tim.one at comcast.net
Mon Feb 10 20:20:26 CET 2003


[Andrew Koenig]
> 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 :-)

Cool!  Good eye.  I didn't find this because, in current CVS, that code
reads

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

Looks like Neal Norwitz fixed it 8 months ago.






More information about the Python-list mailing list