Python Forum
[PyGame] TypeError: unsupported operand type(s) for -: 'int' and 'instancemethod'
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] TypeError: unsupported operand type(s) for -: 'int' and 'instancemethod'
#4
A function defined in the class is already bound to the instance.  You call it just as you would any function, with parentheses.
>>> class Spam:
...   def __init__(self, foo):
...     self.bar = foo
...   def quz(self):
...     print("I'm an instance method!")
...     return self.bar
...
>>> thing = Spam(42)
>>> thing.quz()
I'm an instance method!
42
Reply


Messages In This Thread
RE: TypeError: unsupported operand type(s) for -: 'int' and 'instancemethod' - by nilamo - Oct-05-2017, 06:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] PLEASE HELP! TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int' keyfive 1 5,354 Jun-19-2018, 01:20 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020