Create Class Implicitly In Python
Question: I have a function that its job is generate a python class implicitly according
to the given name that pass throw the function. After that I want to create
field and method implicitly for the generated class too. I don't know how can
start it. Can someone help...


Answer: Do you really need a class? For "types" created at runtime, maybe namedtuple
would be a solution.

    
    
    from collections import namedtuple
    MyType= namedtuple("MyType", "field1 method1")
    x = MyType(field1="3", method1=lambda x: x+1)
    print x.field1, x.method1(3)
    

