I can make a synthetic class cls1 that inherits from cls.
>>> class cls(object):
... def func(self,arg):
... print 'func',arg
>>> def func1(self):
... print "func 1 of cls1"
>>> def func2(self):
... print "func2 of cls1"
>>> d=dict(func1=func1,func2=func2)
>>> cls1=type('cls1',(cls,),d)
Everything works as expected:
>>> obj=cls1()
>>> obj.func(7)
func 7
I can also replace cls1 with FOO:
>>> cls1=type('FOO',(cls,),d)
that gives me:
'cls1': <class '__main__.FOO'>,
Does this (changing __name__ variable) alter the behavior of cls1 and how (everything still works fine)?
You’re just changing the name of your class, so it should matter only if you rely on the name somehow:
That works fine, but what about pickling (that I think rely on the name) ?
For example, before the name change, you can pickle
objwithout any problem. You can’t afterwards.