[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Beautiful Code in Python?

js

3/2/2008 4:24:00 PM

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.
9 Answers

Michele Simionato

3/2/2008 4:36:00 PM

0

On Mar 2, 5:23 pm, js <ebgs...@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.

John DeRosa

3/2/2008 6:02:00 PM

0

On Mon, 3 Mar 2008 01:23:32 +0900, js <ebgssth@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.

Just about any Python code I look at.

Aaron Brady

3/2/2008 6:19:00 PM

0

On Mar 2, 12:01 pm, John DeRosa <stug...@qwest.net> wrote:
> On Mon, 3 Mar 2008 01:23:32 +0900, js <ebgs...@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.
>
> Just about any Python code I look at.

Decorators, with, and namedtuple.

Bruno Desthuilliers

3/3/2008 11:07:00 AM

0

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.

Jonathan Gardner

3/3/2008 7:57:00 PM

0

On Mar 2, 8:35 am, Michele Simionato <michele.simion...@gmail.com>
wrote:
> On Mar 2, 5:23 pm, js <ebgs...@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.

babycode

3/3/2008 8:42:00 PM

0

> Please tell me what code you think it's stunning.

Pexpect is (almost) pseudocode is (almost) poetry to my ears. And
there's a lot of narrative in it as well:

http://pexpect.svn.sourceforge.n...*checkout*/pexpect/trunk/pexpect/pexpect.py?content-type=text%2Fplain

sjdevnull@yahoo.com

3/3/2008 10:30:00 PM

0

On Mar 2, 1:18 pm, castiro...@gmail.com wrote:
> On Mar 2, 12:01 pm, John DeRosa <stug...@qwest.net> wrote:
>
> > On Mon, 3 Mar 2008 01:23:32 +0900, js <ebgs...@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.
>
> > Just about any Python code I look at.
>
> 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.

Aaron Brady

3/4/2008 1:12:00 AM

0

On Mar 3, 4:30 pm, "sjdevn...@yahoo.com" <sjdevn...@yahoo.com> wrote:
> On Mar 2, 1:18 pm, castiro...@gmail.com wrote:
>
> > On Mar 2, 12:01 pm, John DeRosa <stug...@qwest.net> wrote:
>
> > > On Mon, 3 Mar 2008 01:23:32 +0900, js <ebgs...@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.
>
> > > Just about any Python code I look at.
>
> > 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.

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

Aaron Brady

3/9/2008 11:45:00 PM

0

On Mar 2, 1:18 pm, castiro...@gmail.com wrote:
> On Mar 2, 12:01 pm, John DeRosa <stug...@qwest.net> wrote:
>
> > On Mon, 3 Mar 2008 01:23:32 +0900, js <ebgs...@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.
>
> > Just about any Python code I look at.
>
> Decorators, with, and namedtuple.

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