TypeError: 'NoneType' object is not callable

Whoo hoo, I rock baby! I have finally implemented separate controls into my game! But here’s my problem: while I can attach animations to the keypress (the game program responds very well to it now since I have a python dictionary taken from the Code Snipplets part of the forum), the player goes through one loop of animation and then the game crashes. I have no idea what’s causing it or anything.

Here is the code from my Player libary (Pyro is the name of the player character, a sonic-inspired fox):

And here is my Error from the console window:

I am totally and completely lost here. I’ve tried other animation functions like ‘play’ or ‘accept’ for the keyboard, I’ve tried putting ‘loop()’ in different locations, only to get the same results. This is for Panda 1.0.5. Could anybody please help me here? I’ll be extrememly grateful. :smiley:

You have calls like this:


and this:


Where you probably meant to write this instead:


The difference is that, without the parens, you are passing the function to self.accept() or self.acceptOnce(), and the function is a callable object that the Messenger will call later when the event is generated. On the other hand, with the parens, you are calling the function on the spot, and passing the result of that call to self.accept() or self.acceptOnce()–since these functions don’t return anything in particular, the implicit return value is None. So you are passing None in to the messenger, and None is not a callable object. When the event is generated, the messenger attempts to call the None object you gave it, and generates the error message that you see.


Sorry I deleted my snipplet post. I made it in a hurry in response to a question about state controls, but it wasn’t very good and I didn’t think anyone was using it. I’ve changed to a more object-oriented approach. I’ll post the new snipplet and an example of its use.

drwr, thanks for the response, I’ve gotten my game to work correctly now. I also know why the console window kept giving me that error.
And Cyan, thank you too for your post. It really helped me get unstuck with control libraries. Cheers to your new one. :smiley: