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

Arthur ajs@ix.netcom.com
Thu, 19 Sep 2002 18:43:02 -0400


Guido writes -

> You are convinced that a copy() method should be added yet are unable
> to provide a single example.
>
> I accept that it is hard for you to come up with an example.
>
> Until you have introspected enough to come up with an example I do not
> consider your testimony enough to change the language.  I think that
> is fair too.

But I have tried to articulate why the methodology on which you insist is
not responsive to the entire basis of what I am suggesting is the issue.

The best I can try to do is a double whammy of issues. I'll verbalize, and
try to follow up with code - though I think my point is made better in the
rhetoric better than I can make it in code.

The list.remove(x) trap on a list over which one is iterating.  I think it
is fair to say that this is generally recognized as a gotcha that gets most
of us somewhere along the line.  Now the answer usually is iterating over a
[:] copy and removing from the list itself.  But that [:] is effective as a
operator for a shallow copy seems more a happenstance/side-effect than a
feature. Would you agree that copy were more core if [:] didn't work as an
instead. But [:] is a slice operator, we are taught. Early on. And we begin
to understand how it works. [0] means 1 not 0. -1 last.  Good stuff to start
to get a handle on.

But there is no association with copying.  "Copy" should be associated with
copying. Or by having "copy" there is front of us in dir(__builtins__) we
are on notice it comes into to play in basic ways.  The answer to the
list.reomve(x) issue should be less of a blindside, or at least seem like
less of a happenstance.

But by the nature of a methodology you might establish it might be much
easier to prove to you that the newbie needs [1] to be the first list item,
not the second. I promise you I can produce an experiment that will prove
that this is true.   God forbid you should act on it.

So in some way the methdology you elect determines the answers you get.  And
you probably *can't* get my answer by your methodolgy. But that doesn't make
it Zen.

Art