Sometimes i need to create an anonymous class instance in python, just like c#:
var o= new {attr1=\"somehing\", attr2=344};
but in python i
I prefer the dict answer from mwhite, but here's how I've done it in the past using the "magic" of kwargs (pun intended).
class ObjectFromDict(object):
def __init__(**kwargs):
for k in kwargs:
if k not in self.__dict__:
setattr(k,v)
myObj = ObjectFromDict(**{'foo': 'bar', 'baz': 'monkey'})
print myObj.foo #bar