我需要的是這樣的繼承內部類Python3
class Parent(object):
class Base(object):
def __init__(self, a, b):
self.a = a
self.b = b
class Derived(Base):
def __init__(self, a, b, c):
super(Derived,self).__init__(a, b)
self.c = c
def doit():
pass
parent = Parent()
derived = parent.Derived(x,y,z)
derived.doit()
當我嘗試運行它,我得到這個以下錯誤:NameError: name 'Derived' is not defined
我的「衍生」的地方試圖與「基地」在super()
- 沒有幫助
爲什麼要這樣做?嵌套有什麼意義? –
在「Parent」中聲明'Derived'會不會更好? –
你正在運行什麼python版本?超級().__ init__是不夠的? – user3012759