Skip to content

Allow assets dicts to be called like attrs#16

Merged
ojustino merged 1 commit into
mainfrom
dicts-as-attrs
Apr 2, 2026
Merged

Allow assets dicts to be called like attrs#16
ojustino merged 1 commit into
mainfrom
dicts-as-attrs

Conversation

@ojustino

@ojustino ojustino commented Apr 2, 2026

Copy link
Copy Markdown
Owner
Allow keys of a dictionary to also be called like class attributes:

```
    >>> regions = {'Milotic': 'Hoenn'}
    >>> regions['Milotic']
    Hoenn
    >>> regions.Milotic
    AttributeError: 'dict' object has no attribute 'Milotic'
    
    >>> regions = AttrDict({'Milotic': 'Hoenn'})
    >>> regions['Milotic']  # standard dict behavior
    Hoenn
    >>> regions.Milotic  # behavior enabled by AttrDict
    Hoenn
```

Also handles setting and deleting keys/attrs. Nested dicts are also
converted to AttrDict instances. Less-than-free-range code.

@ojustino
ojustino merged commit e216ff8 into main Apr 2, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant