List semantics [was Re: Slices time complexity]

Terry Reedy tjreedy at udel.edu
Wed May 20 14:42:08 EDT 2015


On 5/20/2015 4:54 AM, Gregory Ewing wrote:

> At this point the student thinks, "Um... what? How
> can an object contain another object *twice*?"
> If he's still thinking in physical terms, this
> sentence is nonsensical.
>
> It gets even worse with:
>
> x = [1, 2]
> x[1] = x
>
> Now you have to say that the list contains *itself*
> in some weird Tardis-like fashion!
>
> I can't think of any way to dispel the confusion
> verbally without using some word like "reference"
> or "pointer" or something with an equivalent meaning.
> Something that suggests a level of indirectness.

Python sets and lists (and frozen versions) are like clubs.  A club 
roster contains identifiers that refer to and identify the members. 
Kids who can read and write names usually have no problem with this. The 
roster for the Recursive Club (of recursive clubs) would contain the 
identifier 'Recursive Club'.

-- 
Terry Jan Reedy




More information about the Python-list mailing list