tough-to-explain Python
kj
no.email at please.post
Tue Jul 7 17:11:29 EDT 2009
In <m2my7gb4g6.fsf at cs.uu.nl> Piet van Oostrum <piet at cs.uu.nl> writes:
>>>>>> kj <no.email at please.post> (k) wrote:
>>k> I'm having a hard time coming up with a reasonable way to explain
>>k> certain things to programming novices.
>>k> Consider the following interaction sequence:
>>>>>> def eggs(some_int, some_list, some_tuple):
>>k> ... some_int += 2
>>k> ... some_list += [2]
>>k> ... some_tuple += (2,)
>>k> ...
>>>>>> x = 42
>>>>>> y = (42,)
>>>>>> z = [42]
>>>>>> eggs(x, y, z)
>>>>>> x
>>k> 42
>>>>>> y
>>k> (42,)
>>>>>> z
>>k> [42, 2]
>>>>>>
>>k> How do I explain to rank beginners (no programming experience at
>>k> all) why x and y remain unchanged above, but not z?
>You shouldn't. That's not for beginners.
No, of course not. And I don't plan to present these examples to
them. But beginners have a way of bumping into such conundrums
all on their own, and, as a former beginner myself, I can tell you
that they find them, at best, extremely frustrating, and at worst,
extremely discouraging. 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.
Thanks for your comments!
kj
More information about the Python-list
mailing list