I want to create a dynamic object (inside another object) in Python and then add attributes to it.
I tried:
obj = someobject obj.a = object() setattr
There are a few ways to reach this goal. Basically you need an object which is extendable.
obj.a = type('Test', (object,), {}) obj.a.b = 'fun' obj.b = lambda:None class Test: pass obj.c = Test()