sys.stndout syntax

David Bolen db3l at fitlinxx.com
Fri Aug 18 17:29:01 EDT 2000


"Jeff Kunce" <kuncej at mail.conservation.state.mo.us> writes:

> #Here is the general solution if you can't be bothered with remembering
> secret passwords:
> original_stdout = sys.stdout
(...)

Actually, I'd call this the preferred approach unless you're really
just working temporarily at the interactive prompt.

If you're writing actual code, then you can't really be positive that
sys.stdout hasn't already been redirected before you get called (some
other module may have imported you and is using one of your
functions), so if you reset to sys.__stdout__ explicitly you might not
be properly restoring any previous redirection.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list