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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

regex_dictionary-1.0.2-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file regex-dictionary-1.0.2.tar.gz.

File metadata

  • Download URL: regex-dictionary-1.0.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for regex-dictionary-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4c87cb32419fbec9fdd2911032293b9a3ba4346d2facbf67497b5e571952f700
MD5 a5c3b146daa95f2b69ea9e39ce0dc037
BLAKE2b-256 1399526bf9fd87667c3984bd74ae0630b91bd22aad4a793e8976672e5025915b

See more details on using hashes here.

File details

Details for the file regex_dictionary-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for regex_dictionary-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08b20815ed694d59aace1567f96bc9308994c4ce01dfb205e1683815c17fbe4a
MD5 43525206359f7504ff239ffe15ada28b
BLAKE2b-256 1aa20f85a50267e61c22ea9697d753f52bf81afd5833f9e48ce72aed00a3ec51

See more details on using hashes here.

Supported by

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