> class Output(file): > def __init__(self, name, mode='w', buffering=None, verbosity=1): > super(Output, self).__init__(name, mode, buffering) > self.verbosity = verbosity > > def write(self, string, messageVerbosity=1): > if messageVerbosity <= self.verbosity > super(Output, self).write(string)
I may have to just accept name as a string or as a file object so that I can still provide the same interface as a file object. It'll just store and use a separate file object when it needs to handle writing to stdout and sterr. This way it should always be able to be used in place of a file object. err, and again, not that it matters but in the code above verbosity should of course get the value passed in, not 1 :/ -- http://mail.python.org/mailman/listinfo/python-list