PEP 308: A PEP Writer's Experience - PRO

Erik Max Francis max at alcyone.com
Mon Feb 10 22:26:56 EST 2003


John La Rooy wrote:

> Point to Andrew!
> 
> I would suggest using one of these forms
> 
>     self.stream.writeln("Ran %d test%s in %.3fs" %
>                         (run, ("s","")[run==1], timeTaken))
> 
> or
>     self.stream.writeln("Ran %d test%s in %.3fs" %
>                         (run, "s"[run==1:], timeTaken))
> 
> There is negligible difference in performance. I think the indexed one
> is
> a little clearer.

The issue isn't performance, it's legitibility, but more importantly,
correctness.

> Do we really want to start seeing this? ...

I sure wouldn't mind seeing

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

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Ride / Ride this wave of mine
\__/ Res
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.




More information about the Python-list mailing list