Skip to main content

An extended Python dict implementation that supports multiple key selection with a pretty syntax.

Project description

dictf

An extended Python dict implementation that supports multiple key selection with a pretty syntax.

How to use it

First you install the package with pip

pip install dictf

Then you can use it like this:

from dictf import dictf


example_dictf = dictf(name="Led Zepellin", singer="Robert Plant", guitarist="Jimmy Page")

print(example_dictf["name"])
>>> 'Led Zepellin'

print(example_dictf[["name"]])
>>> {'name': 'Led Zepellin'}

# The pandas inspired syntax makes it easy to understand how the lib works
print(example_dictf[["name", "singer"]])
>>> {'name': 'Led Zepellin', 'singer': 'Robert Plant'}

# The return type is a dictf whenever you use a list, tuple or set as key
print(type(example_dictf[["name", "singer"]]))
>>> dictf

# If one key doesn't exist, a KeyError is raised
print(example_dictf[["name", "singer", "drummer"]])
>>> KeyError

Currently you can not make multiple assignments at the same time, and I'm not sure we need to add this functionality. I'm open to suggestions, though!

Contributing

Contributions are welcome and appreciated. Make sure to read our guide for contributing and don't forget to check out our code of conduct.

Also, please do check out our other libs as well such as https://github.com/Eric-Mendes/unexpected-isaves.

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

dictf-1.0.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

dictf-1.0.0-py3-none-any.whl (3.9 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