[Python-Dev] List copy and clear (was Re: Inconsistent API for sets.Set and build-in set)

Arthur ajsiegel at optonline.net
Tue Jul 5 16:17:09 CEST 2005


>* and because Guido believes beginners tend to copy too much
>  (that is one reason why copy.copy is not a builtin) and that
>  the language should encourage correct behavior.


OTOH, beginners tend to copy not enough - when for example iterating over a list being acting upon.

Though my real argument for list.copy() as an aid to beginners is otherwise - a bit more obtuse/non-linear than that - 
so much so that it doesn't get much sympahty.  

It isn't realistic to expect beginners to pick up idioms near the outset of the learning process.
Now, copying lists is not something the beginner will often want to do, and the argument that once
they want to do so, they will also be comfortable with slicing and with more idiomatic Python is 
not an unreasonable argument.

But I believe it misses something more fundamental. It is a belief that is extracted from my own
experience in tackling Python as a first language - as an adult, being able - I think - to introspect
a bit better as to the process than I could if I were doing so at a younger age, and more in the
normal course.

The downside of Guido hiding "copy" to the extent it is - by not having a list.copy(), by not having
copy.copy as a built-in, by even rejecting the notion of a short blurb of the copy module in the
tutorial - is that the confrontation with the distinction between copying and "=" assignment gets delayed
and confusion on the point becomes frustrating - fundamentally so.

It doens't seem to me that this is an outlandish notion by any means. It can't be - as I seemed
to have experienced it.

Guido called this "one of my favorite subjects" in my last go around here on this issue.

Well, it is indeed an opinion I hold. Not of earthshaking importance.  But I hold it
firmly enough, nonetheless.  My flexiblity is more on the issue as to the extent that Python should
design itself around the needs of beginners. If the conclusion is that list.copy() is a distraction
to the experienced programmer, and that the motivated beginner will get to where they need to get,
in any case, with or without it - I'm on board.  

If the thought is that hiding "copy", or relying on idioms for a construct as fundamental as the list -
is a favor to the beginner, I very much am not.

Art



More information about the Python-Dev mailing list