Reputation: 10689
I'm having some trouble with class inheritance in Python 3.1x that I am hoping to get some help with. I have a class called ClassA
and I am trying to create another class called ClassB
that inherits from ClassA
. Here is the code I've written:
from myfile import ClassA
class ClassB(ClassA):
def __init__(self):
super(ClassB, self).__init__()
When I try to create an instance of ClassB
I get this error:
>>> x = ClassB()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ClassB' is not defined
Which is my problem?
Upvotes: 0
Views: 125
Reputation: 798686
The problem is that you're not referring to what you've imported.
>>> import SomeModule
>>> x = SomeModule.ClassB()
Upvotes: 3