Inconsistency in dictionary behaviour: dict(dict) not calling__setitem__
Terry Reedy
tjreedy at udel.edu
Tue Dec 12 20:18:44 EST 2006
"Almad" <bugs at almad.net> wrote in message
news:1165948261.745137.88540 at j72g2000cwa.googlegroups.com...
> Hello,
>
> I discovered this behaviour in dictionary which I find confusing
...
> However, when constructing dictionary with dictionary in constructor
> like d = RegisterMap({'k':'v'}), __setitem__ is not called,
d.__setitem__(k,v) is the internal translation of d[k] = v (when such is
explicitly written in this code). d.__init__(otherdict) need not go thru
that interface if a more direct means is available.
>so workaround is needed:
Your 'workaround' seems to be the proper solution.
> Am I doing something wrong
Denigrating a solution because it does not meet your expectation.
Your are not the first to do this ;-).
tjr
More information about the Python-list
mailing list