티스토리 뷰

python 에서 현재의 변수가 list 인지 dictionary 인지 등, 변수의 type 을 알고 싶을 때가 있다.

그럴때 isinstance() 를 사용하면 된다.

http://code.activestate.com/lists/python-list/56087/

예를 들면, {} 가 dict type 인지 알고 싶다면

isinstance({}, dict)

이런식으로 하면 된다.

 

 

isinsatnce() 에 관한 document 이다.

http://docs.python.org/library/functions.html

댓글