Re: [Tutor] class Writer

2006-05-24 Thread Alan Gauld
> I understand that the class is taking the strings from > stdout (supplied by the print statements) and writing > them to a text file. Does the user need to explicitly > call the write function? For example: > > sys.stdout = Writer('tmp.log').write(whatever the > message is) No, that's what pr

Re: [Tutor] class Writer

2006-05-24 Thread Danny Yoo
On Wed, 24 May 2006, Christopher Spears wrote: > I've been working my way through an online tutorial and came across the > following sample script: > > import sys > > class Writer: >def __init__(self, filename): >self.filename = filename >def write(self, msg): >f = file(

[Tutor] class Writer

2006-05-24 Thread Christopher Spears
I've been working my way through an online tutorial and came across the following sample script: import sys class Writer: def __init__(self, filename): self.filename = filename def write(self, msg): f = file(self.filename, 'a') f.write(msg) f.close() sys.s