Elegant copy-by-value

Peter Hansen peter at engcorp.com
Sat Jan 11 20:51:11 EST 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. ;-)

-Peter




More information about the Python-list mailing list