Dijkstra on Python

Christopher A. Craig list-python at ccraig.org
Wed Aug 14 04:12:34 CEST 2002


Robin Becker <robin at jessikat.fsnet.co.uk> writes:

> as another example one only has to consider the dictator's paper on
> python optimisation http://www.python.org/doc/essays/list2str.html which
> has no fewer than 7 ways to do the same thing. The zen of Python is
> often pretty meaningless.

But only one of those ways (or maybe none of them) is the obvious
solution.  Certainly you don't claim that you immediately thought of
f5 and f7 when you read the problem, or that if you were asked to
create a string from a list of ASCII values you would be thrown into a
conundrum about the merits of the various obvious solutions to the
problem.

At the time that paper was written, I would have considered f1 to be
the obvious solution.  Unless I had some good reason for needing to
optimize, I never would have tried anything else.  Now, having become
more one with Python, I would immediately write 
"".join(map(chr, list)) without even thinking.  That from is concise, 
fast, and its meaning rather obvious.

It is important to keep in mind that it is the Zen of Python, not the
Python Feature List, or the Cardinal Rules of Python Programming.  Two
people listening to a waterfall may not hear the same thing.

-- 
Christopher A. Craig <list-python at ccraig.org>
"Beware of bugs in the above code; I have only proved it correct, not
 tried it." Donald Knuth




More information about the Python-list mailing list