Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Case-insensitive dictionary

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 dicti
Octocat-spinner-32 .gitignore
Octocat-spinner-32 AGPL
Octocat-spinner-32 AUTHORS.md
Octocat-spinner-32 HISTORY.md
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.md
Octocat-spinner-32 README.txt
Octocat-spinner-32 setup.py
README.md

dicti

dicti is a dictionary with case-insensitive keys.

It works like the normal dict except that key matching is case-insensitive.

Installing

pip install dicti

Creating

Import dicti.

from dicti import dicti

Then instantiate dicti like you would a normal dict; for example, these work.

dict(foo = 'bar', answer = 42)
dicti(foo = 'bar', answer = 42)

dict({'foo': 'bar', 'answer': 42})
dicti({'foo': 'bar', 'answer': 42})

Retrieving keys

You can retrieve an item with a case-insensitive match.

di = dicti()
di['cAsE'] = 1
di['case'] == di['CASE']

Methods that record keys record the original case, just as a normal dictionary does.

di = dicti()
di['cAsE'] = 1
di.keys() == ['cAsE']
di['Case'] = 1
di.keys() == ['Case']
di['caSE'] == 1

Keys are still stored in their original case, however; the original keys are presented when you request them with methods like dicti.keys.

Something went wrong with that request. Please try again.