The “does Python have variables?” debate

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri May 9 21:11:59 EDT 2014


On Fri, 09 May 2014 17:34:17 -0500, Mark H Harris wrote:

> On 5/7/14 8:27 PM, Steven D'Aprano wrote:
>>> In almost every other language you know A and B each "contain" by
>>> reference (and almost always by static type) macTruck. But NOT python.
>>
>> Nor Javascript, Ruby, Perl, PHP, Lua, or (I think) Lisp or Java. To
>> mention only a few.
>>
>> I think it is easy to exaggerate the difference between Python and
>> "almost every other language". Python's name binding model is very
>> common amongst dynamically typed languages, and there are many
>> dynamically typed languages.
> 
>      Then we don't need a discussion.
> 
>      Why are new Python coders 'always' confused by this question of
> variable (name value) vs. {name: object} model of Python?

"Always"? I don't think anyone, not even Ben, claims that new Python 
coders are "always" confused about Python's variable semantics. That 
would be a straw man, easy to disprove by just finding a single person 
who wasn't confused. Perhaps someone who had never learned C and didn't 
know C variable semantics?


>      The reason I suggest is that the person has a preconceived idea of
> what 'variable' means, and they then attempt to apply their conception
> of variable on to Python in some way ending in a surprise.

That's the problem as some of us see it.


>      We need a way to speak about Pythons name object model to avoid
> this confusion.

And that would be the "name binding" part.




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/



More information about the Python-list mailing list