lundi 27 août 2018

make dictionary to objects of class in python

i made the class for making dict keys to object accessor but this is not working in nested case

d= {'c': {'v': {'a'}}, 'e': 'x', 'r': 'e'}
class A:
     def __init__(self, dicti):
         self.__dict__.update(dicti)
o = A(d)
# i want something like o.c.v=a , o.e=x, o.r=e
# i'm unable to make nested dict object accessor  

looking for help

Aucun commentaire:

Enregistrer un commentaire