addict
addict copied to clipboard
Deep setattr and gettattr when attribute names contain '.'
Would it be possible (prudent?) for the Dict.__setattr__
and Dict.__getattr__
functions to be modified to make nested attribute gets/sets when given attribute names that contain periods?
For example:
>>> from addict import Dict
>>>
>>> d = Dict()
>>> d.date.year = 2019
>>> setattr(d, "date.month", "FEB")
>>>
>>> d.date.year
2019
>>> getattr(d, "date.month")
'FEB'
>>> getattr(d, "date.year")
{} # Desired output: 2019
>>> d.date.month
{} # Desired output: 'FEB'
>>>
Im sure this has been handled already but based on the title, when you use dot notation it will automatically do a deep copy?
definitely possible, slightly worried about breaking something.