Skip to main content

nocasedict - A case-insensitive ordered dictionary for Python

Version on Pypi Test status (master) Docs status (master) Test coverage (master)

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.

Limitation: Any functionalities added to the dict class in Python 3.9 or later are not yet supported. These are:

  • d | other - Added in Python 3.9.
  • d |= other - Added in Python 3.9.

The case-insensitivity is achieved by matching any key values as their casefolded values. By default, the casefolding is performed with str.casefold() for unicode string keys and with bytes.lower() for byte string keys. The default casefolding can be overridden with a user-defined casefold method.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nocasedict-2.0.3.tar.gz (40.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nocasedict-2.0.3-py2.py3-none-any.whl (23.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file nocasedict-2.0.3.tar.gz.

File metadata

  • Download URL: nocasedict-2.0.3.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for nocasedict-2.0.3.tar.gz
Algorithm Hash digest
SHA256 1c9226c7f5a8a97ad51dcb0ae3157a720e3f7cb9c4568d22ea3a05e3f85658a9
MD5 6ddeacf0adeed0b23ffe5b4d727d87d4
BLAKE2b-256 0aca1b44e958239052935019f65eed56a1af7ca20c2f0bbcddd03751789d8303

See more details on using hashes here.

File details

Details for the file nocasedict-2.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: nocasedict-2.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for nocasedict-2.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c364ddc9e0b749654709160b109dff3da8b9cf061de1baf869d66c697a01c38e
MD5 45253c634eec2ea0d3f8c664d29dfb6c
BLAKE2b-256 7de0bf856524f0f371cca531cf43df0285201c87be905151cff90c19d8435977

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.1

2 files

2.2.0

2 files

2.1.0

2 files

2.0.5

2 files

2.0.4

2 files

This release

2.0.3 This release

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.5.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page