[Python] How to execute multi-line statements within Python's own debugger (PDB)

Discussão em 'Python' iniciado por Stack, Maio 10, 2025.

  1. Stack

    Stack Membro Participativo

    So I am running a Python script within which I am calling Python's debugger, PDB by writing:

    import ipdb; ipdb.set_trace()


    (iPython's version of PDB, though for the matter I don't think it makes a difference; I use it for the colored output only).

    Now, when I get to the debugger I want to execute a multi-line statement such as an if clause or a for loop but as soon as I type

    if condition:


    and hit the return key, I get the error message *** SyntaxError: invalid syntax (<stdin>, line 1)

    How can one execute multi-line statements within PDB? If not possible is there a way around this to still executing an if clause or a for loop?

    Continue reading...

Compartilhe esta Página