{"id":21598,"library":"multimapping","title":"MultiMapping","description":"Special MultiMapping objects used in Zope, currently at version 5.1. Provides ordered and unordered mappings supporting multiple values per key (like `NestedMultiMapping` and `IOrderedMultiMapping`). Release cadence is low, with occasional maintenance updates. Requires Python >=3.10.","status":"active","version":"5.1","language":"python","source_language":"en","source_url":"https://github.com/zopefoundation/MultiMapping","tags":["mapping","zope","multiple-values","ordered"],"install":[{"cmd":"pip install multimapping","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The package was renamed to 'multimapping' in version 5.0; old import path no longer exists.","wrong":"from zope.multimapping import MultiMapping","symbol":"MultiMapping","correct":"from multimapping import MultiMapping"},{"note":"","wrong":"","symbol":"NestedMultiMapping","correct":"from multimapping import NestedMultiMapping"},{"note":"","wrong":"","symbol":"IOrderedMultiMapping","correct":"from multimapping import IOrderedMultiMapping"}],"quickstart":{"code":"from multimapping import MultiMapping, NestedMultiMapping\n# Create a simple MultiMapping\nmm = MultiMapping()\nmm['key1'] = 'value1'\nmm.add('key1', 'value2')\nprint(mm.getall('key1'))  # ['value1', 'value2']\n# NestedMultiMapping stores keys as ordered tuples\nnmm = NestedMultiMapping()\nnmm[('a', 'b')] = 1\nprint(nmm[('a', 'b')])  # 1","lang":"python","description":"Basic usage: create MultiMapping and NestedMultiMapping, add multiple values per key."},"warnings":[{"fix":"Replace 'from zope.multimapping import ...' with 'from multimapping import ...'","message":"In version 5.0, the package was renamed from 'zope.multimapping' to just 'multimapping'. All imports must be updated.","severity":"breaking","affected_versions":">=5.0"},{"fix":"Use 'IMultiMapping' from 'multimapping.interfaces'","message":"The 'IUnorderedMultiMapping' interface is deprecated and will be removed in a future version. Use 'IMultiMapping' instead.","severity":"deprecated","affected_versions":">=5.0"},{"fix":"If you need an immutable sequence, convert the result to tuple: tuple(mm.getall('key1'))","message":"Methods like 'getall' return a list, not a tuple. Relying on immutability can break code.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the new package and update imports: pip install multimapping; from multimapping import MultiMapping","cause":"The package was renamed to 'multimapping' in version 5.0, so 'zope.multimapping' no longer exists.","error":"ImportError: cannot import name 'MultiMapping' from 'zope.multimapping'"},{"fix":"For MultiMapping, use 'add' if available (v5+). For older versions, use 'insert'. Check your version: import multimapping; print(multimapping.__version__)","cause":"The 'add' method was renamed to 'insert' in an older version but then restored. If you see this, you might be using an obsolete version or a different class.","error":"AttributeError: 'MultiMapping' object has no attribute 'add'"},{"fix":"Use a tuple key: nmm[('key',)] = value, not nmm['key'] = value","cause":"NestedMultiMapping keys must be tuples of arbitrary length. You tried a single key without wrapping it in a tuple.","error":"TypeError: 'NestedMultiMapping' object does not support item assignment"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}