본문 바로가기
BASIC

self

by 자동매매 2023. 11. 17.
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)

'BASIC' 카테고리의 다른 글

named tuple  (0) 2023.11.17
두점 사이 거리구하기  (0) 2023.11.17
추상 클래스  (0) 2023.11.17
메서드 탐색 순서  (0) 2023.11.17
메서드 오버라이딩  (0) 2023.11.17

댓글