class implementation

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Sep 30 19:45:48 EDT 2013


On Mon, 30 Sep 2013 17:28:30 -0400, 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


I'm not convinced that "Python variables are different from C variables" 
is a better way to get through to people than "Python doesn't have 
variables, it has name bindings".

Of course, *technically* the first statement is accurate, and the second 
relies on a definition of variable that is not universal. The question is 
which is more effective at getting the differences between the two 
programming models through to the reader. I can't speak for others, but 
in my own experience, I never *quite* understood the semantic differences 
between Python name bindings and Pascal variables until I came across the 
meme "Python has no variables".



-- 
Steven



More information about the Python-list mailing list