Custom Formatting The Output Of subprocess.Popen
Scott David Daniels
Scott.Daniels at Acm.Org
Fri Nov 21 16:35:36 EST 2008
thedsadude at gmail.com wrote:
> ...
> so, it seems to me that if I would know how to write a file object,
> then I could write one that prefixes each line, and that would be
> fine, no? I don't see how this would necessitate waiting for p.py's
> termination, or matter that it is a different process. I just don't
> know how to create a file object.
Duck typing to the rescue: Here's a simple file object for writing:
class MyFunkyOutput(object):
def write(self, sometext):
print repr(sometext)
def close(self):
pass
outputter = MyFunkyOutput()
print >>outputter, 1,'a', 43
More information about the Python-list
mailing list