A dictionary manipulator that enables attribute-style access to dictionary items.
Project description
attrobj
A dictionary manipulator that enables attribute-style access to dictionary items.
Also, supports nested dictionaries and value filtering via predicates.
Example
from attrobj import Object
foo = Object({"quake": {"mw": "3.7"}})
bar = Object({"quake": {"ml": "3.9"}})
print("first quake:", foo.quake.any(["mw", "ml", "md"], key=True)) # {'mw': 3.7}
print("second quake:", bar.quake.any(["mw", "ml", "md"], key=True)) # {'ml': 3.9}
foo.haskey("quake") # True
foo.only() # Filters out None values
foo.only(lambda k, v: k[:2] == "is") # Filters keys starting with 'is'
info = Object({"quake": {"magnitude": 3.9}})
print(info.quake.magnitude) # 3.9
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
attrobj-0.2.0.tar.gz
(3.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file attrobj-0.2.0.tar.gz.
File metadata
- Download URL: attrobj-0.2.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba46fc8c9d89e46f07d04fcdd0b6608d3c31b7ee954cfffdc49d7b735d5a473e
|
|
| MD5 |
8b0f26243751d34b2fc8faf80bb493ba
|
|
| BLAKE2b-256 |
67724ad946f0fa655aff5ba12e11ad3d50ce4e481bb7983468f697df8a726f7c
|
File details
Details for the file attrobj-0.2.0-py3-none-any.whl.
File metadata
- Download URL: attrobj-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c89a556a2469487633fe903788c0c84c5bec2dda23a1f3fad21a49a88c67ac9b
|
|
| MD5 |
571a44a91eb8f98ae5c02729edac94c8
|
|
| BLAKE2b-256 |
b18cadaa7615df92afde011a3cfb45e545f3710618d9731a6f9f3659ee324a13
|