collections.OrderedDict

1. OrderedDict 란

명칭 그대로 삽입 순서가 보장되는 dictionary 형태의 컬렉션이다.

collections.namedtuple

1. namedtuple이란

명칭 그대로 index(idx)로만 값(value)에 접근 가능한 기본 튜플(basic Tuple)과는 다르게 키(key)값으로 접근이 가능하도록 제공한다. 키(namedtuple에서는 field_names)를 가지고 값에 접근이 가능한 점이 딕셔너리(dict)타입과 비슷하다 할 수 있다. namedtuple()에 대한 자세한 내용은 docs.python.org 에서 확인할 수 있다.

namedtuple()은 collections.namedtuple(typename, field_names, verbose=False, rename=False)을 입력값으로 받으며, field_names 를 통해 namedtuple()의 키 즉, 필드명(fieldname)을 정의할 수 있다. 필드명을 정의할 때에는 필드사이에 빈칸(whitespace)이나 ‘,’ 로 구분 해준다. 예를들어 필드명 x 와 y 를 지정할 경우 ‘x y’ 나 ‘x, y’와 같이 입력해야한다. 다른방법으로는 [‘x’, ‘y’]와 같이 리스트(list)형식으로 필드명을 지정해줄 수 있다.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×