Home

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

>> 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.

previous
next

Question on overriding implicit lookups
Re: vector of (int,string). can't convert i->first to int
Bill Gates try to sell Microsoft @ ebay look here
Re: Assertion in list comprehension
RE: How to Start
Fundacja Sloneczko
Mam Marzenie
Podaruj Zycie
Fundacja Avalon
Mimo Wszystko