Skip to main content

No project description provided

Project description

RegexDict

RegexDict is a Python class that extends the built-in dict class, allowing you to access dictionary keys using regular expressions.

Features

  • Access dictionary keys using regex patterns.
  • Flatten nested dictionaries into a single level for easy access.

Installation

bash or windows

pip install regex_dict

Usage

from regex_dict import RegexDict

# Create an instance of RegexDict
my_dict = RegexDict(x={'sde': {'6': 4}}, y=4, xx={'sde': 2, 'sq': 3}, xxx=6.8)

#Alternate - you can even convert a normal_dict into a regex_dict
my_dict = RegexDict(**normal_dict)

# Access keys using regex pattern
result = my_dict['x+']
# The output will be a dictionary containing keys that match the provided regex pattern with predefined keys.

#To flatten the output.
result = my_dict['x+'].flatten_dict()

#you can also use multiple hierarchies(keys)
my_dict['x+']['s+']

It will flatten out the values and give as a list if your pattern matches multiple keys.

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_custom_dict-0.3.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

regex_custom_dict-0.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file regex_custom_dict-0.3.tar.gz.

File metadata

  • Download URL: regex_custom_dict-0.3.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.0

File hashes

Hashes for regex_custom_dict-0.3.tar.gz
Algorithm Hash digest
SHA256 8b31090b9a7bce210d00627504985e982ea2b3318f6e84da0173b01ccd8743ca
MD5 08f2e6a850d3c754a0d2c94c72f5fb68
BLAKE2b-256 deb4c3edf33ee382571e94d1f0f5cede43fd818e8ea8dd620e67291dbdc092fb

See more details on using hashes here.

File details

Details for the file regex_custom_dict-0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for regex_custom_dict-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9ffb7959cee3e947091bd6119425efd575d3e78c751ecb3d39b5d23eaadff663
MD5 2eb501db3a16d4e0a330dd9b8ed2121a
BLAKE2b-256 14c1631a831d864166cc450157047b97ea7b59aeeb8efd201e1201d90cdeee5f

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