Skip to main content

Simple type that extends default python dict to dict with regex keys

Project description

regex-dictionary

Python type to use regex as keys in dict

Install

pip install regex-dictionary

Usage

>>> from regex_dictionary import RegexDict
>>> d = RegexDict({"simple_key": "simple_value", "regex_key.*": "simple_value"})
>>> d["simple_key"]
'simple_value'
>>> d["regex_key_some_stuff"]
'simple_value'
>>> d.get("regex_key_some_stuff", "default")
'simple_value'
>>> d.get("some_stuff_regex_key_some_stuff", "default")
'default'
>>> for k, v in d.items():
...     print(k, v)
...
re.compile('^simple_key$') simple_value
re.compile('^regex_key.*$') simple_value

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

regex-dictionary-1.0.2.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

regex_dictionary-1.0.2-py3-none-any.whl (11.0 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