[Python] How can I ignore a specific breakpoint interactively?

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    Consider this script:

    print("before loop")
    for i in range(100):
    breakpoint()
    print("after loop")
    breakpoint()
    print("exit")


    Short of pressing "c" one hundred times, how can you get past the breakpoint within the loop at L3 and proceed to L5?

    I've tried the ignore command, but I couldn't work it out:

    $ python3 example.py
    before loop
    > /tmp/example.py(2)<module>()
    -> for i in range(100):
    (Pdb) ignore 0
    *** Breakpoint 0 already deleted
    (Pdb) c
    > /tmp/example.py(2)<module>()
    -> for i in range(100):
    (Pdb) ignore 0
    *** Breakpoint 0 already deleted
    (Pdb) c
    > /tmp/example.py(2)<module>()
    -> for i in range(100):


    I want to execute the remainder of the loop, without tripping the breakpoint on L3 again, and then print "after loop" and break before printing "exit", remaining in the debugger. The answer must not require exiting the debugger and reentering the runtime, or modifying the source code.

    Continue reading...

Compartilhe esta Página