inheriting file object

2005-07-06 Thread Jeremy
Hello all, I am trying to inherit the file object and don't know how to do it. I need to open a file and perform operations on it in the class I am writing. I know the simple syntax is: class MyClass(file): ... but I don't know how to make it open the file for

Re: inheriting file object

2005-07-06 Thread harold fellermann
On 06.07.2005, at 18:58, Jeremy wrote: Hello all, I am trying to inherit the file object and don't know how to do it. I need to open a file and perform operations on it in the class I am writing. I know the simple syntax is: class MyClass(file): ... but I don't know how to

Re: inheriting file object

2005-07-06 Thread Jeremy Jones
Jeremy wrote: Hello all, I am trying to inherit the file object and don't know how to do it. I need to open a file and perform operations on it in the class I am writing. I know the simple syntax is: class MyClass(file): ... but I don't know how to make it open the file for

Re: inheriting file object

2005-07-06 Thread Jeremy
Jeremy Jones wrote: Something like this? I put the following code in test_file.py: class MyFile(file): def doing_something(self): print in my own method And used it like this: In [1]: import test_file In [2]: f = test_file.MyFile(foobar.file, w) In [3]:

Re: inheriting file object

2005-07-06 Thread harold fellermann
I don't know if I should be inheriting file or just using a file object. How would I determine which one would be more appropriate? Inheritance is often refered to as an IS relation, whereas using an attribute is a HAS relation. If you inherit from file, all operations for files should be

Re: inheriting file object

2005-07-06 Thread Jeremy
harold fellermann wrote: I don't know if I should be inheriting file or just using a file object. How would I determine which one would be more appropriate? Inheritance is often refered to as an IS relation, whereas using an attribute is a HAS relation. If you inherit from file, all