Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problem with shelve

Reply
Thread Tools

Problem with shelve

 
 
bluesmanu@gmail.com
Guest
Posts: n/a
 
      11-06-2008
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
 
Reply With Quote
 
 
 
 
Paul Rudin
Guest
Posts: n/a
 
      11-06-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) 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'

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with shelve/gdbm Douglas Applegate Python 0 10-19-2007 08:58 PM
hi,everyone. a problem with shelve Module softwindow Python 4 05-26-2006 12:00 PM
shelve problem Michael Mulcahy Python 0 03-02-2004 04:58 PM
shelve keeping old (unused) data around? AK Python 2 09-29-2003 09:43 PM
Serious problem with Shelve Rami A. Kishek Python 6 08-19-2003 10:41 PM



Advertisments