Last active
February 12, 2017 13:54
-
-
Save zeraf29/1cbb2dabd4123cd1a970adaaff1073d2 to your computer and use it in GitHub Desktop.
Python Class example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person(): | |
def __init__(self, name): | |
self.name = name | |
# __init__()은 클래스 생성자(초기화) | |
# __init__()은 모든 클래스 정의에서 선언할 필요는 없음 | |
# __init__()을 정의할 떄 반드시 첫번째 매개변수는 self | |
#__init__()을 정의할 때 첫 번째 매개변수는 self | |
hunter = Person('Tester Kim') | |
print('The mighty hunter: ', hunter.name) | |
#Person 클래스 정의 찾음 | |
#새 객체를 메모리에 초기화(생성) | |
#객체의 __init__ 메서드 호출 새롭게 생성된 객체를 self에 전달하고 인자를 name에 전달 | |
#객체의 name값을 저장 | |
#새로운 객체 반환 | |
#hunter에 이 객체 연결 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment