Python variables? [was Re: class implementation]

Ethan Furman ethan at stoneleaf.us
Mon Sep 30 18:02:22 EDT 2013


On 09/30/2013 02:28 PM, Ned Batchelder wrote:
> On 9/30/13 3:34 PM, Dave Angel wrote:
>> Python doesn't actually have variables, but the things it documents as
>> variables are local names within a method.  Those are not visible
>> outside of the method, regardless of whether you're in a class or a
>> subclass.
>
> Why does this meme persist!?  Of course Python has variables, they just don't work like C variables do.  If you'd like
> to know the details: http://nedbatchelder.com/text/names.html

Because Python's model is different enough that it usually makes thinking about it simpler to stay away from the word 
'variable'; in every other language I have used a variable is a box, but in Python it's a label for a box.

 From your blog:
>
> Names are Python's variables: they refer to values, and
>  those values can change (vary) over the course of your
>  program.

This is partially incorrect.  If the value referred to by the name is immutable, then it cannot change; perhaps you 
meant to say that which object the name points to can vary over time?

--
~Ethan~



More information about the Python-list mailing list