Pass variable by reference

Mark H Harris harrismh777 at gmail.com
Tue May 6 17:00:19 EDT 2014


On 5/6/14 3:31 PM, Ned Batchelder wrote:
> On 5/6/14 12:42 AM, Gary Herron wrote:
>> This gets confusing, but in fact the most accurate answer is that Python
>> does not have "variables", so there is no such thing as passing
>> "variables" by reference or any other method.  Python *does* have names
>> bound to values, but that's a very different thing. If necessary, you
>> may consider that the *values* are passed by reference.
>
> This meme bugs me so much.  Python has variables.  They work differently
> than variables in C.  In fact, they work by having names bound to values.

What does the word "variable" mean. Think BASIC variables. You can set 
them, you can reset them, you can delete them, you can change them.  ... 
because they are variable.

Python has names bound to objects... some of which you may not change. 
Once the name is bound to an object you may bind it to another object, 
but you may not change it, nor may you change the object it is bound to 
if the object is immutable.

marcus




More information about the Python-list mailing list