How can I debug manually typed expression and statements in pdb?

后端 未结 2 1635
小蘑菇
小蘑菇 2021-01-12 09:39

In pdb (or ipdb) we can execute statements and evaluate expressions with the ! or p commands:

p expression
     Evaluate the

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 10:04

    With regards to your example, you don't need to exit pdb and change the code. You can step into the function (with 's') and set weekday_index=0 inside.

    One solution to your original problem is to use the debugger's jump command as follows:

    1. jump before the function call using 'j #line-number'
    2. step in the function with 's'
    3. set the input params, and continue debugging.

    This worked when I tried it, but the debugger complained when I tried to do step 3 before step 2 for some reason.

提交回复
热议问题