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

Andrew Harrington aharrin at luc.edu
Mon Feb 15 23:48:32 EST 2016


I agree with Gary that mutability is a property of objects, not of
variables. An object has methods.  A name does not - it can refer to an
object with a particular method.  I do not get the variable and remote
buttons analogy at all. The importance of a variable naming a memory
*location* with a reference is that clearly there can be only one reference
at that memory location at a time.  There is nothing saying with the
English word "label" that two different objects/places could not have the
same naming label slapped on them, so relying too heavily on easy English
analogies is tricky.

In my Hands-on Python Tutorial <http://anh.cs.luc.edu/python/hands-on/3.1>
I say all data has a type, and I start with immutable objects types.  I say
initially that a variable is a name used to refer to a piece of data.  Much
later I get to mutable objects, and then the idea of a reference to an
object is key to understanding.  I point out that with immutable objects
this does not make much difference, but when we start dealing with mutable
objects, it is important to be more precise.  This sequence seems to work
fine.

Andy

Dr. Andrew N. Harrington
  Computer Science Department
  Graduate Program Director gpd at cs.luc.edu
  Loyola University Chicago
  529 Lewis Towers, 111 E. Pearson St. (Downtown)
  417 Cudahy Science Hall (Rogers Park campus)
http://www.cs.luc.edu/~anh
Phone: 312-915-7982
Fax:    312-915-7998
aharrin at luc.edu (as professor, not gpd role)

On Mon, Feb 15, 2016 at 8:58 PM, kirby urner <kirby.urner at gmail.com> wrote:

>
>
> On Mon, Feb 15, 2016 at 5:23 PM, Carl Karsten <carl at nextdayvideo.com>
> wrote:
>
>> I think the point of this thread is: how important is this subject?
>>
>>
> I don't know that there's a scale of 1-10 answer.  If / when it comes up,
> as a student question, it becomes important, but also instructors need to
> explain how a given object may have many names, whereas of we're focused on
> "containers" how does that look?
>
>
>
>> I have one of many answers: in my 2 hour 500 line intro to python, it
>> gets about 60 seconds spent on this 1 line:
>>
>> """Other languages have variables; technically, Python doesn't. But it
>> has something that looks like a var: It has names. So don't call it a var.
>> For a good explanation of this see
>> http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables
>> """
>>
>
> This is excellent.
>
> I was racking my brains where to find visuals like this, specifically
> showing the buckets versus post-its models.
>
> I've added links to my make_links_v2.py and make_links_v3.py @ <guild />
> [1]
>
> This thread was useful for our trains at PDX Code Guild at least, as I'm
> having philosophical differences with some of my peers regarding the
> uber-basics and how best to teach them.
>
> I've been told repeatedly that code school students will start out *not*
> knowing what a variable is and my number one most important responsibility,
> right from the get go, is to introduce the concept.
>
> Fine.  But what if the curriculum hard-codes that we should see variables
> as "containers".
>
> Before I lead a boot camp, Python-centric, I want to make sure I'm not
> shackled to a misinforming presentation I'm not comfortable teaching.  It'd
> just feel wrong, like I'm lying, to force the "container metaphor".  I
> needed ammo.
>
> By now, thanks to these threads today, I feel well armed in my views that
> I'm free to avoid said metaphor if I want to.
>
> Here's a screen shot of our faculty Slack feed from a few minutes ago:
>
> https://flic.kr/p/DduBoA
>
> There's enough consensus out there to defend my position.  Yay.
>
> What I want to avoid is another instructor insisting on the "variable as
> container" metaphor to a point where I feel I have to do extra work to undo
> that picture.
>
> Thanks again for the tools, should that come up.
>
> Kirby
>
> [1]
> https://www.dropbox.com/home/PDX%20Code%20Guild/Accelerated%20Programming%20%28fork%29
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20160215/0cb873ff/attachment.html>


More information about the Edu-sig mailing list