pycharm not suspend when calling a function from d

2019-07-10 03:17发布

问题:

Suppose I have the following python code:

import dummy

def run():
    print('Running calc() function')
    y = dummy.perform_very_long_calculation()
    out = calc(y) #BP1 is here
    print(out)

def calc(x):
    print('Calculating ...')
    return x+2 #BP2 is here

run()

The goal is to have this flow:

  1. Put a debug break-point ("BP1") on "out = calc(y)" line.
  2. Put a debug break-point ("BP2") on "return x+2" line.
  3. Run the module and stop on this "BP1".
  4. Call calc(y) from the interactive debug console.
  5. Stop on "BP2".
  6. debug calc()
  7. goto #4 and repeat, until I am pleased with calc()

The problem: item 5 is not working. The code is not suspended on "BP2".

My motivation: I want to call calc function until it is good. This way I can dubug calc again and again without calling it through run which take 20 seconds. I am very used to this kind of debugging flow from Matlab IDE and it is very convenience.

How can I make "BP2" stop?