nonlocal fails ?

Antoon Pardon antoon.pardon at vub.be
Fri Nov 15 04:21:42 EST 2019


On 14/11/19 18:46, R.Wieser wrote:
> Jan,
>
>> So what you want to do is dynamic scope?
> No, not really.    I was looking for method to let one procedure share a 
> variable with its caller - or callers, selectable by me.   And as a "by 
> reference" argument does not seem to exist in Python ...

If you start thinking about what kind of argument passing mechanisme
Python has,
you should first think about what kind of assignment semantics Python has.

In some sense all parameter passing in Python is by reference, but it is
the assignment
semantics that cause it to not have the effect people expect.

The preffered terminology is call by sharing, but if you mutate the
parameter it has the
same effect as call by reference.

-- 
Antoon.


More information about the Python-list mailing list