0

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?

ROMANIA_engineer
57.1k30 gold badges211 silver badges207 bronze badges
asked Oct 2, 2011 at 22:07

1 Answer 1

3

The problem is that you're not referring to what you've imported.

>>> import SomeModule
>>> x = SomeModule.ClassB()
answered Oct 2, 2011 at 22:12
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.