How to capture stdout in an exec'ed string?
preston at jump.net
Thu Nov 18 04:22:08 CET 1999
Thanks a lot Mark! It only took a few microseconds after I posted to
realize what I needed to do. For some reason the concept of saving
and restoring the stdout handler didn't occur to me. I was thinking
about namespace issues which are not really related.
"Mark Hammond" <mhammond at skippinet.com.au> writes:
> Something like this should work:
> oldout = sys.stdout
> sys.stdout = My_STDOUT()
> cruft = my_ancient_class()
> sys.stdout = oldout
> except SystemExit, msg:
More information about the Python-list