Simple Conceptual Pickling problems

Emile van Sebille emile at fenx.com
Tue Jul 2 07:01:45 EDT 2002


"chris lyon" <chris.lyon at spritenote.co.uk> wrote in message
news:3d217732$0$4276$afc38c87 at news.easynet.co.uk...
> I am trying to pickle instances of a class stored in a dictionary with
a MD5
> hash used as the key of the dictionary.
>
> I can pickle them ok and when I examine the pickle file (I'm using the
> default ASCII mode) I can see the instance data in the pickle file.
>
> However when I try to load the pickle file After I have imported the
module
> from which it was all derived I get:-
>
> SystemError: Failed to import class Programme from module __main__

This is the hint.  The module's name when the pickle was created was
__main__, which only happens when the module is not imported, but is run
directly.  You need to pickle and unpickle from within the same context,
eg, use import in both cases.

HTH,

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list