[Edu-sig] Edu-sig Digest, Vol 39, Issue 2

kirby urner kirby.urner at gmail.com
Mon Oct 2 19:00:16 CEST 2006

> The coffee-cup-handle metaphor is certainly useful, but IMHO not quite as
> spot-on as the sticky-note metaphor.
> -John Posner

Excellent review John thanks.

Below is the kind of thing a teacher could project.

IDLE 1.2b2

>>> handle1 = ['coffee','sugar','cream']
>>> handle2 = handle1

>>> id(handle1)

>>> id(handle2)

>>> handle1.sort()  # alphabetize in place

>>> handle2
['coffee', 'cream', 'sugar']

>>> handle3 = handle1
>>> handle3 is handle2

So by this time with have a list in Memory with three handles
(handle1, handle2, handle3).

The idea of a cartoon mug with more than one handle seems "sticky" in
the sense that students are unlikely to forget it easily.

BTW, I just searched and found a real two-handled mug for sale in Ireland:

One reason I like this "handle" nomenclature is kids use "handles" for
themselves, i.e. for chat rooms, other places where some notion of
primitive identity is required (Second Life is especially popular
these days).  So there's already this builtin sense of "me" (myself)
with multiple handles, multiple ways for others to get in touch with
the same identity.

I like the idea of making Memory a spatial affair i.e. instead of just
using flat rectangles or circles to represent contents, we could use
3D-looking balloons or balls.

Balloons with multiple strings is a good analogy (or just the one
string).  When no strings attach, the balloon simply floats off, out
of sight out of mind (out of Memory).

Cartoon animations of Garbage Collection:  what should those look like?

We need to connect here: a discussion of immutability.

A list can be shaken and stirred without losing its identity.

However, strings are considered immutables in Python, meaning if you
fix a typo, you get back a new string, not a change in the original
Memory container.

Tuples are similar, in that you can't change the handles inside a
tuple -- but you *can* change the Memory contents of what the handles
point to, e.g.:

>>> mytuple = (handle1, handle2, handle3)
>>> mytuple[1]
['coffee', 'cream', 'sugar']
>>> handle3[2] = 'vanilla flavoring'
>>> mytuple[1]
['coffee', 'cream', 'vanilla flavoring']

What's a good metaphor for explaining about intern?

>>> help(intern)
Help on built-in function intern in module __builtin__:

    intern(string) -> string

    ``Intern'' the given string.  This enters the string in the (global)
    table of interned strings whose purpose is to speed up dictionary lookups.
    Return the string itself or the previously interned string object with the
    same value.



More information about the Edu-sig mailing list