David Wahler wrote:
> Kent Johnson wrote:
> > Is there a way to persist a class definition (not a class instance,
> > the actual class) so it can be restored later? A naive approach
> > using pickle doesn't work:
> [snip]
> > The idea is to persist classes that are created and modified at runtime
Kent Johnson wrote:
> Is there a way to persist a class definition (not a class instance,
> the actual class) so it can be restored later? A naive approach
> using pickle doesn't work:
[snip]
> The idea is to persist classes that are created and modified at runtime.
I couldn't resist the challenge
Kent Johnson <[EMAIL PROTECTED]> wrote:
> Is there a way to persist a class definition (not a class instance, the
> actual class) so it can be restored later? A naive approach using pickle
> doesn't work:
You can use copy_reg to customize pickling behavior. In this case,
you'd need a custom meta
Kent Johnson enlightened us with:
> OK that confirms that pickle won't work. Is there another approach
> that will?
Well, since the classes are created at runtime as well, you could
compile them using the appropriate API and call exec() on them.
Sybren
--
The problem with the world is stupidity.
Sybren Stuvel wrote:
> Kent Johnson enlightened us with:
>
>>Is there a way to persist a class definition (not a class instance,
>>the actual class) so it can be restored later?
>
>
> From the docs:
>
> "Similarly, classes are pickled by named reference, so the same
> restrictions in the unpick
Kent Johnson enlightened us with:
> Is there a way to persist a class definition (not a class instance,
> the actual class) so it can be restored later?
>From the docs:
"Similarly, classes are pickled by named reference, so the same
restrictions in the unpickling environment apply. Note that none
Is there a way to persist a class definition (not a class instance, the actual
class) so it can be restored later? A naive approach using pickle doesn't work:
>>> import pickle
>>> class Foo(object):
... def show(self):
... print "I'm a Foo"
...
>>> p = pickle.dumps(Foo)
>>> p
'c__ma