Recent Post»

Recent Comment»

« 2024/12 »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
12-25 13:14

 

'isinstance'에 해당되는 글 1

  1. 2016.06.22 파이썬 내장 함수 : isinstance
 

파이썬 내장 함수 : isinstance

Python | 2016. 6. 22. 22:30 | Posted by 짱아
반응형

파이썬 내장함수 


isinstance(object, classinfo)
Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. Also return true if classinfo is a type object (new-style class) and object is an object of that type or of a (direct, indirect or virtual) subclass thereof. If object is not a class instance or an object of the given type, the function always returns false. If classinfo is a tuple of class or type objects (or recursively, other such tuples), return true if object is an instance of any of the classes or types. If classinfo is not a class, type, or tuple of classes, types, and such tuples, a TypeError exception is raised.

Changed in version 2.2: Support for a tuple of type information was added.


isinstance는 object가 classinfo의 인스턴스인지 점검 후 True / False 값을 리턴한다.

isinstance를 이용하여 object의 데이터 타입을 확인 할 수 있다.


>>>isinstance( "hello", str)

True

반응형
: