티스토리 뷰
spi = ["NONE","Women","Wolf","Moster"]
class human:
def __init__(self):
self.name = "NONE"
self.age = 0
self.Species = "NONE"
def insert(self):
print "Input Normal method"
self.name = raw_input("NAME : ")
self.age = int(raw_input("AGE : "))
tmp = int(raw_input("1. Women, 2. Wolf, 3. Moster : "))
if tmp < 1 or tmp > 3:
tmp = 0;
self.Species = spi[tmp]
def __str__(self):
return "NAME : %s, AGE : %d, SPECIES : %s"\
%(self.name,self.age,self.Species)
class teacher(human):
def __init__(self):
human.__init__(self)
self.subjects = []
def insert(self):
human.insert(self)
self.subjects.append(raw_input("Subject : "))
def __str__(self):
return "%s\nSUBJECTS : %s"%(human.__str__(self),self.subjects)
def insertsub(self):
self.subjects.append(raw_input("Subject : "))
|
글자가 너무 긴 나머지, 자동으로 축소 기능으로 인해, 조금 작아 졌군...
상속에서는 상속 받은 클래스에서 부모 클래스의 기능을 저런 식으로 손쉽게 사용 가능하다.
human.__init__(self)
추가 되는 것만 따로 구현하면 상속은 그냥 끝
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- directive
- SVN
- angular
- 미래
- 브랜치
- 파이썬
- LightBox
- IE
- SSL
- 테스트
- Material
- Branch
- RUBY
- JS
- frontend
- RESTful
- 클라우드
- jQuery
- 테크노트
- ie11
- 개발자
- NG
- Ai
- technote
- Git
- Python
- vuejs
- SQL
- FLASK
- 전략
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함