On Feb 14, 1:21 pm, a...@pythoncraft.com (Aahz) wrote: > Nope -- any reason you can't change the filename? > --
Os X 10.5 did not recognized the dbm extension. But, I have been able to fix the problem (hope it helps somebody): At http://docs.python.org/library/shelve.html it says: "shelve.open(filename[, flag='c'[, protocol=None[, writeback=False]]])ΒΆ Open a persistent dictionary. The filename specified is the base filename for the underlying database. As a side-effect, an extension may be added to the filename and more than one file may be created. By default, the underlying database file is opened for reading and writing. " Then, I went ahead and try to find out which type of db file was being created: print whichdb.whichdb(dbmFile)#prints bsddb185 kpfmac:xLPR kpf$ python Python 2.5.1 (r251:54863, Feb 9 2009, 18:49:36) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import bsddb185 >>> bsddb185.open('realizations.db') <bsddb.bsddb object at 0x12260> I found that the dbm extension is generated by bsddb and bsddb3 so I went ahead and installed it: sudo easy_install bsddb3. Finally, in our code, I just went ahead and instead of using shelve.open, I am calling shelve.BsdDbShelf(bsddb3.btopen(filename, 'c')) #realizations=shelve.open( filename, 'c', 2, writeback = False ) #hk 021010: need to use BsdDbShelf to ensure the usage of bsddb3 on OsX 10.5 #shelve.open creates a bsddb185 file on OsX 10.5 #but shelve.open on OsX reads with bsddb3, who knows why... #as a result the shelve.open throws #<class 'bsddb.error'> (22, 'Invalid argument') dbshelf=shelve.BsdDbShelf(bsddb3.btopen(filename, 'c')) realizations=dbshelf And that fixed on Os X 10.5. It also works fine on Windows, by ensuring the proper import: try: import bsddb3 except: import bsddb as bsddb3 -- http://mail.python.org/mailman/listinfo/python-list