Pickling a class instead of an instance

  • Thread starter Sebastien Boisgerault
  • Start date
S

Sebastien Boisgerault

Hi,

It seems to me that it's not possible with the pickle module
to serialize a class rather than an instance, as in

I mean, it does *something*, there is no error indeed, but
from the string pickstr, I am unable to rebuild the class
C in a brand new context (got a "you're really stupid, all
you deserve is an AttributeError because you know there is
no attribute 'C' in the 'module' object" error).

Am I wrong ? Why would the "(new-style) classes are regular
objects too" mantra not apply in this case ? Could we imagine
a patch to the pickle module to handle this kind of situation ?

SB
 
H

harold fellermann

have a look at the thread "copying classes?" some days ago.
what goes for copying goes for pickling also, because the
modules use the same interface.

- harold -
 

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,215
Messages
2,571,113
Members
47,716
Latest member
MiloManley

Latest Threads

Top