class MicroMock(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def print_foo(x):
print x.foo
print_foo(MicroMock(foo=3))
>>> obj = type('',(object,),{"foo": 1})()
>>> obj.foo
1
#So brief, such Python! O.o
>>> Object = lambda **kwargs: type("Object", (), kwargs)
#Then you can use Object as a generic object constructor:
>>> person = Object(name = "Bernhard", gender = "male", age = 42)
>>> person.name
'Bernhard'
>>>