PEP 308: some candidate uses cases from live code
holger krekel
pyth at devel.trillke.net
Mon Feb 10 14:01:34 EST 2003
Andrew Koenig wrote:
> Here's an example from the Python 2.2.2 distribution, Lib/unittest.py,
> lines 618-619:
>
> self.stream.writeln("Ran %d test%s in %.3fs" %
> (run, run == 1 and "" or "s", timeTaken))
>
> Need I say more?
No, but maybe you can replicate it some more :-)
I have seen worse effects of buggy code than this.
Besides, in a PEP-308 world you would certainly find the like of
self.stream.writeln("Ran %d test%s in %.3fs" %
(run, 's' if run==1 else '', timeTaken)
Getting things messed up with ternary ops (whichever) is easy enough.
That doesn't imply we have to introduce a new one.
holger
More information about the Python-list
mailing list