The “does Python have variables?” debate

Larry Hudson orgnut at yahoo.com
Sat May 10 03:46:45 EDT 2014


On 05/09/2014 06:11 PM, Steven D'Aprano wrote:
> On Fri, 09 May 2014 17:34:17 -0500, Mark H Harris wrote:
>
>> On 5/7/14 8:27 PM, Steven D'Aprano wrote:
<snip>
>>       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?
>

Well, here is that one person.   ;-)

I'm an entirely self-taught amateur/hobbyist programmer, coming to Python from a C background. 
Very early in my reading of books/tutorials on Python I learned that Python variables are 
different, and how they are different from C variables.  Essentially I said, "Okay, they're 
different.  What's next?"  There was no confusion at all.  All I had to do was accept that they 
_are_ different.  (BTW, I'm now quite hooked on Python -- and still learning it.)

>>       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.
>

As I said above, not a problem.  I already accepted the fact that all programming languages are 
different -- often with similarities, but more often quite different, especially in the details. 
  So when programming in C I think in C-style variables, in Python I think in Python-style 
variables.  And uv course, I nefer make mmistakes...  Yeah, right!    ;-)

>
>>       We need a way to speak about Pythons name object model to avoid
>> this confusion.
>
> And that would be the "name binding" part.
>

This is something I absolutely disagree with.  I still think it's only necessary to teach that 
variables in different languages are handled differently.  Insisting on a different name is NOT 
helpful.  And insisting that Python does not have variables is ludicrous!

      -=- Larry -=-




More information about the Python-list mailing list