로그인 바로가기 하위 메뉴 바로가기 본문 바로가기

데이터 구조 및 분석: Linear Structure and Dynamic Programming

임시 이미지 KAIST 산업및시스템공학과 문일철
http://kooc.kaist.ac.kr/datastructure-2019s/forum/12556
좋아요 1779 수강생 3366

파이참에 강의자료와 같은 코드를 실행했는데 자꾸 오류가 납니다.

입력한 코드와 오류를 첨부하겠습니다.


class Father(object):
strHometown = "Jeju"
def __init__(self):
print("Father is created")
def doFatherThing(self):
print("Father's action")
def doRunning(self):
print("Slow")

class Mother(object):
strHometown = "Seoul"
def __init__(self):
print("Mother is created")
def doMotherThing(self):
print("Mother's action")

class Child(Father, Mother):
strName = "Moon"
def __init__(self):
super(child, self).__init__()
print("Child is created")
def doRunning(self):
print("Fast")

me = Child()
me.doFatherThing()
me.doMotherThing()
me.doRunning()
print(me.strHometown)
print(me.strName)

Traceback (most recent call last):
File "C:/Users/Hyewon Park/Practice/uml1.py", line 25, in <module>
me = Child()
File "C:/Users/Hyewon Park/Practice/uml1.py", line 20, in __init__
super(child, self).__init__()
NameError: name 'child' is not defined