기본 콘텐츠로 건너뛰기

[matplotlib] 등고선(Contour)

[python] 리스트와 튜플 자료형과 내장메서드(built-in method)

특별메서드의 종류

자료형 리스트와 튜플은 그 자체가 클래스입니다. 그 자료형에 따라 내장된 내장 메소드(built-in method, 특별메서드)와 속성은 다음과 같습니다.

메서드리스트튜플내용
x.__add__(y) x와 y의 연결(concatenation)하여 새로운 객체 생성
x.__iadd__(y) x += y 연결(concatenation), x가 연결된 객체로 변경(in-place concatenation)
x.append(e) x의 마지막 요소로 e를 첨가, e의 자료형 유지
x.clear() x의 모든 요소 삭제, 빈 객체 x는 존재
x.__contains__(e)e in s
x.copy() 요소가 리터럴일 경우 깊은복사, 컬렉션일 경우 얕은복사
x.count(e)요소의 발생횟수
x.__delitem__(p) 인덱스 p의 값을 삭제
x.extend(x) x의 마지막 요소로 e를 첨가, e 자료형은 숫자형 또는 문자형, 즉, 리터럴로 변환
x.__getitem__(p) 인덱스 p의 요소를 반환
x.__getnewargs__() Support for optimized serialization with pickle
x.index(e) 객체 x에서 e의 첫번째 인덱스를 반환
x.insert(p, e) 인덱스 p에 e를 삽입
x.__iter__()Get iterator
x.__len__() 객체 x의 크기=len(x)
x.__mul__(n) x * n—repeated concatenation
x.__imul__(n) x *= n—in-place repeated concatenation
x.__rmul__(n)n * s—reversed repeated concatenationa
x.pop([p]) Remove and return last item or item at optional position p
x.remove(e) Remove first occurrence of element e by value
x.reverse() Reverse the order of the items in place
x.__reversed__() Get iterator to scan items from last to first
x.__setitem__(p, e) s[p] = e—put e in position p, overwriting existing item
x.sort([key], [reverse]) Sort items in place with optional keyword arguments key and revers

댓글