开发者

Creating python subclass issue

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 '开发者_如何学JAVAClassB' is not defined

Which is my problem?


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

>>> import SomeModule
>>> x = SomeModule.ClassB()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜