hans at zephyrfalcon.org
Sat Jan 1 23:23:32 CET 2005
Uwe Mayer wrote:
>>>Why is the UserDict module is deprecated after Python 2.2. The
>>>application of it I have in mind is, i.e. multiple inheritance from
>>>"file" and "dic" - which is not possible.
> I was writing a class that read /writes some binary file format. I
> implemented the functions from the file interface such that they are
> refering to records. However, the file format has some header fields and
> I'd wanted to grant access to those via the dict-interface.
> Another example: working with PyQt I have an instance of a QListView and
> wanted to use the list-interface to get and set individual records.
If it's just a matter of attribute access, implementing the relevant
__getitem__ and __setitem__ methods will probably suffice. I don't
think that deriving from dict or list will do you much good here... most
of the methods will be irrelevant, or won't do what you want, so you
have to override them anyway.
More information about the Python-list