Dictionary with loose rules for finding keys.
Project description
PermissiveDict
Dictionary class with loose rules for returning an attribute or a requested key value.
Note: may resort to iterating the dict values to find the matching requested key, so is potentially slow.
Key is first directly found using the exact key, and then loose rules are used.
Rules:
- Keys compared without regard to case.
- Spaces, underscores, full-stops and dashes are equivalent in a requested key.
- Requested key is converted to str and stripped for wild card searching.
- Items in the list can be retrieved by, get, attribute_access, call or array requested_key.
- First matching element is returned.
- Default of '' is used instead of dict standard None or raising KeyError
- Multiple keys can be supplied separated with , (comma)
Example:
from permissive_dict import PermissiveDict
a = PermissiveDict({'A B': 2, 4: 4})
a.get('A_b') == a['a_b'] == a['A b'] == a['A_B'] == a['a-b '] == a['a.b '] == a.a_b == a.A_b == a('a-b')
a.get('blue,4') == 4
a.get('4') == a[4] == a(4) == a('4')
Items with multiple wildcard keys matching in the dictionary will return the first item found.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file permissive_dict-1.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: permissive_dict-1.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
454c04c1e8469decadfe6407f673b2b13d1a02eaed9c9fb37cb71a5b05890e27
|
|
| MD5 |
67443d9f0e2cf2ab42ee3e26c6d1eab7
|
|
| BLAKE2b-256 |
82dd557925b03e3847f7747c06811a99b78efe76147374eb7c6a31b1545c5db4
|