invalid at invalid.invalid
Sat Oct 17 07:15:13 CEST 2009
On 2009-10-17, Dave Angel <davea at ieee.org> wrote:
> mattia wrote:
>> Is there a way to print to an unbuffered output (like stdout)? I've seen
>> that something like sys.stdout.write("hello") works but it also prints
>> the number of characters!
> What the other responses (so far) didn't address is your comment about
> "prints the number of characters."
> You're presumably testing this in the interpreter, which prints extra
> stuff. In particular, it prints the result value of any expressions
> entered at the interpreter prompt. So if you type
> then after the write() method is done, the return value of the method
> (5) will get printed by the interpreter.
Except sys.stdout.write("hello") doesn't return 5. It returns
I don't know what the OP is talking about when he says "prints
the number of characters":
Python 2.6.2 (r262:71600, Aug 25 2009, 22:35:31)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more
>>> import sys
> Either put the statement in a real script, or do the following trick to
> convince yourself:
> dummy = sys.stdout.write("hello")
I don't see why the assignment is needed.
More information about the Python-list