The built-in function breakpoint() calls the Python Interactive Source Code Debugger.
This debugger features:
- Support the definition of conditional and single-pass interruption points at source.
- Inspection of stack frame.
- Source code listing.
- Arbitrary Python code evaluation in the context of any stack frame.
Running the example:
a = "teste"
breakpoint()
print(a)
When the interpreter finds the function breakpoint()
command line will switch to the shell of the interactive Python source debugger (Pdb)
> /home/runner/2608v0dh5c5/main.py(3)<module>()
-> print(a)
(Pdb) ▉
To know the list of available commands type on this command line h
or help
:
> /home/runner/2608v0dh5c5/main.py(3)<module>()
-> print(a)
(Pdb) help
Documented commands (type help <topic>):
========================================
EOF c d h list q rv undisplay
a cl debug help ll quit s unt
alias clear disable ignore longlist r source until
args commands display interact n restart step up
b condition down j next return tbreak w
break cont enable jump p retval u whatis
bt continue exit l pp run unalias where
Miscellaneous help topics:
==========================
exec pdb
(Pdb) ▉
To get a description of a specific command type help <nome_do_comando>
:
(Pdb) help next
n(ext)
Continue execution until the next line in the current function
is reached or it returns.
(Pdb) ▉
The elementary commands are:
p expressão
: Evaluates the expression expression in the current context and prints its value. Example:
(Pdb) p a
'teste'
(Pdb) ▉
(Pdb) whatis a
<class 'str'>
(Pdb) ▉
!declaração
: Executes a declaração
of a line. Example:
(Pdb) !a = "não é mais um teste"
(Pdb) p a
'não é mais um teste'
(Pdb) ▉
next
: Continue execution until the next line in the current function is reached or it returns. Example:
(Pdb) next
não é mais um teste
--Return--
> /home/runner/2608v0dh5c5/main.py(3)<module>()->None
-> print(a)
(Pdb) ▉
A full description of the commands available in the Python interactive source debugger is available in the online documentation.