I am looking for a simple way to directly convert a python dict to a custom object as follows, while not breaking intellisense. The result should not be read-only, it should behave just like a new object.
d = {
"key1": 1,
"key2": 2
}
class MyObject(object):
key1 = None
key2 = None
# convert to object o
# after conversion
# should be able to access the defined props
# should be highlighted by intellisense
print(o.key1)
# conversion back to dict is plain simple
print(o.__dict__)
for key, value in d.items(): setattr(o, key, value)
– Angelangela