Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep setattr and gettattr when attribute names contain '.' #110

Open
evanjtravis opened this issue Feb 20, 2019 · 2 comments · May be fixed by #144
Open

Deep setattr and gettattr when attribute names contain '.' #110

evanjtravis opened this issue Feb 20, 2019 · 2 comments · May be fixed by #144

Comments

@evanjtravis
Copy link

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'
>>>
@MorenoBandito
Copy link

Im sure this has been handled already but based on the title, when you use dot notation it will automatically do a deep copy?

@mewwts
Copy link
Owner

mewwts commented Sep 12, 2020

definitely possible, slightly worried about breaking something.

@dxma dxma linked a pull request May 26, 2022 that will close this issue
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 a pull request may close this issue.

3 participants