nonlocal fails ?
R.Wieser
address at not.available
Fri Nov 15 07:28:50 EST 2019
Dennis,
> The first thing one needs to learn is that Python does NOT follow the
> common post-office mailbox concept where
>
> x = y
>
> means the /value/ stored at location identified by "y" is /copied/ to the
> location identified by "x".
:-) Although that is how we humans remember the effect of what we do, there
is no reason for a programming language to do it exactly like that. And
sometimes they don't.
> means /find/ the object (somewhere in memory) that has a note "y"
> stuck to it. Without moving the "y" note, attach an "x" note to that
> same object.
Which you can find back in any language which allows a "by reference"
passing of arguments to a procedure (and do remember how strings are often
/only/ passed as such). The caller often uses one name for the "value"
passed as an argument but in the procedure uses a different one - both
accessing the same contents.
> In software engineering as I learned it, it is preferable to decouple
... not because its so good for us humans, but that way you can
mathematically prove that the finished program should work as designed.
... which some languages (mostly the ones which allow only single results
returned from a function) are starting to turn back from (allowing "by
reference" access back in - its just too damn usefull).
> All depends upon the scope of those procedures.
I have no idea which circumstances you're hinting at. But just take it
that the scope is local - apart from that externally referenced value
ofcourse.
> The simplest is to use a mutable object as a container at the
> module level.
With some variation of "simple" I guess. :-)
Personally I think I would sooner go for a single-element tuple.
Regards,
Rudy Wieser
More information about the Python-list
mailing list