Hi,

I was working on an inheritance "tree" when I found that problem.
I have classA that is the base class of classB, and the classB is the base 
class of both classC1 and classC1.
                         classA
                             |
                        classB
                       /          \
               classC1       classC2

Each class is in a diferent module so, something like

moduleA.py
class ClassA(object):
    def __init__(self, name):
        print name

moduleB.py
import moduleA; reload(moduleA)

class ClassB(moduleA.ClassA):
    def __init__(self,name):
        super(ClassB, self).__init__(name)

moduleC1.py
import moduleB; reload(moduleB)

class ClassC1(moduleB.ClassB):
    def __init__(self,name):
        super(ClassC1, self).__init__(name)

moduleC2.py
Introducir código aquí...import moduleB; reload(moduleB)

class ClassC2(moduleB.ClassB):
    def __init__(self,name):
        super(ClassC2, self).__init__(name)


And this is when I get the # Error: TypeError: super(type, obj): obj must 
be an instance or subtype of type # 
import moduleA;
classA = moduleA.ClassA("foo")
import moduleB;
classB = moduleB.ClassB("foo")
import moduleC1; reload(moduleC1)
classC1 = moduleC1.ClassC1("foo")  # workd Ok at this point
import moduleC2;
classC2 = moduleC2.ClassC2("foo")

# this time if I do this, I get the error
classC1 = moduleC1.ClassC1("foo")
# Error: TypeError: super(type, obj): obj must be an instance or subtype of 
type # 


I have been reading all day about it. I have read that you should never 
user super(), then that you always should use super(), then that you should
never reload a module but I need to reload my module while I am 
developing... So I thought to ask here.

I guess my real question, besides the error which I can read more about it, 
is what is wrong with the design of that code.In this simple example to 
create this tree where class C1 and class C2 inherite from the same classB, 
what am I doing wrong?

Thank you

R


-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/004e7a43-f363-4407-adee-4aca3dfe518a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to