shelve and ".bak .dat .dir" files

Michele Petrazzo michele.petrazzo at TOGLIunipex.it
Thu Apr 6 12:34:44 EDT 2006


Sion Arrowsmith wrote:
> 
> This is a documented behaviour of shelve:

Sorry, I had read only the:
"""Open a persistent dictionary. The filename specified is the base
filename""" ... :)

> I guess this depends on what dbm shelve is built on the documentation
> implies it goes through anydbm. I'm not seeing this behaviour on my
> Debian 3.1

In my tries, I see that if I use a "simple" script that open, use and
save the shelve data, it work without problems, but if I use shelve into
my application, I has this behaviour.

(and I fail to understand why
> it is a problem).
> 

Because:
1) I pass a name that, after, I'll pass to another program and if shelve
change the name, the latter can't read it (it doesn't exists!)
2) I can't read those files with shelve! If I try... :

>>> shelve.open("test.dat")
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/lib/python2.3/shelve.py", line 231, in open
     return DbfilenameShelf(filename, flag, protocol, writeback, binary)
   File "/usr/lib/python2.3/shelve.py", line 212, in __init__
     Shelf.__init__(self, anydbm.open(filename, flag), protocol,
writeback, binary)
   File "/usr/lib/python2.3/anydbm.py", line 80, in open
     raise error, "db type could not be determined"
anydbm.error: db type could not be determined


And this with all the three types.

Thanks,
Michele



More information about the Python-list mailing list