from new import classobj
obj = classobj('Test', (object,), {'attr1': int, 'attr2': int})
setattr(obj, 'attr1', 10)
setattr(obj, 'attr2', 20)
getattr(obj, 'attr1')
getattr(obj, 'attr2')
How to access object attribute given string corresponding to name of that attribute