Want to inherit from file
Steve Holden
sholden at holdenweb.com
Fri Nov 10 11:18:32 EST 2000
Franz GEIGER wrote:
>
> I'd like to inherit from file to add some functionality:
>
[snip]
> As a file object comes into existence by calling f=open() and not something
> like f=File(), I guess there is no regular way to do it.
>
> Any idea how to overcome this?
>
> Best regards
> Franz GEIGER
Correct. One of the less-pure aspects of Python is that the built-in
types are not first-class objects such as you build when defining your
own classes, and cannot be used as superclasses.
However, it's quite easy to build a wrapper class, offering pretty much
the same functionality. Take a look at the UserList and UserDict library
modules for clues as to how.
regards
Steve
--
Helping people meet their information needs with training and technology.
703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/
More information about the Python-list
mailing list