본문 바로가기

전체 글258

Comprehending Lists으로 Generator 만들기 + 깊복,얕복 Generator 란 # Generator : 한 번에 한 개의 항목을 생성(메모리 유지X) 왜 쓸까? 메모리 공간 절약 반복자는 인스턴스화될 때 각 항목의 값을 계산하지 않습니다. 그들은 당신이 그것을 요청할 때만 그것을 계산합니다. 이것을 지연 평가 라고 합니다. 지연 평가는 계산할 데이터 세트가 매우 큰 경우에 유용합니다. 전체 데이터 세트가 계산되는 동안 데이터 사용을 즉시 시작할 수 있습니다. 왜쓸까 출처 : https://www.freecodecamp.org/news/how-and-why-you-should-use-python-generators-f6fb56650888/ dataSet이 아주 큰 경우에는 모든 data를 읽어오는데 시간이 너무 오래 걸리므로 필요한만큼 필요한부분만 꺼내 쓰는게 .. 2022. 4. 1.
파이썬 자료형 정리 파이썬 자료형 정리 # 컨테이너(Container : 서로다른 자료형[list, tuple, collections.deque], # vs Flat : 한 개의 자료형[str,bytes,bytearray,array.array, memoryview]) [ 1, 'a', 'asd'] vs 'hello' # 가변(list, bytearray, array.array, memoryview, deque) # vs 불변(tuple, str, bytes) list_a[0] = 33 가능함 그래서 가변 tuple_a[0] = 33 X 불변 strA = 'abcdefu' , strA[0] = A X 불변 그렇담 불변을 바꾸려면 어캅니까!? 불변의 data를 가변에 넣어주고 수정해서 써먹으면 됨 방법 예시 짧게 #ord는 아.. 2022. 4. 1.
List Comprehension 리스트 컴프리헨션 +(딕셔너리 + 튜플) https://wikidocs.net/22805 1) 리스트 컴프리헨션 ## 리스트 생성하기 기존에 배운 문법으로 1부터 10까지 정수를 순서대로 가지고 있는 리스트를 생성하는코드는 다음과 같습니다. ``` numbers = [] for ... wikidocs.net 참고 정리 : 람다식마냥 리스트 한줄로 만드는 거임 기본원리 1. 2. 3. 다중for문 + 리스트 컴프리헨션 ;; 다중 if문 + 리스트 컴프리헨셔ㅑㄴ ;; [ ] 이거로 닫으면 List로 생성 ( ) 이거로 닫으면 generator로 생성 튜플컴프리헨션은 필요없다 왜냐면 리스트컴프리헨션으로 만들고 튜플로 형변환하면됨 https://wikidocs.net/92540 참고 2022. 4. 1.
매직 메소드_네임드튜플 https://www.tutorialspoint.com/namedtuple-in-python Namedtuple in Python Namedtuple in Python The NamedTuple is another class, under the collections module. Like the dictionary type objects, it contains keys and that are mapped to some values. In this case we can access the elements using keys and indexes. To use it at first we www.tutorialspoint.com 정의 : 네임드Tuple은 Collections 모듈 아래에 있는 다른 클래스입니.. 2022. 4. 1.
매직 메소드_오퍼레이터같은 https://docs.python.org/3/reference/datamodel.html 3. Data model — Python 3.10.4 documentation A class can implement certain operations that are invoked by special syntax (such as arithmetic operations or subscripting and slicing) by defining methods with special names. This is Python’s approach to operator overloading, allowing classes to define docs.python.org what is python special method doc.. 2022. 3. 31.
객체vs인스턴스vs클래쓰 & 인스턴스메서드vs클래스메서드vs스태틱메서드 https://dojang.io/mod/page/view.php?id=2380 파이썬 코딩 도장: 35.3 클래스 메서드 사용하기 이번에는 정적 메서드와 비슷하지만 약간의 차이점이 있는 클래스 메서드를 사용해보겠습니다. 클래스 메서드는 다음과 같이 메서드 위에 @classmethod를 붙입니다. 이때 클래스 메서드는 첫 번째 dojang.io 객체 vs인스턴스 vs 클래쓰 블로그 https://cerulean85.tistory.com/149 인스 클래스 스태틱 메서드 설명 블로그 https://journeytosth.tistory.com/73 참고 lion = Animal() class method를 삭제 하기도 가능함 참조 사이트 : https://pynative.com/python-class-meth.. 2022. 3. 31.