Problem with shelve
paul.nospam at rudin.co.uk
Thu Nov 6 19:07:16 CET 2008
bluesmanu at gmail.com writes:
> Hi all,
> I am trying to use the shelve module to save an object of a 'Electron'
> class I made into a file. The writing goes well but the reading goes :
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "shelve.py", line 113, in __getitem__
> value = Unpickler(f).load()
> AttributeError: 'module' object has no attribute 'Electron'
> any idea of what I am doing wrong?
I'm not sure, but shelve uses pickle, and to unpickle you need to have
the module and class definition available for import at unpickling
time. The error message suggests that the module is there, but it no
longer contains a definition for the Electron class.
I could be wrong tho' :)
More information about the Python-list