By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

Problem with shelve

P: n/a
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 :
>>e=f['0']
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?

Thanks!
ET
Nov 6 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
bl*******@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 :
>>>e=f['0']
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' :)

Nov 6 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.