How to debug your Python code


I don’t know why pdb isn’t recommended in “Tips and Tricks” page (eg. you may (should) use it instead of code.interact() function.

I used code.interact() function in order to debug my code. But, as far as I could search the internet, I didn’t find a way to exit interactive shell and make blender continue running the game. Instead, I’m now using pdb.set_trace() function which lets me interrupt a game session, debug, change variables and then continue executing the game.

Hope this helps.

*** Moderation ***
moved from “Tutorials, Tips and Tricks”
because it is a discussion thread

You write about Blender coding but you mention a game.

Blender and the BGE are two different applications with two different ways of interacting with Python. We have a forum for Blender and we have a forum for BGE. Which one are you interested in?

I’m working on BGE, so yes, it’s probably a BGE related tip. Since a fairly equivalent function is mentioned in “Blender Tips and Tricks” page, I thought it is related to “Tips and Tricks” subforum. Anyway, if this thread belongs here, it belongs here. Thanks for the movement.

Indeed the “tips and tricks” page (not part of this forum) refers to Blender.

You can find threads explaining debug in the BGE resource forum. You are welcome if you want to post a tutorial there. If you want to discus, you can do this in the BGE discussion forum.