Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > unbuffering std streams in code

Reply
Thread Tools

unbuffering std streams in code

 
 
John Reese
Guest
Posts: n/a
 
      05-28-2005
You know how you can specify that stderr, stdin, stdout should be
unbuffered by running python with the -u switch? Is there any way I
can have the same affect in code by doing something to the sys.std*
variables?
 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      05-28-2005
John Reese wrote:

> You know how you can specify that stderr, stdin, stdout should be
> unbuffered by running python with the -u switch? Is there any way I
> can have the same affect in code by doing something to the sys.std*
> variables?


try this:

>>> import os, sys
>>> sys.stdout = os.fdopen(sys.stdout.fileno(), sys.stdout.mode, 0)


(repeat for the other streams)

(-u does a bit more than this on some platforms, but the above
should be good enough for many purposes)

</F>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
error: 'std::ios_base& std::ios_base::operator=(const std::ios_base&)' is private Geoffrey S. Knauth C++ 6 01-18-2006 11:48 AM
xServices::CServices<TImp>::StHoldClientList::StHoldClientList(std::set<TImp*, std::less<TImp*>, std::allocator<TImp*> >&)': Vinu C++ 4 07-07-2005 06:08 AM
xServices::CServices<TImp>::StHoldClientList::StHoldClientList(std::set<TImp*, std::less<TImp*>, std::allocator<TImp*> >&)': Vinu C++ 0 07-06-2005 12:45 PM
std::map<int,std::set<std::string> > Wrong? (Segmentation fault.) Peter Jansson C++ 5 03-17-2005 06:34 AM



Advertisments