"Raymond Hettinger" <[EMAIL PROTECTED]> writes: > The StringIO API needs to closely mirror the file object API. > Do you want to change everything that is filelike to have += > as a synonym for write()?
Why would they need that? StringIO objects have getvalue() but other file-like objects don't. What's wrong with __iadd__ being another StringIO-specific operation? And is making += a synonym for write() on other file objects really that bad an idea? It would be like C++'s use of << for file objects and could make some code nicer if you like that kind of thing. What I was really aiming for was something like java.lang.StringBuffer, if that wasn't obvious, but using an already-existing class (StringIO). java.lang.StringBuffer supports a bunch of other operations too, so maybe there's something to be said for adding something like it to Python and using that instead of StringIO for this purpose. I also now notice that the StringBuffer doc describes how the Java compiler is supposed to handle adding multiple String objects by using a temporary StringBuffer: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html That could be seen as a performance specification. -- http://mail.python.org/mailman/listinfo/python-list