The “does Python have variables?” debate

Neil D. Cerutti neilc at norwich.edu
Thu May 8 10:47:42 EDT 2014


On 5/8/2014 8:41 AM, Roy Smith wrote:
> In article <mailman.9742.1399477705.18130.python-list at python.org>,
>   Jerry Hill <malaclypse2 at gmail.com> wrote:
>
>> thinking of python variables as having two parts -- names and values
>> -- really can help people who are struggling to learn the language.
>
> There's many levels of learning, and we see them all on this list.
>
> For people who are just learning programming, and are learning Python as
> their first language, we need to keep things simple.  These are the
> people who are still struggling to understand basic concepts such as
> algorithms, loops, and the most fundamental data structures.  For those
> people, talking about variables as a container to hold a value is the
> right level of abstraction.
>
> At some point, that model no longer fits reality well enough that it
> becomes a barrier to further learning.  When I write:
>
> def mutate(x, y):
>      x = 42
>      y[0] = 42
>
> x = 4
> y = [4]
>
> mutate(x, y)
> print x, y
>
> and run it, unless I really understand about name binding and argument
> passing, I'm going to be totally befuddled by the result.  At that
> point, I need to unlearn something I thought I understood, and that's
> really hard (en.wikipedia.org/wiki/Principles_of_learning#Primacy).

The "surprising" things can be demonstrated without using functions. 
Once assignment statements are mastered, the way argument passing works 
can be extrapolated. New programmers will have to further be taught 
about shadowing and scopes, while experienced programmers should already 
be up and running (until they try to get cute).

Of course everybody has to eventually learn about the special syntax 
usable in function definitions and function calls.

-- 
Neil Cerutti




More information about the Python-list mailing list