PEP 305 - CSV File API

Ian Bicking ianb at colorstudy.com
Sun Feb 2 16:01:04 EST 2003


On Sun, 2003-02-02 at 12:51, Andrew Dalke wrote:
> Hmm.... I'm have an "X".  You don't know what it is, but I tell you
> it's some sort of container which allows forward iteration and
> returns 'row' objects.  I also tell you you can add new row objects
> X, but only one at a time and only after the previous one you added.
> If you start appending row objects to an empty X and then read them
> again from the start, you get them in the same order.
> 
> You may also be able to do other things to X, if you peer into the
> internals, but I'm not going to let you.
> 
> The question for you is, what is "X"?

But to me I expect "obj.append(x)" to imply "obj[-1] == x" and also that
"obj.append(x)" is equivalent to "obj += x".

The sequence interface is implemented many places, but almost always in
a reasonably complete manner.  Files (aka streams) *aren't* sequences,
except that they are iterable.  The write method doesn't fit because the
arguments don't fit, but the write semantics are quite appropriate.

If you were implementing a wrapper on a CSV that made it look like an
in-memory object with random access, then append would be more
appropriate, IMHO.

-- 
Ian Bicking           Colorstudy Web Development
ianb at colorstudy.com   http://www.colorstudy.com
PGP: gpg --keyserver pgp.mit.edu --recv-keys 0x9B9E28B7
4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241






More information about the Python-list mailing list