Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error of datebase
#1
import shelve
class Waiting:
   def __init__(self):
       self.name = 'Waiting'
       self.List = []
bd = shelve.open('Data')
bd['Waiting'] = Waiting()
bd.close()
bd = shelve.open('Data')
print(bd['Waiting'].name)
Error:
Traceback (most recent call last):  File "<input>", line 1, in <module>  File "C:\Python34\lib\shelve.py", line 114, in __getitem__    value = Unpickler(f).load() EOFError: Ran out of input
Reply
#2
not sure, but shouldn't you open with writeback=True? The default is False.
Also it's better to use with context manager
Reply
#3
Actually your code works for me in python2 and in python3 if I add .db extension to file name
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020