Official definition of call-by-value (Re: Finding the instance reference...)

Aaron Brady castironpi at gmail.com
Fri Nov 21 05:41:56 EST 2008


On Nov 21, 4:33 am, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> Aaron Brady <castiro... at gmail.com> wrote:
> >> a[:] = [1, 2, 3]
>
> > No, that's not assignment, it's syntactic sugar for a __setslice__
> > call.  No copies here.
>
> Oh dear, perhaps you had better get the Python developers to update the
> grammar that Python uses as that seems to think it's an assignment:

Well, the docs don't take my side either.

"object.__setitem__(self, key, value)
Called to implement assignment to self[key]."

But wait, is that true assignment?

"Assignment statements
Assignment statements are used to (re)bind names to values and to
modify attributes or items of mutable objects:"

"If the target is an identifier (name):
... the name is bound to the object in the current global namespace."

The latter is the case of interest.






More information about the Python-list mailing list