Pass variable by reference

Mark H Harris harrismh777 at gmail.com
Wed May 7 14:11:46 EDT 2014


On 5/6/14 6:46 PM, Chris Angelico wrote:

>  Is there really a fundamental
> difference between languages in which that is equally valid syntax and
> does exactly the same thing?

No. And from that standpoint, python has variables. I know, because I 
thought about python's 'variables' as variables for quite sometime 
before I learned about the 'beautiful heart of python'.  AND I used them 
as variables too, ignorantly of course.

And we must never forget that CPython's underpinnings, uhm C, uses 
variables, C ones...  (never mind)

Here is the rub. What happens when a newbie (me, some some years ago) 
gets a strange 'surprise' when trying to use python's variables:

Given that A is bound to 3.5, and B is also bound to another object 3.5:

A == B
True

A is B
False

... and now they want to know why if A == 3.5 and B == 3.5 does (A is B) 
come up False?

This is just one of a dozen 'different' kinds of examples. And the 
answer is the same, Python does not have variables, Python has names 
bound to objects.

The cleanest clearest explanation of Python's (name-->object) model is 
'the beautiful heart of python' in Mark Summerfield's Programming Python 
3.

I think we should STOP saying that python does not have variables (like 
that horse hasn't been beaten before, to death) but instead explain 
Python's beautiful heart. uhm,  "What you have been using in ignorance 
as a simple variable is, uhm, a 'name' bound to an object... and these 
are its strange properties:
    ... enumerated...


marcus




More information about the Python-list mailing list