파이썬 TIP (8) 썸네일형 리스트형 collections > UserList UserList list 객체를 상속 받아 기능을 확장할 때 사용한다. 1. UserList를 상속하여 list를 생성 1) 클래스 생성 class MyList(UserList): def __init__(self, *args, **kwargs) : super().__init__(*args, **kwargs ) 2) 기능 테스트 mylist = MyList() mylist.append(1) mylist.append(2) mylist.append(3) mylist >> MyList([1, 2, 3]) mylist = MyList('mylist') mylist >> MyList(['m', 'y', 'l', 'i', 's', 't']) 2. 기능을 추가해서 확장 1) 클래스 생성 class MyList(User.. typing > type hint Type signature(annotation)는 파이썬에서 함수의 입력과 반환 타입을 명시적으로 하는 방법이다. tpye 1. 변수 아래 예시는 입력 x는 ndarray 타입이고, 반환 값도 ndarray 타입이다. import numpy as np from numpy import ndarray def add1(x:ndarray) -> ndarray: ''' ndarray타입 x 변수를 입력 받고 1을 더한 후 ndarray로 반환한다. ''' return np.add(x, 1) type2. 함수 아래 예시는 함수func과 x을 받고, ndarray 타입으로 반환한다. Callable은 ndarray 입력이 1개이고 ndarray로 1개 반환한다는 의미이다. from typing import Calla.. pip 설치 오류 (PEP 517) pip로 설치 시 다음과 같은 오류가 발생할 경우의 해결방법 ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly 아래 코드를 실행하면 해결 될 수 있다. !pip install --upgrade pip setuptools wheel !pip install opencv-python 이전 1 2 3 다음 목록 더보기