StringIO proposal: add __iadd__

Paul Rubin http
Sun Jan 29 17:28:42 EST 2006


aleax at mail.comcast.net (Alex Martelli) writes:
> But why can't I have perfectly polymorphic "append a bunch of strings
> together", just like I can now (with ''.join of a list of strings, or
> StringIO), without caring whether the strings are Unicode or
> bytestrings?

I see that 'a' + u'b' = u'ab', which makes sense.  I don't use Unicode
much so haven't paid much attention to such things.  Is there some
sound reason cStringIO acts differently from StringIO?  I'd expect
them to both do the same thing.

> As for extending cStringIO.write I guess that's
> possible, but not without breaking compatibility ... you'd
> need instead to add another couple of methods, or wait for Py3k.

We're already discussing adding another method, namely __iadd__.
Maybe that's the place to put it.



More information about the Python-list mailing list