[Edu-sig] what is a "variable" in Python?

kirby urner kirby.urner at gmail.com
Mon Feb 15 14:42:00 EST 2016


Perfect!

That's exactly the right rant!  Thank you Naomi.

Python names are post-its, not buckets.  You effectively counter the
"bucket brigade".  Hah hah.

Here's me chatting with Steve Holden a few minutes ago, across many time
zones (dinner time there, just getting to be lunch time here).

===

*Kirby*:  This posting of two minutes ago goes back to your laptop drawings
at Pycon, of namespace versus objectspace.  An ongoing theme in Python
Pedagogy...
https://mail.python.org/pipermail/edu-sig/2016-February/011372.html
<https://www.google.com/url?q=https%3A%2F%2Fmail.python.org%2Fpipermail%2Fedu-sig%2F2016-February%2F011372.html&sa=D&sntz=1&usg=AFQjCNGIza5x8WaXR0iMd7N8XJ1XzWjAtg>

*Steve*: And yet I have had arguments with people who complain when I say
that names in Python are simply object references

*Kirby*: They're references with hooks in that dot notation becomes a
conduit i.e. one applies A.method() to A to control whatever A names.  So a
name is a reference with controller capabilities?  It's not quite like a
luggage tag, so much as a TV remote.  You can press the tag in such a way
as to make the suitcase snap open.

*Steve*: I'd rather say dot notation is a way of changing the namespace in
which a name is expected to be found.  If that's "controlling" then we agree

*Kirby*: Given the name exists, e.g. A, using A.method() does not alter the
namespace though, i.e. A is still the only name we've got.  A may have
mutated nonetheless e.g. L.sort().

*Steve*: What I meant was that A.b means that b is looked up in A's
namespace

*Kirby*: Yes.  A TV remote is a namespace in that each button belongs to
the remote.  R.on, R.off, R.volume(+1) etc.  The TV is what R controls i.e.
is the object R names.

*Steve*: There is nothing a function/method can to to alter which object is
bound to a name used as a variable because bindings to arguments occur only
the function/method's namespace. It can, however, mutate the objects to
which it is passed references.

*Kirby*: In my posting to edu-sig I suggest that objects may be constant or
variable, corresponding to immutable versus mutable.  Names, however, in
being simply identifiers, are not themselves "variables".  The list itself
is a variable (a mutable object).  The name L is simply a name.  And it
should not be represented as a "container" of something.

*Steve*: Later. Dinner time now!

*Kirby*: OK, eat hardy!



On Mon, Feb 15, 2016 at 11:15 AM, Naomi Ceder <naomi.ceder at gmail.com> wrote:

> The short answer is that I agree with you.
>
> In fact, the link you shared is an example of my favourite incorrect
> mental model, which even prompted me to post this rant
> https://learnpython.wordpress.com/2015/05/21/notes-on-teaching-python-mental-models/
> some months ago.
>
> TL;DR - "in Python 'variables' are post-its, not buckets". (to use one of
> my own homely metaphors)
>
> Cheers,
> Naomi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20160215/a3ead876/attachment-0001.html>


More information about the Edu-sig mailing list