Beautiful Code in Python?

J

js

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.
 
M

Michele Simionato

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.
 
J

John DeRosa

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.

Just about any Python code I look at.
 
B

Bruno Desthuilliers

js a écrit :
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.

FormEncode has some very interesting parts IMHO.
 
J

Jonathan Gardner

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.
 
S

sjdevnull

Decorators, with, and namedtuple.

IMO, decorators are functional but far from beautiful. They're a
special, somewhat ugly syntax for something that was already handled
by normal constructs ("foo=classmethod(foo)") that you didn't need
extra knowledge to understand.

On balance I think it's worth it in order to get those "declarations"
up by the function defs, but it's sort of a tradeoff of magical non-
explicitness for pragmatism over purity. A worthwile tradeoff, but
not what I'd ever call beautiful.
 
C

castironpi

IMO, decorators are functional but far from beautiful.  They're a
special, somewhat ugly syntax for something that was already handled
by normal constructs ("foo=classmethod(foo)") that you didn't need
extra knowledge to understand.

On balance I think it's worth it in order to get those "declarations"
up by the function defs, but it's sort of a tradeoff of magical non-
explicitness for pragmatism over purity.  A worthwile tradeoff, but
not what I'd ever call beautiful.

Someone study architecture. What are the Palmer House, the Rookery,
and the Lyric Opera?
 
C

castironpi

<running gag>Oh yeah, and variable arguments and keyword
dictionaries.<throat clear/></running gag>

If you're C++, garbage collection. How's the cycle detector? The
pages and pages get pretty specific.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top