Making the Zen of Python more useful
Peter Hansen
peter at engcorp.com
Fri Apr 2 17:34:52 EST 2004
Aloysio Figueiredo wrote:
>>>>import sys
>>>>t,sys.stdout = sys.stdout, file('/dev/null', 'w')
>>>>from this import s
>>>>sys.stdout = t
>>>>s.decode('rot-13')
Aloysio, it's often helpful that sys.__stdout__ preserves a reference
to the original sys.stdout (similarly with sys.__stdin__ and
sys.__stderr__) so you don't have to preserve it manually like
that.
-Peter
More information about the Python-list
mailing list