Beautiful Code in Python?

Jonathan Gardner jgardner at jonathangardner.net
Mon Mar 3 14:56:41 EST 2008


On Mar 2, 8:35 am, Michele Simionato <michele.simion... at gmail.com>
wrote:
> On Mar 2, 5:23 pm, js <ebgs... at gmail.com> wrote:
>
> > Hi,
>
> > Have you ever seen Beautiful Python code?
> > Zope? Django? Python standard lib? or else?
>
> > Please tell me what code you think it's stunning.
>
> The doctest module in the standard library.
>
>  M.S.

The first thing of beauty I found in Python (coming from C, C++, and
perl) was the way Python handled variables, or as someone recently
described them, names.

Python's "for" statement is always beautiful to look at. Especially
when someone uses the else clause rather than trying to detect if the
list was exhausted. I sometimes avoid using the comprehensions just to
get an excuse to write another for loop in Python. There can never be
enough for loops written in Python!

Also, Python's iterator interface is by far the most beautiful thing I
have ever seen in the world of programming. Of course, the reason why
the for loop is so beautiful is because iterators are so beautiful.



More information about the Python-list mailing list