728x90

객체가 클래스의 하위 인스턴스 인지 여부를 확인하는 Method.

 

ex)

 

isinstance(1, int)  -> True 반환 ( 1은 int 클래스의 인스턴스이므로)

 

isinstance(1.4 , string) -> False 반환 (1.4는 string 클래스의 인스턴스가 아니므로)

 

마찬가지로 

 

test=Test()

 

isinstance(test, Test) -> True

 

https://sonseungha.tistory.com/509

 

[python] isinstance

isinstance() 의 설명은 아래와 같습니다. Return whether an object is an instance of a class or of a subclass thereof. A tuple, as in isinstance(x, (A, B, ...)), may be given as the target to check ag..

sonseungha.tistory.com

 

 

728x90

+ Recent posts