[Python] 고급 - Dict 및 Set(2) - Sequence(4)
Immutable Dict # immutable Dictfrom types import MappingProxyTyped = {'key1': 'value1'}f = dprint('f = d : ', d is f, d == f) # is 는 id 가 같은지 확인, == 는 값이 같은지 확인print('value & id: ', d, id(d))print('value & id: ', f, id(f))print()# Read Only(Immutable Dict 생성)d_frozen = MappingProxyType(d)print(d, id(d), type(d))print(d_frozen, id(d_frozen), type(d_frozen))print(d is d_frozen, d == d_frozen) # is..
[Python] 고급 - 리스트 및 튜플(2) - Sequence(2)
컨테이너 타입 자료형(Container : 서로다른 자료형[list, tuple, collections.deque], a = [3, 3.5, 'a'] # 서로 다른 자료형, 컨네이너 타입 자료형 Flat : 한 개의 자료형[str, bytes, bytearray, array.array, memoryview])한개의 자료형만 저장, 빠름, 자연어 처리, 숫자, 이산, 회계분석, 기상데이터 등 단일 형태의 연산 가변(list, bytearray, array.array, memoryview, deque)불변(tuple, str, bytes)Unpacking # Tuple Advanced# Unpacking# b, a = a, bprint(divmod(100, 9))print(divmod(*(100, 9)))p..
[Python] 고급 - 리스트 및 튜플(1) - Sequence(1)
컨테이너 타입 자료형(Container : 서로다른 자료형[list, tuple, collections.deque], a = [3, 3.5, 'a'] # 서로 다른 자료형, 컨네이너 타입 자료형 Flat : 한 개의 자료형[str, bytes, bytearray, array.array, memoryview])한개의 자료형만 저장, 빠름, 자연어 처리, 숫자, 이산, 회계분석, 기상데이터 등 단일 형태의 연산 가변(list, bytearray, array.array, memoryview, deque)불변(tuple, str, bytes) # 지능형 리스트(Comprehending Lists)# Non Comprehending Listschars = '+_)(*&^%$#@!~)'code_list1 = []f..
[Python] Magic Method(1)
워밍업 # 참조 : https://docs.python.org/3/reference/datamodel.html#special-method-names# 클래스 안에서 정의할 수 있는 특별한(built-in) 매소드, 파이썬에 이미 정의된 함수들임.# 기본형 - 모두 클래스입니다.print(int)print(float)# # # 모든 속성 및 메소드 출력print(dir(int))print(dir(float))# ['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floord..