Skip to main content

More picky version of Python dictionary.

Project description

pickydict

More picky version of Python dictionary

PickyDict objects will behave just like Python dictionaries, with a few notable exceptions:

(1) PickyDict has a force_lower_case attribute. If set to True (default) then dictionary keys will all be treated as lower-case.

(2) PickyDict can contain a second dictionary named "replacements" with mappings to enforce translating specific key words.

Examples:

from pickydict import PickyDict

# per default force_lower_case is set to True:
my_dict = PickyDict({"A": 1, "B": 2})
print(my_dict)  # => {'a': 1, 'b': 2}

# now also using a replacements dictionary
my_dict = PickyDict({"A": 1, "B": 2},
                    replacements={"a": "abc", "b": "bcd", "c": "cde"})
print(my_dict)  # => {'abc': 1, 'bcd': 2}
my_dict["c"] = 100
print(my_dict)  # => {'abc': 1, 'bcd': 2, , 'cde': 100}
my_dict["b"] = 5  # => ValueError: Key 'b' will be interpreted as 'bcd'...

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

pickydict-0.1.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

pickydict-0.1.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

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