Hi there! Cool packages, but run into an issue with it right in the beginning...
from dotsi import DotsiDict
assert getattr({}, "a", None) is None # all good
hasattr(DotsiDict({}), "a") # raises
assert getattr(DotsiDict({}), "a", None) is None # raises
which raises e.g.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/var/folders/s5/z9b__9915kq1tpx_kltkywn80000gn/T/ipykernel_40275/4202784131.py in <module>
----> 1 assert getattr(DotsiDict({}), "a", None) is None
KeyError: 'a'
Hi there! Cool packages, but run into an issue with it right in the beginning...
which raises e.g.
The problem is this line:
and the core issue is this:
python relies on catching specific exceptions to make
hasattr
andgetattr(obj, key, default_value)
workPotential solution is something like:
PS for context i run into this because I use iPython/JupyterLab +
rich.pretty
package to visualise objects: