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.2.tar.gz (2.3 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.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: regex_custom_dict-0.2.tar.gz
  • Upload date:
  • Size: 2.3 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.2.tar.gz
Algorithm Hash digest
SHA256 d143a8c436021baca12c401c0b0431d113824d9f013e338eb266cea5e2c9f071
MD5 2ad0ddf3758c3c6a069ece704a8bbcc9
BLAKE2b-256 f1adcb94dfb196f4968e606b2fbbb0e42014445fb1a9eb9c4ce2e44eb0993c29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for regex_custom_dict-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 797ddc788911cd0fb17fcb3d5785649c3386822af18a786eb8a9c11d075f5bfb
MD5 706e116d5f8d5607991241829ad05111
BLAKE2b-256 8746e8a526d9b906a5664bf321e0724a4a43a7440e49e5d08896d925ec0511cf

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