gallium.arsenide at gmail.com
Tue Jul 7 20:55:13 EDT 2009
On Jul 7, 5:11 pm, kj <no.em... at please.post> wrote:
> I don't plan to present these examples to them.
> But beginners have a way of bumping into such
> conundrums all on their own [...]. I doubt that
> an answer of the form "don't worry your pretty
> little head over this now; wait until your second
> course" will do the trick.
I agree that beginners are bound to come across difficult issues on
their own, and when they do, you have to at least try to explain,
rather than dismiss them. I believe that the beginners which are most
curious, and thus most likely to run into things you didn't plan for
them, are also most likely to be ready and able to receive your
That said, I think it's worth planning a fairly controlled flow of
information. For example, you can go a LONG way without touching
tuples or the augmented assignment operators.
For your function example, I suppose the key ideas to understand are
binding and containers (which may or may not be mutable). The
oversimplified version I think I would attempt to explain is that, as
far as the "outside world" is concerned, a function cannot rebind the
arguments passed to it. However, the contents of a mutable container
may be altered without rebinding. That is, you can hold a bucket,
pass that bucket to a function, and the function can put stuff in the
bucket or take stuff out without you ever letting go of the bucket.
When the function returns, you are still holding the bucket.
Nested containers, especially with "outside" bindings to inner
containers, may be tougher to visualize with real-world objects.
Hopefully by then the students can grasp a more abstract (pointerlike)
notion of binding! Good luck!
More information about the Python-list