티스토리 뷰
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
- 미래
- SQL
- SSL
- frontend
- Python
- vuejs
- 클라우드
- angular
- FLASK
- NG
- RESTful
- JS
- 전략
- directive
- technote
- IE
- LightBox
- Material
- 브랜치
- SVN
- Branch
- ie11
- 개발자
- Ai
- Git
- 테크노트
- 파이썬
- RUBY
- 테스트
- jQuery
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함