Re: print stream behavior

2009-05-27 Thread Peter Otten
Andreas Kraemer wrote: I don't understand the behavior of the print statement when streaming to a file-like object. From the documentation at http://www.python.org/doc/2.4.4/ref/print.html I understand that the file-like object needs to have a write() method that - I assume - is called when

Re: print stream behavior

2009-05-27 Thread Andreas Kraemer
On May 27, 10:52 am, Peter Otten __pete...@web.de wrote: This is a longstanding quirk of the CPython implementation. The PRINT_ITEM_TO opcode triggers a PyFile_WriteObject() call which in turn does the C equivalent of if isinstance(f, file):    file.write(f, s) else:    write = getattr(f,