cannot create my own dict

Bruno Desthuilliers bdesth.quelquechose at
Wed Sep 19 21:25:38 CEST 2007

Steve Holden a écrit :
> A.T.Hofkamp wrote:

>> So if copying all methods of a native dictionary is not enough, what 
>> should I
>> do to make my class work as a dictionary WITHOUT deriving from dict 
>> (which will
>> obviously work).
> You have to overwrite the "__new__" method to return an object of your 
> new type.


This applies to subclasses of immutable types, but I don't see the point 
here. The problem is - as Peter pointed out - that __magic__ methods are 
not looked up in instances when using new-style classes.

More information about the Python-list mailing list