multi-key-dict (version 2.0.3) is a Python library that provides a dictionary implementation allowing multiple distinct keys to refer to the same single value. It extends the standard dictionary interface to enable access, update, and deletion of elements via any of its associated keys. The library appears to be in maintenance mode, with its last release in 2015.
pip install multi-key-dictVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to create a multi-key dictionary, assign a value using multiple keys, access the value via any of its keys, update the value through one key (affecting all associated keys), and delete the value through one key (making it inaccessible via others).
Understand the core functionality: multi-key-dict maps multiple distinct keys to one unique value. If you need a key to map to a list of values, consider using `list` as a value or explore other 'multidict' implementations if that is the desired behavior.
Be aware that keys associated with the same value are linked. An update operation on any one of these keys will propagate to all other linked keys. Test thoroughly if this behavior is unexpected for your use case.
When deleting an item, understand that you are deleting the shared value, not just the association with a single key. Ensure this is the intended side effect across all linked keys.
Assess if the current feature set meets your long-term needs. Consider potential compatibility issues with newer Python versions, though `requires_python: None` suggests broad compatibility. Monitor the GitHub repository for any new activity.
Install the package using pip: `pip install multi-key-dict`
Ensure the key (or one of its aliases) exists in the dictionary before attempting to access it, for example, by using `if 'some_key' in my_mkey_dict:` or `my_mkey_dict.get('some_key', default_value)`.To add or update a value, use assignment `my_mkey_dict[key] = new_value`. If you intend to store multiple items under a key, ensure the value itself is a list (or other mutable collection) and append to that: `my_mkey_dict[key].append(item)`.
Use the correct import statement as shown in the library's examples: `from multi_key_dict import multi_key_dict`
No dependency data recorded yet.