user1311286
user1311286

Reputation:

Python Error unsupported operand type(s) for /: 'instancemethod' and 'int'

I am receiving this error when trying to do division

   roomRatio = max(self.getRoomWidth(), self.getRoomHeight)/8
 TypeError: unsupported operand type(s) for /: 'instancemethod' and 'int'

getRoomWidth/Height() returns integer sizes of the room I am in.

Upvotes: 0

Views: 2385

Answers (1)

Dietrich Epp
Dietrich Epp

Reputation: 213368

You forgot ().

roomRatio = max(self.getRoomWidth(), self.getRoomHeight())/8
                                                       ^^

Note that in Python, you usually don't need setX() or getX() methods, because you can do this instead:

class MyClass(object):
    def getRoomWidth(self):
        ...
    def setRoomWidth(self, width);
        ...
    roomWidth = property(getRoomWidth, setRoomWidth)

And to use it,

self.width = self.width * 2

Upvotes: 3

Related Questions