https://github.com/pywbem/nocaselist
A case-insensitive list for Python
https://github.com/pywbem/nocaselist
case-insensitive list python
Last synced: 11 months ago
JSON representation
A case-insensitive list for Python
- Host: GitHub
- URL: https://github.com/pywbem/nocaselist
- Owner: pywbem
- License: apache-2.0
- Created: 2020-07-18T02:50:32.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T09:51:55.000Z (over 1 year ago)
- Last Synced: 2024-11-28T15:42:18.872Z (over 1 year ago)
- Topics: case-insensitive, list, python
- Language: Python
- Homepage:
- Size: 300 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# nocaselist - A case-insensitive list for Python
[](https://pypi.python.org/pypi/nocaselist/)
[](https://github.com/pywbem/nocaselist/actions/workflows/test.yml?query=branch%3Amaster)
[](https://readthedocs.org/projects/nocaselist/builds/)
[](https://coveralls.io/github/pywbem/nocaselist?branch=master)
# Overview
Class
[NocaseList](https://nocaselist.readthedocs.io/en/master/reference.html#nocaselist.NocaseList)
is a case-insensitive list that preserves the lexical case of its items.
Example:
$ python
>>> from nocaselist import NocaseList
>>> list1 = NocaseList(['Alpha', 'Beta'])
>>> print(list1) # Any access is case-preserving
['Alpha', 'Beta']
>>> 'ALPHA' in list1 # Any lookup or comparison is case-insensitive
True
The
[NocaseList](https://nocaselist.readthedocs.io/en/master/reference.html#nocaselist.NocaseList)
class supports the functionality of the built-in
[list class of Python 3.8](https://docs.python.org/3.8/library/stdtypes.html#list)
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()](https://docs.python.org/3/library/stdtypes.html#str.casefold)
for unicode string keys and with
[bytes.lower()](https://docs.python.org/3/library/stdtypes.html#bytes.lower)
for byte string keys. The default casefolding can be overridden with a
user-defined casefold method.
# Installation
To install the latest released version of the nocaselist package into
your active Python environment:
$ pip install nocaselist
The nocaselist package has no prerequisite Python packages.
For more details and alternative ways to install, see
[Installation](https://nocaselist.readthedocs.io/en/master/intro.html#installation).
# Documentation
- [Documentation](https://nocaselist.readthedocs.io/en/master/)
# Change History
- [Change history](https://nocaselist.readthedocs.io/en/master/changes.html)
# Contributing
For information on how to contribute to the nocaselist project, see
[Contributing](https://nocaselist.readthedocs.io/en/master/development.html#contributing).
# License
The nocaselist project is provided under the [Apache Software License
2.0](https://raw.githubusercontent.com/pywbem/nocaselist/master/LICENSE).