[Python-ideas] Replacing the standard IO streams (was Re: changing sys.stdout encoding)

Antoine Pitrou solipsis at pitrou.net
Sun Jun 10 09:17:02 CEST 2012

Le 10/06/2012 04:26, Nick Coghlan a écrit :
> Calling detach() on the standard streams is a bad idea - the interpreter
> uses the originals internally, and calling detach() breaks them.

Where does it do that? The interpreter certainly shouldn't hardwire the 
original objects internally.

Moreover, your snippet is wrong because if someone replaces the streams 
for a second time, garbage collecting the previous streams will close 
the file descriptors. You should use closefd=False.



More information about the Python-ideas mailing list