Re: print >> to a derived file

2008-01-15 Thread Scott David Daniels
iu2 wrote: > Hi, > > I'm trying to write data to both a file and the console, so I did: > > class File_and_console(file): > def write(self, s): > file.write(self, s) > print s, f = File_and_console('1.txt', 'w') ... Always use the same method for writing,

Re: print >> to a derived file

2008-01-15 Thread iu2
On Jan 15, 12:44 pm, "Ben Fisher" <[EMAIL PROTECTED]> wrote: > This might have something to do with the class being derived from file. > > I've written it so that it doesn't derive from file, and it works. > > class File_and_console(): >         def __init__(self, *args): >                 self.fil

Re: print >> to a derived file

2008-01-15 Thread Ben Fisher
This might have something to do with the class being derived from file. I've written it so that it doesn't derive from file, and it works. class File_and_console(): def __init__(self, *args): self.fileobj = open(*args) def write(self, s): self.fileo

print >> to a derived file

2008-01-15 Thread iu2
Hi, I'm trying to write data to both a file and the console, so I did: class File_and_console(file): def write(self, s): file.write(self, s) print s, >>> f = File_and_console('1.txt', 'w') >>> f.write('hello') hello >>> print >>f, 'world' >>> the 'write'