This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Shelve second tier array subscript "[ ]" key creation doesn't work
Type: behavior Stage: resolved
Components: None Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: cpiekarski, ned.deily
Priority: normal Keywords:

Created on 2011-11-01 22:54 by cpiekarski, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg146816 - (view) Author: Chris Piekarski (cpiekarski) Date: 2011-11-01 22:54
Shelve object second tier array subscript key generation doesn't behave the same way dictionary object do.

>>> import shelve
>>> x = shelve.open("tst1.shelve")
>>> x["one"] = {}
>>> x
{'one': {}}
>>> x["one"]["two"] = 2
>>> x
{'one': {}}

Whereas with a dictionary it works:

>>> y = {}
>>> y["one"] = {}
>>> y["one"]["two"] = 2
>>> y
{'one': {'two': 2}}
msg146817 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-11-01 23:23
shelve is behaving as documented.  Because the shelve dictionary entry is mutable (a dictionary), you need to set writeback=True to get the behavior you expect.  http://docs.python.org/library/shelve.html
History
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57527
2011-11-01 23:23:59ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg146817

resolution: not a bug
stage: resolved
2011-11-01 22:54:06cpiekarskicreate