way to pickling locals()

Pascal Gauthier glibc at videotron.ca
Sun Sep 1 03:29:06 EDT 2002


Hi,
    I am currently writing an application that uses the 
InteractiveInterpreter (PyCrust to be exact). I want to be able to save 
the state by pickling locals() of the interpreter. The problem is that 
pickle doesn't support module pickling.

To make a long story short, I want to :

    l = locals()
    InteractiveInterpreter(locals=l)
    pickle.dump(l, file)
    ...
    InteractiveInterpreter(locals=pickle.load(file))

The only solution I found is to remove __builtins__ and marshal modules 
from the locals() dictionnary. But this is not really clean...

Any other suggestion ???
Thanks.




More information about the Python-list mailing list