What makes an object uncopyable?

T

tron.thomas

I am trying to make a copy of a certain Python object using the
copy.copy() function. When I try to perform this operation I get an
error like the following:

copy.Error: un(shallow)copyable object of type ...

What factors determine whether an object can be copied?
 
K

Konstantin Veretennicov

I am trying to make a copy of a certain Python object using the
copy.copy() function. When I try to perform this operation I get an
error like the following:

copy.Error: un(shallow)copyable object of type ...

What factors determine whether an object can be copied?

You are probably trying to copy an instance of a class implemented in
C extension. AFAIK, Python classes have copy support by default, but
extension classes need to implement copy/pickle protocol.

- kv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,252
Messages
2,571,267
Members
47,908
Latest member
MagdalenaR

Latest Threads

Top