Copy operator (was list.remove for Noivces)

Arthur Siegel ajs at
Wed Nov 28 03:04:57 CET 2001

Jeff Shannon wrote:

>>Arthur Siegel wrote:

>> How about this one.  A copy operator -  <=> or something.  So now
> >all the world is on notice from day one = is different that <=>.
>> Which do you mean?

>Well, Python already *does* have several ways to indicate copying, though
specifically in a single simple operator like that.

>list2 = list1[:]   #create a copy
>import copy
>list2 = copy.copy(list1)  #copies a list
>list2 = copy.deepcopy(list1)  #even better

Except not having grokked the difference between copy and
deepcopy, I am aware -as to the list2=list[:], just recently aware.

>Yes, beginners are likely to get bitten by a few things.  This will happen
>regardless of what language they use.  Trust me, it's a lot easier to track
>an assignment/copy error, or the list.reverse() gotcha, than to track down
>bugs caused by referencing free()'d memory in C...

Don't doubt it for a moment.

>I don't think that changing the language to avoid these will help matters

What if we could help matters marginally, at no real cost?

Turns out I am not the first to suggest a copy operator on the list.
It was suggested in the course of discussions by some folks focused
on numerics.

But though I would defend the position with some vehemence that a
copy operator would be a significant improvement for Python as a
beginners/learners language  - it is clearly not a discussion worth
having if there are overriding design reasons it does not make sense.

The issue of copy vs. deepcopy is one issue that came up in previous
discussions.  How significant is that? Are there other significant issues

Certainly no backwards compatibility issues arise, and those who
find it superfluous can ignore its existence.

I don't doubt that there is significantly more to the issue than my view
allows me.

But if  I could find some way to demonstrate (not  saying that I
necessarily could find a way to do so convincingly) that it would
indeed make Python better equipped for beginners/learners -
is there a shot it would find acceptance by the community?


More information about the Python-list mailing list