Multi key dictionary implementation
Project description
Implementation of a multi-key dictionary, i.e.:
(key1[,key2, ..]) => value
This dictionary has a similar interface to the standard dictionary => but is extended to support multiple keys referring to the same element.
If element is created using multiple keys, e.g.:
from multi_key_dict import multi_key_dict k = multi_key_dict() k[1000, 'kilo', 'k'] = 'kilo (x1000)' print k[1000] # will print 'kilo (x1000)' print k['k'] # will also print 'kilo (x1000)' # the same way objects can be updated, deleted: # and if an object is updated using one key, the new value will # be accessible using any other key, e.g. for example above: k['kilo'] = 'kilo' print k[1000] # will now print 'kilo' as value was updated
These elements can be accessed using either of those keys (e.g for read/update/deletion).
Multi-key dict provides also extended interface for iterating over items and keys (e.g. by the key type), which might be useful when creating, e.g. dictionaries with index-name key pair allowing to iterate over items using either: names or indexes. It can be useful for many many other similar use-cases, and there is no limit to the number of keys used to map to the value.
There are few other useful methods, e.g. to iterate over dictionary (by/using) selected key type, finding other keys mapping to the same value etc. Refer to example/test code to see it in action.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size multi_key_dict-2.0.3.tar.gz (8.4 kB) | File type Source | Python version None | Upload date | Hashes View |
Filename, size multi_key_dict-2.0.3.win32.exe (206.7 kB) | File type Windows Installer | Python version any | Upload date | Hashes View |
Filename, size multi_key_dict-2.0.3.win-amd64.exe (146.8 kB) | File type Windows Installer | Python version any | Upload date | Hashes View |
Filename, size multi_key_dict-2.0.3.zip (9.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for multi_key_dict-2.0.3.win-amd64.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb67a532d7361a66820aa1e8fe6c0c939f4c34a3a09a3e8db199ce7b77c4fb78 |
|
MD5 | 67b3f7128dd4ef09cdfebbed9fdfd7b7 |
|
BLAKE2-256 | 47a5a2d29af9491979a4f41b0e35f9530e581a6a6b99f6a25a82b7f1afc4570e |