January 18, 2025

After version Python3.7, you can set Break Point on your script.

There is the breakpoint as primitive python function on your environment.

from typing import List

def mysum(intlist: List[int]):
    total = 0
    for n in intlist:
        total += n
        breakpoint()


if __name__ == '__main__':
    mysum(range(100))

you can continue your script if you set “c” and you can get variables if you set “p {variable name}”.

For example,

> /home/kevin/project/test/test-python/test.py(5)mysum()
-> for n in intlist:
(Pdb) n
> /home/kevin/project/test/test-python/test.py(6)mysum()
-> total += n
(Pdb) n
> /home/kevin/project/test/test-python/test.py(7)mysum()
-> breakpoint()
(Pdb) n
> /home/kevin/project/test/test-python/test.py(5)mysum()
-> for n in intlist:
(Pdb) n
> /home/kevin/project/test/test-python/test.py(6)mysum()
-> total += n
(Pdb) n
> /home/kevin/project/test/test-python/test.py(7)mysum()
-> breakpoint()
(Pdb) n
> /home/kevin/project/test/test-python/test.py(5)mysum()
-> for n in intlist:
(Pdb) n
> /home/kevin/project/test/test-python/test.py(6)mysum()
-> total += n
(Pdb) p total
3