Elegant copy-by-value

Andrew Bennetts andrew-pythonlist at puzzling.org
Sun Jan 12 20:10:54 EST 2003


On Sun, Jan 12, 2003 at 05:29:44PM -0700, Andrew Dalke wrote:
> Mike Meyer wrote:
> >If it still bothers you, how about a PEP proposing that object have
> >copy and deepcopy methods that DTRT? That way, all new-style classes
> >would have a copy and deepcopy methods, so you could invoke them
> >without having to import a module.
> 
> Actually, I think Python could get what he wants if copy.copy and
> copy.deepcopy were added to the builtins as 'copy' and 'deepcopy'.
> It seems he mostly didn't like the need for an extra import, based
> on the OP's statement

In which case, perhaps all they want is the following code:
     
     from copy import copy, deepcopy
     __builtins__.copy = copy
     __builtins__.deepcopy = deepcopy

<wink>

-Andrew.






More information about the Python-list mailing list