[파이썬 오류] "TypeError 'xxx' object is not callable" 무슨 뜻?
파이썬 코드를 실행함에 있어서 다양한 에러메세지를 만나게 되는데요,
'TypeError : ('Series'/'list'/'int' 등등..) object is not callable'
이와 같은 에러 메세지가 뜰 때가 있습니다. 여기서의 'callable'은 뭘 의미하고, 이 에러를 해결하려면 어떻게 해야 할까요?
python - What is a "callable"? - Stack Overflow
What is a "callable"?
Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, res...
stackoverflow.com
1. 'callable'의 뜻
말 그대로 call을 할 수 있는 객체라는 뜻입니다.
'not callable'이라는 에러가 떴다는 것은, 내가 callable 하지 않은 객체에 call을 했다는 뜻이 됩니다.
2. 'call' 방법
함수를 사용할 때처럼, 이름 뒤에 () 괄호를 붙이는 것으로 call 할 수 있습니다.
3. 'callable' 객체
그렇다면 call을 할 수 있는 것에는 무엇이 있을까요?
- 함수
- 메소드
- __call__ 메소드가 설정된 클래스 객체
따라서 문자열, 정수 등 일반적인 객체는 'call'을 할 수 없습니다.
4. 에러 해결 방법
괄호를 제거하면 됩니다.