changes to shelf items fail silently?

eichin at metacarta.com eichin at metacarta.com
Mon Mar 17 16:42:29 EST 2003


shelftest.py:

#!/usr/bin/python                                                                                          
import shelve

complex_example = shelve.open("/tmp/complex_example_shelf")
complex_example["a"] = []
print complex_example["a"]
complex_example["a"].append("b")
print complex_example["a"]
complex_example["a"].extend(["b"])
print complex_example["a"]
complex_example["a"] = complex_example["a"] + ["b"]
print complex_example["a"]

$ python shelftest.py 
[]
[]
[]
['b']

So, I see why the last case works (it can't help *but* work) but I
don't get why the append/extend mutators don't.  Or rather, why if
they can't work, I don't get an error thrown so I notice it...

(this occurs in 2.1 and 2.2.  Is there a "better" shelf-like thing
that I should use instead, for more completely persistent data?)




More information about the Python-list mailing list