On 06/03/12 02:42, Dave Angel wrote:
My guess would be similar to the cat operator in Unix:
file3 = file1 + file2
So somehow assigning the object to file3 will write the data to a file
by the name "file3" ? I know about __add__(), but didn't know we had
__assign__()
We don't need any special assign behavior, its just standard Python
assignment of the returned object to a name.
class MyFile(file):
....
def __add__(self, file2):
newFile = MyFile('foo.dat','wb')
newFile.write(self.read())
newFile.write(file2.read())
return newFile
file3 = MyFile('spam.dat') + MyFile('baz.dat')
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor