[Python-Dev] who uses new language features? (was: Why did Fredrik leave the party?)

Zooko zooko@zooko.com
Wed, 05 Feb 2003 14:53:00 -0500


This is just a "data point" -- I'm going to tell you about my experiences and my 
choices rather than advocate something you should do.

I'm a programmer.  I'm pretty smart.  I know a lot of programming languages 
fluently.  (Or at least, I have known them fluently in the past.)

For the last four years or so Python has been my favorite programming language 
by far.

I'm the lead developer on a largish[1] project written in Python, named Mnet[2].

When the project started in 1999, the current version of Python was 1.5.1.

The latest release of Mnet works on all released Pythons from 1.5.2 to 2.2 
(although it does nothing to prevent accumulation of reference cycles).


 Mark Lutz <lutz@rmi.net> wrote:
>
> I don't disagree that 2.3 is more complex than 1.5.2.
> However, *some* of the changes made python easier to learn 
> and use.  At one time, every beginner had to learn:
> 
> * how to override __getitem__ and throw away the index
>    to simulate iteration

I've never done this, nor do I use the modern iterators.  This probably means 
there are places where my code could be tightened up by the application of 
iterators, but I don't feel particularly motivated about this.

> * to add 1L to their factorial function which worked fine
>    for small parameters but crashed with larger ones

Yeah, this was a pain.  I'm glad it's fixed.

> * to clutter code with x=x, y=y, etc to simulate nested scope      

Likewise, I find the modern language is nicer in this respect.

> * funky code contortions to simulate lockstep iteration

I don't know what this means (see earlier comment about iteration).

> * use of the lineinput module to read files line-by-line

I've always read text files line-by-line with the "readline()" method of a file 
object.  I don't know about the lineinput module.  I know about xreadlines() but 
I've never bothered to use it AFAIR.

By the way, you didn't mention generators as such, but likewise they are a new 
Python feature that I haven't bothered to learn.  I'm comfortable with the 
notion of continuations, and so I don't think I would have any trouble learning 
how to use generators, but I don't feel the need and it would make my code 
harder for others (who don't understand generators) to learn.


Now as to the Standard Library, I have rejoiced each time something was added to 
the Python Standard Library that I had previously done with a third-party module 
or with a homegrown module.  Many of the agenda items on the Mnet TODO list 
(some of which are now checked off) say "now that feature X is in the Python 
Standard Library, replace our homegrown X with the standard X".  These include 
distutils, pyunit, logging, bsddb3.


I will refrain from mentioning Things I Would Like To See because that would 
constitute advocating something you should do.


Regards,

Zooko

http://zooko.com/

[1] $ find . -iname '*.py' | xargs cat | sort -u | wc -l
    27784
    $ find . -iname '*.c' | xargs cat | sort -u | wc -l
    1081
    $ find . -iname '*.cpp' | xargs cat | sort -u | wc -l
    838

[2] http://mnet.sf.net/