클래스1 20.01.12 기록 1. 클래스 속성과 인스턴스 속성 클래스 속성 : 클래스 자체에 바로 선언된 속성 인스턴스 속성 : 각 인스턴스별로 따로 가지고 있는 속성 클래스 속성은 한 클래스에서 나온 모든 인스턴스가 공유하고 있다. 즉, class Person: feeling = [] def got_feeling(self, feel): Person.feeling.append(feel) #self.feeling.append(feel)와 같은 코드지만, 클래스 속성임을 조금 더 명시적으로 나타낸 것 alphaca = Person() alphaca.got_feeling(‘nice’) Beenzino = Person() Beenzino.got_feeling(‘good’) print(alphaca.feeling) #속성,메서드 이름을 찾는.. 2020. 1. 13. 이전 1 다음