Package: pydicti
InstallationYou can install the newest version ofpydictifromPyPI:pipinstallpydictiAlternatively, you can just take the filepydicti.pyand redistribute
it with your application.Overviewclass dicti: default case insensitive dictionary typeclass odicti: ordered case insensitive dictionary typedef build_dicti: create a case insensitive dictionary classdef Dicti: create a case insensitive copy of a dictionarydictiObjects of typedictiare dictionaries that feature case insensitive
item access:>>>d=dicti(Hello='foo',world='bar')>>>d['heLLO']'foo'>>>'WOrld'indTrueInternally however, the keys retain their original case:>>>sorted(d.keys())['Hello','world']odictiThe typeodictiinstanciates order-preserving case insensitive
dictionaries:>>>odicti(zip('abc',range(3)))Dicti(OrderedDict([('a',0),('b',1),('c',2)]))build_dictiWithbuild_dictiyou can create custom case insensitive dictionaries.
This function is what is used to create thepydicti.dictiandpydicti.odictitypes. Note that callingbuild_dictiseveral times
with the same argument will result in identical types:>>>build_dicti(dict)isdictiTrue>>>build_dicti(OrderedDict)isodictiTruebuild_dictiuses subclassing to inherit the semantics of the given base
dictionary type:>>>issubclass(odicti,OrderedDict)TrueDictiThe functionDictiis convenient for creating case insensitive
copies of dictionary instances:>>>o=OrderedDict(zip('abcdefg',range(7)))>>>oi=Dicti(o)>>>type(oi)isodictiTrueJSONThe subclassing approach allows to plug your dictionary instance into
places where typechecking withisinstanceis used, like in thejsonmodule:>>>importjson>>>d==json.loads(json.dumps(d),object_hook=dicti)TrueYou can usejson.loads(s, object_pairs_hook=odicti)to
deserialize ordered dictionaries.PitfallsThe equality comparison tries preserves the semantics of the base type as
well as reflexitivity. This has impact on the transitivity of the
comparison operator:>>>i=dicti(oi)>>>roi=odicti(reversed(list(oi.items())))>>>roi==iandi==oiTrue>>>oi!=roiandroi!=oi# NOT transitive!True>>>oi==iandi==oi# reflexiveTrueThecoercion rulesin python allow this to work pretty well when
performing comparisons between types that are subclasses of each other. Be
careful otherwise, however.LicenseCopyright © 2013 Thomas Gläßle <t_glaessle@gmx.de>This work  is free. You can  redistribute it and/or modify  it under the
terms of the Do What The Fuck  You Want To Public License, Version 2, as
published by Sam Hocevar. See the COPYING file for more details.This program  is free software.  It comes  without any warranty,  to the
extent permitted by applicable law.CHANGELOG1.2.0Date: 25.02.2023fix incorrect behaviour of__or__and__ior__, see #81.2.0Date: 15.12.2022add type hints1.1.6Date: 04.11.2021update the badges on the landing page1.1.5Date: 04.11.2021maintenance release for testing automatic releases using GitHub Actions1.1.4Date: 17.10.2020usestr.casefold()on python3make normalization function a parameter ofbuild_dict, so that
user-defined normalization functions can be passed1.1.3Date: 28.06.2019avoid key recomputation in__setitem__1.1.2Date: 28.06.2019leave item order invariant under assignment in odicti (#2)leave key case invariant under assignment1.1.1Date: 25.03.2019fix deprecated MutableMapping import (error on py38)1.1.0Date: 19.03.2019drop py2.6 supportfix version number in long_description1.0.0Date: 19.03.2019make str representation more dict-likemisc cleanup0.0.6Date: 08.09.2016fix UnicodeDecodeError in setup when UTF-8 is not the default encoding0.0.5Date: 18.05.2016fix pickling on py 3.5the ‘name’ parameter to build_dicti can now be a qualname0.0.4Date: 01.02.2014add coverage reportsuse more extensive unit testsadd support for pickle0.0.3Date: 26.01.2014add support for python26make dependency onOrderedDictoptionalmigrate to setuptools in order to use testing commandssupportordereddict.OrderedDictas fallback0.0.2Date: 29.12.2013fixdicti.popsupportdeepcopy(dicti)make nosetest automatically execute the doctests