coding style - where to declare variables

Richard Damon Richard at Damon-family.org
Sun Jul 22 16:16:37 EDT 2018


> On Jul 22, 2018, at 3:50 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> I wish people stopped talking about "name binding" and "rebinding,"
> which are simply posh synonyms for variable assignment. Properly, the
> term "binding" comes from lambda calculus, whose semantics is defined
> using "bound" and "free" variables. Lambda calculus doesn't have
> assignment.
> 
> More about variable binding here: <URL:
> https://en.wikipedia.org/wiki/Free_variables_and_bound_variables>
> 
> 
> Marko

Marko, I think the term binding makes sense in python due to how names work.
In python and the following code:

X = getit()
Y = X
X.changeit()

In python, presuming getit() returns some form of object (so it has a changeit() member) then X and Y are bound to the same object, and changeit() will thus also affect the object that we see at Y.
With a language with more ‘classical’ variable, the assignment of Y = X would normal make a copy of that object, so the value Y does not get changed by X.changeit().


More information about the Python-list mailing list