Question:
I tried to write simple class factory using the “type” method. I called myclass_factory twice and It returned identical namespaces (case1 and case2). But the values of myclass attribute in that namespaces were different (!). Actualy it just what I need but I can not undestnad why I got that result. For my udestanding, since case1 and case2 are not objects but just same namespace (<class ‘main.MyClass’>) they should refer to the same memory and should be case1.myclass = case2.myclassPlease explain how It could be so?
Answer:
Actually case 1 and case 2 are objects since you instantiate them. They are type objects and thus ordinary python objects. So you create two different type objects.also see this answer: Link to answer
Also see This description
If you have better answer, please add a comment about this, thank you!