saving the text on python dos window.
__peter__ at web.de
Thu Jun 24 14:21:41 CEST 2004
Daniel Dittmar wrote:
> class TeeStream:
> def __init__ (self, *outstreams):
> self.outstreams = outstreams
> def write (self, text):
> for outstream in self.outstreams:
> outstream.write (text)
> # do the same for writelines, flush etc.
Or if you are really lazy, use this modification:
def __init__ (self, *instances):
self._instances = instances
def __getattr__(self, name):
def call(self, *args, **kw):
for i in self._instances:
getattr(i, name)(*args, **kw)
setattr(self.__class__, name, call)
return getattr(self, name)
It creates methods lazily on the fly as needed.
More information about the Python-list