opening anydbm files
Scott Barron
kain at twilight.
Sat Oct 30 00:50:37 EDT 1999
Hi folks,
According to the docs and Fredrik's book this should work but I get the
following:
Python 1.5.2 (#8, Oct 13 1999, 22:39:47) [GCC 2.7.2.3] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import anydbm
>>> db = anydbm.open ("foo", "c")
>>> db["1"] = "foo"
>>> db["2"] = "bar"
>>> db["3"] = "baz"
>>> db.close ()
>>> db = anydbm.open ("foo", "r")
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python1.5/anydbm.py", line 80, in open
raise error, "need 'c' or 'n' flag to open new db"
anydbm.error: need 'c' or 'n' flag to open new db
>>> db = anydbm.open ("foo", "w")
[--Snip same error as above --]
>>> db = anydbm.open ("foo")
[--Snip same error as above--]
>>> db = anydbm.open ("foo", "c")
>>> db["1"]
'foo'
Could anyone point me to the reason I might be getting these errors? Using
c will work fine for now but I'd like to open readonly sometime.
Thanks,
Scott
More information about the Python-list
mailing list