Perfect. This is what I"ll use. Thanks! Mike
--
http://mail.python.org/mailman/listinfo/python-list
Mike wrote:
I should've mentioned I want StdoutLog to subclass the 'file' type
because I need all the file attributes available.
You might use a surrogate pattern. Here's one I use for this kind of
situation, where I want to subclass but that can't be done for some reason.
class SurrogateNotInite
flushing stdout has no effect.
I've got an implementation that does not subclass file. It's not as
nice but it works.
--
http://mail.python.org/mailman/listinfo/python-list
Mike wrote:
I would like my 'print' statements to send its output to the user's
screen and a log file.
This is my initial attempt:
class StdoutLog(file):
def __init__(self, stdout, name='/tmp/stdout.log',
mode='w',bufsize=-1):
super(StdoutLog, self).__init__(name,mode,bufsize)
s
In that case, it looks like you won't be able to get what you want
without modifying CPython. PRINT_ITEM calls PyFile_SoftSpace,
PyFile_WriteString, and PyFile_WriteObject, which all use
PyFile_Check(). It might be as simple as changing these to
PyFile_CheckExact() calls in PyFile_WriteString / P
I would like my 'print' statements to send its output to the user's
screen and a log file.
This is my initial attempt:
class StdoutLog(file):
def __init__(self, stdout, name='/tmp/stdout.log',
mode='w',bufsize=-1):
super(StdoutLog, self).__init__(name,mode,bufsize)
self.stdout
Thanks.
I should've mentioned I want StdoutLog to subclass the 'file' type
because I need all the file attributes available.
I could add all the standard file methods and attributes to StdoutLog
without subclassing 'file' but I'd rather avoid this if I can.
--
http://mail.python.org/mailman/li
This variation works:
#
class Tee:
def __init__(self, *args):
self.files = args
def write(self, data):
for f in self.files:
result = f.write(data)
return result
def writelines(s