How do I change a value while debugging python with pdb?

前端 未结 2 1014
别跟我提以往
别跟我提以往 2021-02-07 07:46

I want to run pdb, step through the code, and at some point change the value pointed at by some name. So I might want to change the value pointed at by the name \'stationLat\'

相关标签:
2条回答
  • 2021-02-07 08:10

    Actually, the value of the variable does get changed when you assign a new value in pdb. But if you try to read the variable in pdb again without running your code, it may reset to the original value.

    If you step back into your code, you should see that it will use your new value (-40).

    Try this:

    stationLat = -40
    s # step back into code
    stationLat # should display -40
    
    0 讨论(0)
  • 2021-02-07 08:33

    This appears to be a bug in Python 2.6. You should be able to do this in Python 2.7.

    0 讨论(0)
提交回复
热议问题