본문 바로가기
Python

self

by 자동매매 2026. 1. 29.
class AdvancedList(list):
    def replace(self, old, new):
        while old in self:
            self[self.index(old)] = new


x = AdvancedList([1, 2, 3, 1, 2, 3, 1, 2, 3])
x.replace(1, 100)
print(x)

 

'Python' 카테고리의 다른 글

메서드 오버라이딩  (0) 2026.01.29
super()  (0) 2026.01.29
정적 메서드 / 클래스 메서드  (0) 2026.01.28
특수 메서드  (0) 2026.01.28
비공개 속성 사용하기  (0) 2026.01.26

댓글