. Python 2.1 function attributes
David Bolen
db3l at fitlinxx.com
Mon Jan 29 13:51:16 EST 2001
Roy Katz <katz at Glue.umd.edu> writes:
> On Sat, 27 Jan 2001, Moshe Zadka wrote:
(...)
> > sys.stdout = sys.stderr
> > try:
> > print foo, bar
> > finally:
> > sys.stdout = sys.__stdout__
> >
>
> what is wrong with redirection? must we wrap the output in a try:
> anymore than wrap a standard print in a try:?
Because without this try, if something goes wrong you won't restore
sys.stdout to what it started with, which might affect surrounding
code. That's not an issue with a normal print in the middle of code,
but important when you're redirecting things.
--
-- 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