survey: is shelve broken? should it be fixed?

Emile van Sebille emile at fenx.com
Tue May 7 07:27:20 EDT 2002


"Alex Martelli" <aleax at aleax.it> wrote in message
news:8mMB8.12837$CN3.452004 at news2.tin.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:
>
> [alex at lancelot Lib]$ python
> Python 2.2.1 (#1, Apr 15 2002, 17:55:14)
> [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import shelve
> >>> s=shelve.open('ciao','c')
> >>> s['ciao']=range(4)
> >>> s['ciao']
> [0, 1, 2, 3]
> >>> s['ciao'].append(23)
> >>> s['ciao']
> [0, 1, 2, 3]
>

...although, if you use in-place operators....

>>> s['ciao']+=[23]
>>> s['ciao']
[0, 1, 2, 3, 23]

+1 on the fix.


--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list