Deep Variable is a lightweight, zero-dependency Python utility designed to eliminate KeyError and TypeError crashes when working with deeply nested data structures
Project description
Deep Variable 🚀
Deep Variable is a lightweight, zero-dependency Python utility designed to eliminate KeyError and TypeError crashes when working with deeply nested data structures.
✨ Features
- Safe Traversal: Access deeply nested keys without worrying about missing parents.
- Intelligent List Navigation: Treat string indices (e.g.,
"0") as list offsets automatically. - Zero Dependencies: Pure Python Standard Library implementation—fast and secure.
- Fully Type-Hinted: Optimized for IDE IntelliSense and
mypystrict mode. - Custom Separators: Use dots, slashes, or any delimiter that fits your data.
🚀 The Difference
The Old Way (Standard Python)
# This is fragile and hard to read
email = None
if data and "users" in data and len(data["users"]) > 0:
profile = data["users"][0].get("profile")
if profile:
email = profile.get("email", "default@site.com")
The Deep Variable Way
from deep_variable import DeepVariable
# Flat, clean, and crash-proof
email = DeepVariable.get(data, "users.0.profile.email", default="default@site.com")
📦 Installation
Install the latest version using pip or uv:
pip install deep-variable
# OR
uv add deep-variable
🛠 Usage Examples
- Safe Reading (Getter)
Python
data = {"org": {"teams": [{"name": "Engineering"}]}}
Navigate through mixed Dicts and Lists
name = DeepVariable.get(data, "org.teams.0.name") # Returns "Engineering"
Safe default on missing path
role = DeepVariable.get(data, "org.teams.0.role", default="Developer") # Returns "Developer"
2. Existence Checking
Python
data = {"status": {"active": False}}
Returns True even if the value is Falsy
DeepVariable.has(data, "status.active") # True
DeepVariable.has(data, "status.missing") # False
3. Safe Writing (Setter)
Python
data = {}
Automatically creates intermediate dictionaries
DeepVariable.set(data, "meta.tags.primary", "python")
print(data) # {'meta': {'tags': {'primary': 'python'}}}
🛡 Performance & Safety
Iterative Logic: Unlike recursive utilities, deep-variable uses loops, making it safe for exceptionally deep JSON structures without risking a RecursionError.
Strict Typing: Built with mypy --strict compliance
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
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 deep_variable-0.1.1.tar.gz.
File metadata
- Download URL: deep_variable-0.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd5c839dbb3aff4759d9df87f7fa5f9f788bb05318b9575f5786dc627c237ef1
|
|
| MD5 |
20233aad64cf2811e2b7950b8caf079d
|
|
| BLAKE2b-256 |
efade7370a284a14796c655a8eecf0a1fe2c239b0b84b18a965d6a854121750c
|
Provenance
The following attestation bundles were made for deep_variable-0.1.1.tar.gz:
Publisher:
publish.yml on CreativeCubicle/deep-variable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deep_variable-0.1.1.tar.gz -
Subject digest:
dd5c839dbb3aff4759d9df87f7fa5f9f788bb05318b9575f5786dc627c237ef1 - Sigstore transparency entry: 976397555
- Sigstore integration time:
-
Permalink:
CreativeCubicle/deep-variable@06ba24c956ec3523dc44cd7170c405781605f116 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/CreativeCubicle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06ba24c956ec3523dc44cd7170c405781605f116 -
Trigger Event:
push
-
Statement type:
File details
Details for the file deep_variable-0.1.1-py3-none-any.whl.
File metadata
- Download URL: deep_variable-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6403975e65564c461d01223a7d43bad4a7be71f140e6df33199e8779908d8fa4
|
|
| MD5 |
95552c130df2fc6a814273f36a0d0aca
|
|
| BLAKE2b-256 |
26725905db14636bdfa386645f766c7363e0aade8b7263918e7aa31a468885a3
|
Provenance
The following attestation bundles were made for deep_variable-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on CreativeCubicle/deep-variable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deep_variable-0.1.1-py3-none-any.whl -
Subject digest:
6403975e65564c461d01223a7d43bad4a7be71f140e6df33199e8779908d8fa4 - Sigstore transparency entry: 976397557
- Sigstore integration time:
-
Permalink:
CreativeCubicle/deep-variable@06ba24c956ec3523dc44cd7170c405781605f116 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/CreativeCubicle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06ba24c956ec3523dc44cd7170c405781605f116 -
Trigger Event:
push
-
Statement type: