강의

멘토링

커뮤니티

Inflearn Community Q&A

qwer42479617's profile image
qwer42479617

asked

Free Python Tutorial (Basic) - Become a Developer in 6 Hours

StarCraft Project Second Half

어떨때는 def __init__(self) 만 적고 어떤때는 def__init__(self,name,hp, 등등) 이런식으로 적는데

Written on

·

231

2

혹시 저렇게 나누는 기준이 있을까요?

Unit 클래스를 상속 받을때요!

python

Answer 2

1

qwer42479617님의 프로필 이미지
qwer42479617
Questioner

Unit 클래스를 상속 받을 때, Unit 클래스에는 name, hp, damage 정보가 있다고 치면

def__init__(self) 만 쓰는 경우엔, Unit 클래스의 name, hp, damage가 변수로 저장된 값이 아닐때 사용 하는 것이고

def__init__(self,name,hp,damage) 라고 써주는 경우엔 Unit 클래스의 name, hp, damage가 변수로서 적용이 될때.

맞나요?

0

머지 자기가 질문하고 자기가 답변하는뎅?

qwer42479617's profile image
qwer42479617

asked

Ask a question