output to console and to multiple files
nathan.shair at gmail.com
nathan.shair at gmail.com
Thu Feb 15 10:53:41 EST 2007
On Feb 14, 5:10 pm, "goodwolf" <Robert.Ka... at gmail.com> wrote:
> like this?
>
> class Writers (object):
>
> def __init__(self, *writers):
> self.writers = writers
>
> def write(self, string):
> for w in self.writers:
> w.write(string)
>
> def flush(self):
> for w in self.writers:
> w.flush():
>
> import sys
>
> logfile = open('log.txt', 'w')
> sys.stdout = Writers(aya.stdout, file('log.out', 'w'), logfile)
> sys.stderr = Writers(aya.stdout, file('log.err', 'w'), logfile)
i've tried simliar methods to this and to what Matimus wrote. I know
it works great when using print statements.
However, I'm looking to find something that will work with the output
from a subprocess, such as from spawn, os.system, os.popen, etc.
More information about the Python-list
mailing list