copying classes?

Jeff Epler jepler at unpythonic.net
Wed Dec 29 14:25:01 EST 2004


You copied an instance, not a class.

Here's an example of attempting to deepcopy a class:
>>> class X: pass
... 
>>> import copy
>>> X is copy.deepcopy(X)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.2/copy.py", line 179, in deepcopy
    raise error, \
copy.Error: un-deep-copyable object of type <type 'class'>

In theory, one could provide a metaclass that allows copying of
instances of that metaclass.  I'll leave this as an exercise to the
reader.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041229/1d89f9f7/attachment.sig>


More information about the Python-list mailing list