Introduction - DOM API
Creating a document
Attributes and methods
Brython-specific built-in modules
Working with Brython
Testing, debugging and profiling
Interactive testThe Brythons site, or its mirror available for download, include a console where you can test Python code. Please note that the namespace is not refreshed when you click on "run", you must reload the page for that. For debugging and testing Brython, a number of test scripts are grouped in the directory
Debugging scriptsWhatever the debugging level, syntax errors are reported in the browser console (or at the place defined by
x = $a
generates the message
By setting the debugging level to 1 in the call to functionSyntaxError: unknown token [$] module '__main__' line 1 x = $a ^
x = [1, 2] xgenerates :
IndexError: list index out of range module '__main__' line 2 x
Debugging Python CodeA simple time-travel step back and forth debugger is implemented here As of this writing it is not full featured and supports only line step. You will find documentation on how each function in the debugger works (in case you want to build on it). Currently only python language specific programs are supported. The debugger does not fully support the input statements; only supporting input with a string literal for argument (more on this below).
rython_Debugger For DevelopersThe debugger provides 4 hooks (on_debugging_started, on_step_update, on_debugging_end, and on_debugging_error) which take a callback that you can decide to do whatever you want with. The way the debugger works in record mode (default) when you run
start the debugging session, takes code to debug as parameter as well as an optional boolean flag for whether to live debug or record. Currently live debug is not supported and debugging by default starts in record mode. TheBrython_Debugger.
function to call when you want to stop the debugging sessionBrython_Debugger.
This function when called steps forward one step in the recorded debugging sessionBrython_Debugger.
This function when called steps backward one step in the recorded debugging sessionBrython_Debugger.
check if you can step to the specified stepBrython_Debugger.
seek to a specific step in the recorded debugging session take a number from 0 to the last step as parameter. If a number larger than the last step is entered nothing will happenBrython_Debugger.
return whether a debugging session is activeBrython_Debugger.
returns whether this debugger is in recording modeBrython_Debugger.
returns whether the current step is the last stepBrython_Debugger.
returns whether the current step is the first stepBrython_Debugger.
return a number indicating the current stepBrython_Debugger.
returns the current frame/state (it should be state)Brython_Debugger.
returns all recorded statesBrython_Debugger.
The maximum number of steps executed before the debugger halts, default 10000Brython_Debugger.
object should contain the data you want paced later to the set_trace functiondo not use event names already used by the debugger add a trace call, (which will be called on step update) Brython_Debugger.
cb is called after debugging session has startedBrython_Debugger.
cb is called after debugging session has endedBrython_Debugger.
cb is called after either a syntax or runtime error occursBrython_Debugger.
cb is called whenever a state is changed using setState