print problem
Rich Healey
healey.rich at gmail.com
Tue Jun 17 03:10:41 EDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Gabriel Genellina wrote:
> En Tue, 17 Jun 2008 03:15:11 -0300, pirata <pirata at mars.invalid> escribió:
>
>> I was trying to print a dot on console every second to indicates
>> running process, so I wrote, for example:
>>
>> for i in xrange(10):
>> print ".",
>> time.sleep(1)
>>
>> Idealy, a dot will be printed out each second. But there is nothing
>> print out until after 10 seconds, all 10 dots come out together.
>>
>> I've tried lose the comma in the print statement, and it works.
>>
>> Is that because of the print statement buffer the characters until
>> there is a new line character?
>
> Very probably, altough I can't reproduce it on Windows. Try invoking the script with python -u (unbuffered input/output):
>
> python -u your_script.py
>
Or just write to sys.stdout without the print wrapper..
- --
Rich Healey - healey.rich at gmail.com
Developer / Systems Admin - OpenPGP: 0x8C8147807
MSN: bitchohealey at hotmail.com AIM: richohealey33
irc.psych0tik.net -> #hbh #admins richohealey
irc.freenode.org -> #hbh #debian PythonNinja
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIV2NxLeTfO4yBSAcRAkunAJ9w5lavHK4TIUbexX+pSYmPla9oOQCfT8tM
tzOhQgcpO7dEG7WhE6FNZ4w=
=IqJ1
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list