[David Fraser]
> Others may find this helpful ; it's a pure Python wrapper for cStringIO
> that makes it behave like StringIO in not having initialized objects
> readonly. Would it be an idea to extend cStringIO like this in the
> standard library? It shouldn't lose performance if used like a standard
> cStringIO, but it prevents frustration :-)

IMO, that would be a step backwards.  Initializing the object and then
writing to it is not a good practice.  The cStringIOAPI needs to be as
file-like as possible.  With files, we create an emtpy object and then
starting writing (the append mode for existing files is a different story).
Good code ought to maintain that parallelism so that it is easier to
substitute a real file for a writeable cStringIO object.

This whole thread (except for the documentation issue which has been
fixed) is about fighting the API rather than letting it be a guide to good
code.

If there were something wrong with the API, Guido would have long
since fired up the time machine and changed the timeline so that all
would be as right as rain ;-)


Raymond Hettinger


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to