Created
April 20, 2021 18:10
-
-
Save dsantiago/3825738f63d0e29f85f24bd887ac089d to your computer and use it in GitHub Desktop.
Convert dict to cal propoeries with "."
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class dotaccess(dict): | |
__getattr__ = dict.get | |
__setattr__ = dict.__setitem__ | |
__delattr__ = dict.__delitem__ | |
ml_eng = { | |
'name': 'Diogo Santiago', | |
'link': 'http://github.com/dsantiago/' | |
} | |
ml_eng = dotaccess(ml_eng) | |
print(ml_eng.name) | |
print(ml_eng.link) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment