TypeError: 'int' object is not callable

前端 未结 6 2160
深忆病人
深忆病人 2020-11-22 14:45

Given the following integers and calculation

from __future__ import division

a = 23
b = 45
c = 16

round((a/b)*0.9*c)

This results in:

6条回答
  •  甜味超标
    2020-11-22 14:57

    I was also facing this issue but in a little different scenario.

    Scenario:

    param = 1
    
    def param():
        .....
    def func():
        if param:
            var = {passing a dict here}
            param(var)
    

    It looks simple and a stupid mistake here, but due to multiple lines of codes in the actual code, it took some time for me to figure out that the variable name I was using was same as my function name because of which I was getting this error.

    Changed function name to something else and it worked.

    So, basically, according to what I understood, this error means that you are trying to use an integer as a function or in more simple terms, the called function name is also used as an integer somewhere in the code. So, just try to find out all occurrences of the called function name and look if that is being used as an integer somewhere.

    I struggled to find this, so, sharing it here so that someone else may save their time, in case if they get into this issue.

    Hope this helps!

提交回复
热议问题