Python switching off buffering to stdout

March 11, 2010 at 9:16 pm Leave a comment

For the benefit of google.

To switch off buffering of stdout in python one can use the following code:

def switch_off_buffering():
        sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
switch_off_buffering()

Note that some buffering occurs by default.

Alternatively one can use the -u option to python.

See also:
http://stackoverflow.com/questions/107705/python-output-buffering

Advertisements

Entry filed under: Uncategorized. Tags: , , , .

Human readable datetimes in python’s django Postgres sql basic querying based on datetime

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


March 2010
M T W T F S S
« Feb   Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

%d bloggers like this: