[Tutor] My first contribution

Terry Carroll carroll@tjc.com
Tue Apr 22 03:05:03 2003

I've been playing with Python for about 4 months now.  Thanks to the 
various members of this list who have patiently explained some concepts of 
the language to me.

It took, I guess, because I've now made my first (admittedly trivial) 
contribution to Python.

When I first used nntplib, it bothered me that all the newsgroup headers
retrieved by nntplib.xover() were placed in a list all at once.  I would
have preferred it if they could be passed back to the caller as they were
received.  For one thing, if there are a lot of headers, it can
potentially take up a lot of memory.  For another, it might take a lot of
time, and it would be nice to be able to indicate to the user that there
is some progress going on.

At the same time, someone on comp.lang.python was making the same
observation; he'd had memory constraint issues on small systems when
retrieving a lot of headers.

So, I modified nntplib to write the headers to a file or to an open file 
object.  By making a class a subclass of a file object, you could replace 
the write() method with your own method, and examine the headers to decide 
which you wanted to keep, provide a progess message, whatever.

I then expanded this to support all multi-line outputs from nntplib (I
figure, what I want for XOVER, someone else could want for some other NNTP
command), and turned it into a patch (720468), which I submitted.  It's
been accepted, so some day this will be a standard part of Python (2.4?).

(The patch really was trivial, because a previous patcher, Travers Naran,
really did all the hard work, by putting in similar support for the
nntplib.body() method; all I had to do was generalize it to the other

I've never had the opportunity to contribute to an open source project 
before.  Feels good, even if it is a trivial patch.

Terry Carroll        |  "To have this rare opportunity
Santa Clara, CA      |    is a rare opportunity."
carroll@tjc.com      |    - Houston Rockets' Yao Ming, on being named
Modell delendus est  |    starting center for the 2003 NBA All-Star Game