"TypeError 'int' or 'float' object is not callable"

Last edited on

If you get an error message like one of these:

TypeError: 'int' object is not callable
TypeError: 'float' object is not callable
TypeError: 'str' object is not callable

It probably means that you are trying to call a method when a property with the same name is available. If this is indeed the problem, the solution is easy. Simply change the method call into a property access.

For example, if a line like this causes an error message like one of those above:

width = widget.width()

Try changing the line to this:

width = widget.width