Multiple inheritance

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:31 판 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)


1 Python[ | ]

Python
Copy
class Lion:
    def socialize(self):
        print('socializing...')
    def cry(self):
        print('crying like Lion')

class Tiger:
    def swim(self):
        print('swimming...')
    def cry(self):
        print('crying like Tiger')

class Liger(Lion, Tiger):
    pass

class Tion(Tiger, Lion):
    pass

l = Liger()
l.swim()
l.socialize()
l.cry()
# swimming...
# socializing...
# crying like Lion

t = Tion()
t.cry()
# crying like Tiger

2 같이 보기[ | ]