Kitchen.collections — kitchen 1.1.1 documentation

Kitchen.collections

StrictDict

kitchen.collections.StrictDict provides a dictionary that treats str and unicode as distinct key values.

class kitchen.collections.strictdict.StrictDict

Map class that considers unicode and str different keys

Ordinarily when you are dealing with a dict keyed on strings you want to have keys that have the same characters end up in the same bucket even if one key is unicode and the other is a byte str. The normal dict type does this for ASCII characters (but not for anything outside of the ASCII range.)

Sometimes, however, you want to keep the two string classes strictly separate, for instance, if you’re creating a single table that can map from unicode characters to str characters and vice versa. This class will help you do that by making all unicode keys evaluate to a different key than all str keys.

See also

dict for documentation on this class’s methods. This class implements all the standard dict methods. Its treatment of unicode and str keys as separate is the only difference.

Table Of Contents

Previous topic

UTF-8

Next topic

Kitchen.iterutils Module

This Page