A case-insensitive ordered dictionary for Python
Project description
Overview
Class NocaseDict is a case-insensitive ordered dictionary that preserves the original lexical case of its keys.
Example:
$ python
>>> from nocasedict import NocaseDict
>>> dict1 = NocaseDict({'Alpha': 1, 'Beta': 2})
>>> dict1['ALPHA'] # Lookup by key is case-insensitive
1
>>> print(dict1) # Keys are returned with the original lexical case
NocaseDict({'Alpha': 1, 'Beta': 2})
The NocaseDict class supports the functionality of the built-in dict class of Python 3.8 on all Python versions it supports, with these exceptions (and the case-insensitivity of course):
The iter..(), view..() and has_key() methods are only present on Python 2, consistent with the built-in dict class.
The keys(), values() and items() methods return a list on Python 2 and a dictionary view on Python 3, consistent with the built-in dict class.
Functionality can be added using mixin classes:
HashableMixin mixin class: Adds case-insensitive hashability.
KeyableByMixin mixin generator function: Adds ability to get the key from an attribute of the value object.
Why yet another case-insensitive dictionary: We found that all previously existing case-insensitive dictionary packages on Pypi either had flaws, were not well maintained, or did not support the Python versions we needed.
Installation
To install the latest released version of the nocasedict package into your active Python environment:
$ pip install nocasedict
This will also install any prerequisite Python packages.
For more details and alternative ways to install, see Installation.
Documentation
Change History
Contributing
For information on how to contribute to the nocasedict project, see Contributing.
License
The nocasedict project is provided under the GNU Lesser General Public License (LGPL) version 2.1, or (at your option) any later version.
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.
Source Distribution
Built Distribution
File details
Details for the file nocasedict-0.5.0.tar.gz
.
File metadata
- Download URL: nocasedict-0.5.0.tar.gz
- Upload date:
- Size: 40.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed74b83c7b81505ccaf4b09b0581477fdd5c1099c929098a6a170a91ec26fd33 |
|
MD5 | b1037d65f1f73322c3c2d76681195bb3 |
|
BLAKE2b-256 | 5dbe0f21bb00ad477ead1bcc56b803f5be8b5b91268f60bd835609ac70b14454 |
File details
Details for the file nocasedict-0.5.0-py2.py3-none-any.whl
.
File metadata
- Download URL: nocasedict-0.5.0-py2.py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31bce8b873e69a0223b89f54a15001a7f9469a36be9dbb7d931dc4dff5c83049 |
|
MD5 | af9910f3727f6c18122a6525d0f63cca |
|
BLAKE2b-256 | 2a2d85e3c4126faf91cdee355334229b4e427aa4ea319992d31de5f88e4ab765 |