[Python-Dev] re: Tutorial: Brief Introduction to the Standard Library

Phillip J. Eby pje at telecommunity.com
Thu Dec 4 18:27:28 EST 2003


At 02:27 PM 12/4/03 -0700, Kevin J. Butler wrote:

>The opposite question, "What is fundamentally wrong with list[:]..." has 
>an easy answer:
>
>It takes experience or explanation of slicing to know what it does.
>copy(list) is easy even for novices to understand.
>
>When I know my code will be read by people unfamiliar with Python, I tend 
>to annotate use of
>slices something like:
>
>    list[:] # copy the list
>
>Python usually makes it easier to avoid sacrificing clarity on the altar 
>of micro-optimization, but since the slice is the idiomatically correct 
>way to spell copy(list) in Python, that's the way to write it.

Well, dictionaries have a .copy() method; lists could also grow one.




More information about the Python-Dev mailing list