Unsupported operand type?! Cmon!

Now I was making a gravity system and just multiplied the self.jump value
(wich is outside the function and is equal to 0)
jump = 0


So now it says:

TypeError: unsupported operand type(s) for *: ‘instancemethod’ and ‘float’

What the hell is wrong with multiplying?

to answer your question: the thing that’s wrong is the type of inputvalues.
the python interpreter clearly says this in his error message.

self.jump seems to be a method of an incstance. the python interpreter would have a hard time to multiply this with an float value.
did you define a function named jump() somewhere? did you intend to call it and forgot the () after the self.jump? did you overwrite a value you specified before?

well “self.jump” is not a function it only depends on a variable named “jump” and is equal to 0 but its kinda weird because I didn’t do anything at all with that variable and it still is complaining about a float value. I haven’t even got a float value. The variable is right inside a class and is no instance of one.

you can do

print type( self.jump) , type(globalClock.getDt())

to see which of the 2 is the non-float.

Makkura, you must keep in mind that if you create a function called "jump’, it is a variable too - overwriting any other variable that might be called that way. So, give the variable or function a different name.

You could also be inadvertently assigning a function-value to your jump variable. Any time you make an assignment involving the output of a method, but forget to include the () on the method, the variable will take the method itself as its value. E.g.

self.jump = player.getY

self.jump now has the getY method as its value. This means


would return an invalid operation error, but


would actually give you player.getY()-2 in height.