"Multiple inheritance"의 두 판 사이의 차이

(새 문서: ==Python== category: Python <source lang='Python'> class Lion: def socialize(self): print('socializing...') def cry(self): print('crying like Lion') cla...)
 
34번째 줄: 34번째 줄:
# crying like Tiger
# crying like Tiger
</source>
</source>
==같이 보기==
*[[inheritance]]

2014년 8월 22일 (금) 15:32 판


1 Python

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 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}