Elegant copy-by-value

Peter Hansen peter at engcorp.com
Sun Jan 12 02:51:11 CET 2003

Martin Christensen wrote:
> Python usually uses copy-by-reference. This is all good and well, but
> sometimes we want copy-by-value. For a long time now I've been using
> copy() or deepcopy(), depending on the circumstances, from the copy
> module. Is there no more simple and elegant way of doing this? It
> seems strange that one should have to import a module to so something
> as simple as a copy-by-value. 

No one could call copy-by-value in Python "simple" who has looked at 
the source for it.

Have you looked at copy.py?  If you haven't, take a peek now and then
come back and try the question again. ;-)


More information about the Python-list mailing list