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

Paul Paterson hamonlypaulpaterson at
Sun Feb 9 20:58:55 CET 2003

"Carlos Ribeiro" <cribeiro at> wrote in message
news:mailman.1044816810.28135.python-list at
> On Sunday 09 February 2003 01:30, Paul Paterson wrote:
> > As per a different thread where I did the reverse and searched the
> > code in the Python standard library + assorted packages on my system. I
> > found,
> >
> > 769 candidates where the conditional expression could be used to replace
> > assignment
> > 381210 lines of code
> >
> > So as a rough estimate we get one use per (381210 - 4*769)/769 = 491
> > of code.
> Frequency of usage is *not* a good metric. What counts is having the right
> tool for the job, when you happen to need it.

Frequency of alternative pattern usage is a reasonably good metric of
frequency of likely usage - which was all I was trying to measure here. As
you say, the *value* per use is not at all represented by the statistics.

> Just for a funny counter example: in my standard installation of Mandrake,
> /usr/lib/python, I got the following counts:
> 59520 lines of code
> 152 occurrences of 'continue'
> 306 occurrences of 'break'
> 353 occurrences of 'pass'.
> Does any of the above mean that 'continue', 'break', or 'pass' aren't
worth to
> be part of the language?
> Seriously, it's too easy to get confused with statistics. Let us not even

It gives a different viewpoint - if the new formulation is going to lead to
unreadable code then how often will one come across the unreadable code in
practice, ie how much will readability really suffer. If it is one line in
several hundred than that is a different thing than once every 10 lines or
once every 10,000 lines.

More information about the Python-list mailing list