-
python iteratorpython 기초 2023. 1. 23. 14:39728x90
python을 쓰다보니 자연스럽게 iterator를 활용하고 있었지만 (for 문 등에서)
어떤 개념인지 한번 정리가 필요했다
iterator는 iterable의 원소를 순서대로 호출하는 자료형이다. 위와 같이 iter로 선언할 수 있으며
next로 다음값을 호출해온다. (pnt++ 과 같은 느낌인데...)
같은 데이터에 대해서도 여러개를 선언해서 교차로 사용하는것도 가능하다. (pnt1 과 pnt2 가 따로 사용 가능하듯)
728x90'python 기초' 카테고리의 다른 글
python repr eval 사용 (0) 2023.01.24 type annotation (0) 2023.01.24 python generator (0) 2023.01.23 python closure / decorator (0) 2023.01.23 data type encoding - decoding (0) 2023.01.22