How do I assign integer or string values to dynamic classes in python

186 views Asked by At

I have a code in python which looks something like this:

def Make_My_Class():
    My_Class = type("My_Class", (object, ), { 

        "__init__": Callinit, 

        "My_Funct": Call_My_Funct, 
})

def Callinit(self):
    self.value=0

def Call_My_Func(self):
    self.My_Funct=foo
...

This works fine, but I can't for the life of me figure out how to get str(My_Class), int(My_Class) or print(My_Class) to give coherent results. Any help is appreciated!

0

There are 0 answers