survey: is shelve broken? should it be fixed?

Bjorn Pettersen BPettersen at NAREX.com
Tue May 7 15:28:22 EDT 2002


> From: Alex Martelli [mailto:aleax at aleax.it] 
> 
> Just checking if I'm the only one to feel that shelve 
> seriosly violates the 
> principle of least astonishment when you shelve modifiable values:

[snip]
 
> We probably can't change this default (mis-)behavior due to 
> backward compatibility needs, but it wouldn't be too hard to 
> at least give a simple 
> _optional_ way out, even though off-by-default:

+1 if it also prints 2 as the result of the last expression below (and
if it remains 2 after I close and re-open the shelve):

>>> import shelve
>>> s = shelve.open('ciao','c')
>>> class Foo:
...   def __init__(self, x):
...     self.x = x
...
>>> class Bar:
...   def __init__(self, y):
...     self.y = y
...
>>> s['bye'] = Foo(Bar(1))
>>> s['bye'].x.y = 2
>>> s['bye'].x.y
1
>>>

Seems like a "real" OODBMS might be the only thing that would count as
unsurprising in this case though?

-- bjorn





More information about the Python-list mailing list