I will admit to implementing `__getattr__` and `__setattr__` in such a way that they mimic object properties in dictionaries, for specific cases.
In general, the threshold for doing so should be IMHO fairly high. In my case,
- they are data-heavy classes but not @dataclass classes,
and
- there's enough attribute access that the `["` and `"]` become visually distracting,
and
- there are nested structures, so so you can write `x.foo.bar.baz` instead of `x["foo"]["bar"]["baz"]`
This is especially useful, in our case, in a system that intakes a lot of JSON with a LOT of nested dictionaries.
No comments yet.