prodict
prodict copied to clipboard
getattr() should raise AttributeError
Hi,
I don't know if this is maintained anymore, but I would suggest that getattr()
raises an AttributeError
instead of KeyError
.
This would avoid breaking other libraries that expect getattr()
ro raise an AttributeError
such as Jinja2 for instance (but not only, also had trouble with omegaconf
when creating a DictConfig
from Prodict
).
Best regards,
Antoine
def __getattr__(self, item):
try:
return self[item]
except KeyError as exc:
raise AttributeError(str(exc))