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

Arthur Siegel ajsiegel at optonline.net
Mon Oct 2 23:12:52 CEST 2006


On Mon, 2006-10-02 at 10:00 -0700, kirby urner wrote:

> >>> handle1 = ['coffee','sugar','cream']
> >>> handle2 = handle1
> 
> >>> id(handle1)
> 13645944
> 
> >>> id(handle2)
> 13645944

I always thought that when presenting this it is natural and important -
in order for the student to truly get it - to do an "as opposed to"
thingy.

>handle3=list(handle1)
>handle1[0]='tea'
>handle1
>['tea','sugar','cream']
>handle3
>['coffee','sugar','cream']

To me this is so essential that I have argued that the fact that neither
the list type having a copy method or the copy function being a built-in
is a wart. But I think if it is a wart it impacts discovering 
Python, i.e. self-teaching, rather than teaching Python and learning
Python more formally.

Anyway, I would advocate the "as opposed to" be integrated into such a
presentation.

Art



More information about the Edu-sig mailing list