Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)
Simo Melenius
firstname.lastname at iki.fi-spam
Mon Jan 3 16:38:43 EST 2005
Just <just at xs4all.nl> writes:
> In article <87u0py6elt.fsf at sme.intra.citec.fi>,
> Simo Melenius <firstname.lastname at iki.fi-spam> wrote:
> > ... sys.stdout = sys.__stdout__
> Aargh, I can't believe how widespread this idiom is :-(. See my other
> reply in this thread: DON'T use sys.__stdout__. Ever.
It probably does the right thing, if someone is copypasting code off
the Usenet and tries it out at the Python prompt (and possibly gets
stuck in getting nothing printed on his tty).
If we're talking about real code it might be advisable to start by
first introducing the import statements omitted from the above
snippet, then worry about someone copypasting code into a serious
program instead of copythinkpasting it. :)
br,
S
More information about the Python-list
mailing list