Which objects are expanded by double-star ** operator?

Bryan bryanjugglercryptographer at yahoo.com
Tue Jun 8 08:59:54 EDT 2010


kkumer wrote:
> Bryan wrote:
> > I get the same bug-like behavior in 3.1. I think Peter is right that
> > it's probably a side-effect of an optimization. kkumer seems to have
> > completely over-ridden the methods of dict, but if we insert into his
> > hubDict with the parent class's method:
>
> >  dict.__setitem__(dh, 'c', 3)
>
> > Then the **dh argument passes the keyword arg c=3.
>
> Yes. But problem is that this setting of item
> should also affect one of the two original parent dicts,
> while  your proposal affects only hubDict instance.
> (hubDict is never used to create new items, just to change
> values of existing ones, which belong to one of
> two parents).

Right. This is helpful group, but my observation here does not solve
your immediate problem. Your work-around seems reasonable, and Peter
Otten's demo of what happens if you inherit from object rather than
dict might make **dh work as you want.


--
--Bryan



More information about the Python-list mailing list