[error] TypeError ( 'int' object is not callable )

Asked by arminius

centerX = 607
ml = Env.getMouseLocation()
total = ml.getX+centerX()
print total()

But I get the error message that is in the Summary, what does it mean by int?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

What is centerX - a function or an integer variable?
It it is an int, then you must not add brackets "()"
and the same for total.

Revision history for this message
arminius (arminius75) said :
#2

ok, I got rid of the brackets.
so now it's "ml = Env.getMouseLocation()
total = ml.getX+centerX
print ml.getX()
print total"

now it's returning "[error] TypeError ( unsupported operand type(s) for +: 'instancemethod' and 'int' )"

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

You need to get better in python basics.

You have to understand the difference between using variables (no brackets) and calling functions (need brackets).

Look at your code:
...
total = ml.getX+centerX
print ml.getX()
...
In the second line ml.getX has brackets, but in the first line it hasn't.
This cannot be correct in python syntax.

I assume the correct statements are

ml = Env.getMouseLocation()
total = ml.getX() + centerX
print ml.getX
print total

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#4

Oops, sorry, now I ommitted brackets, it must of course be

ml = Env.getMouseLocation()
total = ml.getX() + centerX
print ml.getX()
print total

Revision history for this message
arminius (arminius75) said :
#5

Thanks Manfred Hampl, that solved my question.