Teaching python (programming) to children

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Wed Nov 7 14:48:59 EST 2001


On 7 Nov 2001 00:30:13 -0800, Hung Jung Lu <hungjunglu at yahoo.com> wrote:
>
>> It is has nothing to do with namespace.  
>
>Now you are confused. You think you can do Python without namespaces.

I did not know I thought that.  Thank you for telling me what I thought. :-)

>
>  statement        modification on the globals() namespace dictionary
>----------------+------------------------------------------------------
>>>> a = []      | (1) yes, entry with key 'a' inserted
>>>> x = a       | (2) yes, entry with key 'x' inserted
>>>> x.append(1) | (3) no, no action on globals() namespace dictionary
>>>> print a     |
>[1]             |
>>>> x = []      | (4) yes, value of the entry with key 'x' updated
>>>> print a     |
>[1]             |
>
>The difference in (3) and (4) is simply whether action has been
>performed on the namespace dictionary, regarding the entry with key
>'x'.

Oh, now I see what you mean.  You are saying anything that concerns names is
a namespace problem.  Of course that would be everywhere.  But that's
exactly why you find it difficult to explain to newbies.

Have you considered the alternative approach?  That is to separate the two
issues: 

1. name binding vs mutation,
2. name binding in different namespaces.

To explain the example, you only need to touch upon the first issue.  And it
is considerably easier, as your one sentence summary quoted above shows.

I would only call the second issue as namespace problem.  However, as long
as the first one is well understood, the second is not hard either - It's
just the scoping rules.

[snip long-winded discussion about namespace mechanisms]

>However, that's not a task for beginners. Me having to spend 4
>postings on this thread should tell you something: many people don't
>see the whole Python.

Or maybe many people don't see the point of weighing in the knowledge of the
whole Python in order to explain this simple example?

>>feeling-exhausted-explaining-this-many-times-ly yr's
>
>Believe me, I am more exhausted than you are. :)
>

Maybe that's because you are trying to explain too much in one go?

divide-and-conquer-works-ly yr's

Huaiyu



More information about the Python-list mailing list