[Edu-sig] Fw: Python sequences by reference - how to make clear

Arthur ajs@ix.netcom.com
Thu, 19 Sep 2002 14:57:34 -0400


Michal writes -


>    >Yes, this is fully in accordance with how the Python language should
> behave:
>    >    Res += [rec] inserts references to list object rec,
>    >    which are further modified... (he should use copy(rec) instead).
>

Yes, this issue in various guises bit me for some time after I began using
Python (self.-taught, as a fist programming language).

 It had always seemed to me that if there were a copy operator, or
(perferably, to me) that the functionality of the copy module were in the
language core as a built_in, that I would have been on clearer notice that
there was something fundamental in this area to which I needed to pay
attention and become attuned.

 In looking into it I did find some discussion of the issue on python-list.
Interestingly it was also math/Numeric folk who seemed to be rasing the
question then and advocating something along the lines of a built_in
operator for copying.  I however think that the issue is quite real for
anyone coming to Python without the benefit of either a programming
background or a formal structure within which they are being taught the
language.

I have felt strongly that others have been too quick to advocate changes to
the language to address "special needs" cases. And that the special needs
cases of the novice have been *much* over-emphasized in discussions, in
general. The "specialist" (as in most special) need of the the novice is to
get themselves in a mindset of knowing that they are using a complicated
tool, that they should expect the unexpected, and that there is a burden on
them to get in step to the tool, the tool - in the case of Python (people
who are not novices will assure them) , having done more than its share in
meeting them at least half way.

And I have confirmed to myself in the work I have been doing recently, which
is specifcally addressed to the non-programmer, that at least some of those
"special needs" can be quite adequately addressed by the right interface
design, using Python's out of the box capabilities.

That being said, and admitting to having little understanding of the full
implications of a suggestion to make the copy function as built_in, I do
believe, all things else being equal (which I suspect they are not), it
would be quite helpful little amendment to the status quo. I use the word
"little"  - perhaps inappropriately, is the problem.

Art


OOPs. Sent this to python-list by mistake. Not sure what will be made of my
starting a conversation in the middle. One advantage of having established a
bad reputation, is that I have little reputation to protect.

Have added a few thoughts, above, so the posts don't even match. Sloppy, as
often I am. Oh well.