How to debug python in blender ?

Hi all, I will be brief for my bad English, there was any way to do that? thanks

if you look at my code, like C3D Import, you will see I set up a debug variable based on the RT: setting in the Anim panel. Then, I have a debug function that prints a message if the variable is > some provided level. Throughout the code, I do a Debug(90,“Variable Var is %i” % var) which encodes the variable into the string, and then passes it to debug. Debug prints the message to the console if the RT is set, in this case to a value >= 90. The idea is that low values give you basic start-end info, whereas high values give you more insight into what is going on.

how to debug python in blender? simple, run ur game and check the terminal for any errors.

You could probably use the python debugger pdb:

how to debug python in blender? simple, run ur game and check the terminal for any errors.

shudder not a great way to debug any kind of complex program.

Debug print statements are always good though :slight_smile:

I use the Programmer’s Notepad for windows. It is a free open source editor for multiple languages.

When I get errors in my script, the Blender console will generate a line number. The Programmer’s Notepad allows you to see the line numbers and you can quickly find the line of code that has the error. It also detects if the file has been modifed by another program (i.e. Blender itself) and offers to reload to “re-synch” the code. This is very usefull, because I’ll use often make the code change in the Blender text window, so an ALT-S to save it, then Programmer’s Notepad detects that save and pops up a dialog to re-synch.

It is a shame the internal Blender text editor is so lame. Considering there are several open source colorized editors out there, I’m not sure why SciTe has not been integrated into Blender. It just makes sense?

For debugging you really want to get a stack trace and be able to view the parameters, not just the line. Simple programs, or simple errors, this works fine but a proper debugger can save you a lot of time.

There are improvements going on in the text editor to allow plugins. It’s already looking pretty good. No link at hand but it wqas on blendernation.

PapaSmurf and lipsonfire, I will be check about yours say , but reality, the issue is more complex, exactly as says “IanC” would need to see the parameters of the functions and variables, for example, when I start in c++, I learn quickly because, I can to view the parameters and verified the behaviour of their different types created, about python, I want to find ways to do the same, but with classes and libraries of blender properly, check the behaviour of a array of vertices according to a function, or behavior of a mesh through a mathematical equation etc.

Atom, thank you, regarding what you say about the text editor, there is information that here " "
the coder is the Student Ian Thompson

IanC, thank you very much for the tip, I will be check it carefully, this may be the way that i need, thank to the all,


Thanks for the BlenderNation link. I had heard about a colorized editor project a few versions ago, but now as we look at 2.47 we still see that it is not a reality.

I guess I spoke too soon.

I didn’t try it yet