[python]Callable

J·2021년 6월 5일
0

python

목록 보기
11/11

what is python callable?

공식 설명은 아래와 같다.

Note that classes are callable (calling a class returns a new instance); instances are callable if their class has a __call__() method.

instances의 class가 call method를 가지면 callable하다.
callable 함수를 통해서 알 수 있다.

Example

class A:
  def __call__(self):
    return 'haha'

class B:
  pass

a = A()
b = B()

callable(a) # True
callable(b) # False

Reference

  1. https://docs.python.org/3/library/functions.html#callable
  2. https://jinmay.github.io/2019/12/03/python/python-callable/
profile
I'm interested in processing video&images with deeplearning and solving problem in our lives.

0개의 댓글