Swapping out sys.stdout globally

Kevin Smith Kevin.Smith at sas.com
Fri Mar 1 09:31:34 EST 2002


I am working on a command-line utility written in Python which daemonizes
itself.  In the process of daemonizing, sys.stdout and sys.stderr are
redirected to now file-like objects as follows:

sys.stdout = NewFile()
sys.stderr = NewFile()

However, I have some logging routines in a separate package that already
have their own references to sys.stdout and sys.stderr which are
unaffected by this.  Is there a way to chonge where sys.stdout and
sys.stderr print their output to and have this change affect all existing
references?

-- 
Kevin SmithKevin.Smith at sas.com



More information about the Python-list mailing list