Elegant copy-by-value
Erik Max Francis
max at alcyone.com
Sun Jan 12 18:40:47 EST 2003
Martin Christensen wrote:
> I wasn't thinking of simplicity implementation-wise. It just seems
> very awkward to me that it should be necessary to import a module just
> to be able to copy the value of even a primitive. For more complicated
> structures it's more understandable, but copying those by value is
> apparently easier. Go figure!
You don't. You can create a (shallow) copy of a list with L[:], and one
of a dict with D.copy(). Numerics, strings, and tuples don't need copy
routines since they're immutable.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ A good indignation brings out all one's powers.
\__/ Ralph Waldo Emerson
Lsystem / http://www.alcyone.com/pyos/lsystem/
A Lindenmayer systems explorer in Python.
More information about the Python-list
mailing list