Python – pretty dictionary access for objects

Instead of hash like access i.e. val = hash[‘key’]

You can achieve a prettier val = obj.key :

class Obj:
..def add(self, k, v):
....self.__dict__[k] = v

o = Obj()
o.add(key, val)

Leave a Reply