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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for regex_dictionary-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08b20815ed694d59aace1567f96bc9308994c4ce01dfb205e1683815c17fbe4a |
|
MD5 | 43525206359f7504ff239ffe15ada28b |
|
BLAKE2b-256 | 1aa20f85a50267e61c22ea9697d753f52bf81afd5833f9e48ce72aed00a3ec51 |