Skip to main content

A case-insensitive list for Python

Project description

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.14 on all Python versions it supports (except for being case-insensitive, of course).

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.

Project details


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.2.0.tar.gz (135.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.2.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nocasedict-2.2.0.tar.gz
  • Upload date:
  • Size: 135.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nocasedict-2.2.0.tar.gz
Algorithm Hash digest
SHA256 6f2b608602b0568cd06ff46e2a0f231d2a0c247d6dc120672c381cb29169e1e7
MD5 d4848aa4bda25adf8689354478f7a0e7
BLAKE2b-256 c0b3430e1cf279b34807c37304c9c50576523c5ca3a514e964e7e376d0cfc6c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for nocasedict-2.2.0.tar.gz:

Publisher: publish.yml on pywbem/nocasedict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nocasedict-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: nocasedict-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nocasedict-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca46fd37843c94ca21c7933abd59b8c3ec6f50310c699e0db1eaa208452c155a
MD5 4236f23c6262b59c9b39da9a59d0b217
BLAKE2b-256 a7f0c1dfe5943bb51b93c7045ffc4f56c85eb56c14f9afc28ba1429e903d9d89

See more details on using hashes here.

Provenance

The following attestation bundles were made for nocasedict-2.2.0-py3-none-any.whl:

Publisher: publish.yml on pywbem/nocasedict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page