Overriding iadd for dictionary like objects

Joshua Judson Rosen rozzin at geekspace.com
Sat Aug 29 07:23:59 CEST 2009


Robert Kern <robert.kern at gmail.com> writes:
>
> On 2009-08-28 16:42 PM, Terry Reedy wrote:
> > Carl Banks wrote:
> >
> > > I don't think it needs a syntax for that, but I'm not so sure a
> > > method to modify a value in place with a single key lookup
> > > wouldn't occasioanally be useful.
> >
> > Augmented assignment does that.
> 
> No, it uses one __getitem__ and one __setitem__ thus two key lookups.

Apparently you're defining "key lookup" some other way than as
`what __getitem__ does'.

What exactly does "key lookup" mean to you?

I've always understood it as `retrieving the value associated with a
key', which obviously isn't required for assignment--otherwise it
wouldn't be possible to add new keys to a mapping.

-- 
Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr)))).



More information about the Python-list mailing list