--- id: magicattr version: "0.1.6" license: MIT license_treatment: permissive maintenance: abandoned --- # magicattr — A getattr and setattr that works on nested objects, lists, dicts, and any combination thereof without resorting to eval License: permissive · Maintenance: abandoned · Downloads: 5.9M/mo ## What it is and what it does Magicattr extends Python's getattr and setattr to work on deeply nested structures—objects with attributes, lists, and dictionaries—by parsing a path string into an abstract syntax tree and evaluating it safely without using eval. Instead of raising a generic AttributeError, it preserves the actual failure cause, making debugging easier. The package is useful when you need to read or write values deep within a complex object hierarchy using a single string path, such as `'friends[0].settings["style"]["width"]'`. It supports get, set, and delete operations on combinations of object attributes, list indices (including negative indexing), and dictionary keys. It explicitly blocks unsafe operations like function calls, expressions, and slicing. Use it for: - Retrieve or modify configuration nested in dictionaries and objects without manual traversal. - Update deeply nested properties in data models or ORM objects via a single path string. - Delete attributes or list items at arbitrary depths in a complex object tree. - Parse and apply user-provided paths to objects without the security risk of eval. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides nested attribute access and modification on objects, lists, and dictionaries using a dot-and-bracket notation string, without eval. Yes, if you need safe nested attribute access and can accept an abandoned package. The code is simple and has no dependencies, so the risk of breakage is low for stable use cases. However, do not rely on it for new projects requiring active maintenance or support for future Python versions—consider it a utility for existing codebases where the feature set is complete and stable. ## Install pip install magicattr uv add magicattr poetry add magicattr ## Installing magicattr Before you install: Low friction: pure Python wheel with no runtime dependencies. However, the package is abandoned—last commit was 2022-02-18 and no releases since 2022-01-25, so it will not receive bug fixes or maintenance. License in practice: MIT license is permissive; you may use, modify, and distribute this package freely with minimal restrictions. Quickstart: pip install magicattr import magicattr class Person: settings = {'style': {'width': 200}} def __init__(self, name): self.name = name bob = Person('Bob') width = magicattr.get(bob, 'settings["style"]["width"]') magicattr.set(bob, 'settings["style"]["width"]', 400) Verify before relying: - Whether the package works reliably with modern Python versions (support unspecified in metadata). - Whether any edge cases or bugs have emerged since the last release in 2022 that users have worked around. ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: abandoned - Downloads: 5.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags nested attribute access, deep object property getter, list and dict traversal, getattr setattr nested, safe attribute path parsing, object tree navigation, object-introspection, data-access [View on SkillFed](https://skillfed.io/packages/magicattr) · [View on PyPI](https://pypi.org/project/magicattr/)