• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    해결됨

callable과 __call__ attribute

22.06.02 18:10 작성 조회수 146

0

안녕하세요.
callable 함수를 사용하면서 str에 __call__ attribute가 있는지 확인해봤습니다.
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
 
 
 
 
 
 
 
callable에서는 true인데 dir에서 __call__을 찾을 수 없는 이유를 알 수 있을까요?

답변 1

답변을 작성해보세요.

0

안녕하세요.

말씀하신대로 빌트인 함수인 str인 callable 한게 맞아여!

아래 링크에 그 이유가 있습니다.

https://docs.python.org/3/library/stdtypes.html#special-attributes-of-genericalias-objects

뤀쪼님의 프로필

뤀쪼

질문자

2022.06.03

아 제 질문은 str이 callable-> True라면, dir했을 때 "__call__" 항목이 있어야한다고 생각했는데, 막상 찾아보니 해당 항목을 찾을 수가 없어서 이해가 되지 않는다는 것이었습니다...