Python Debugger Setup & Example
This details how to setup and use the Python debugger.
To get the debugger the debug mode should be enabled
thisSnippet database properties pythonBridgeSettings serverDebugMode: true. "After setting this, the server will need to be restarted" PBApplication stop.
If there are errors it can be useful to stop the Python server link:
To check that the python process is running in the right folder.
import os os.getcwd()
PythonBridge uses the python
exec() function to evaluate snippets. Breakpoints aren't supported directly in the
exec() script, so must be placed in a function, e.g.:
x = 40 pbbreak() x + 2
When you execute the code, you get a debugger window that shows you the python code. You can step over or run and the execution will continue and still produce the result.
And a factorial example that relies on an external file:
import tfactorial pbbreak() tfactorial.factorial(4,1)
The source code of
tfactorial can be found at:
GtResourcesUtility default resourceAtPath: Path * 'feenkcom'/ 'PythonBridge' / 'PythonBridgeRuntime' / 'PythonBridge' / 'tfactorial.py'