pythonvisual-studio-codedebuggingparameters

Is it possible to modify the 'Step Into' functionality of the python debugger not to iterate the lines with the function parameters?


Let's say I am working on the following python code:

def f(a,
      b,
      c,
      d):
    print(1)
f(a=1, # breakpoint
  b=2,
  c=3,
  d=4)

After hitting the breakpoint when I try to 'Step Into' the body of the function f then instead of stopping in the line with print(1) I get moved to the line with the parameter b. I would like to store the parameters in the separate lines for the sake of code readability but in the same time the necessity of stepping into multiple time every times I reach a function call while debugging is cumbersome.

Is there a way to modify the 'Step Into' so that it goes directly to the body of f (if I want to iterate the lines with parameters I can always use 'step over')?

I am aware that one could run 'continue' and then 'step into' but this make it tricky since if the function call is in just one line then 'continue' makes us jump to the next breakpoint, which may be undesirable.

One could try to 'step into' once then 'continue' and 'step into' again but it takes 3 actions, which seems suboptimal.


Solution

  • When function calls are distributed across multiple lines, the "Step Into" function initializes each parameter step by step. Unfortunately, most debuggers don't have a built-in way to jump directly to the body of the function if the arguments are separated by lines.

    I suggest you trying formatting. Combine them on one line when debugging, and use formatting tools to split the parameters into separate lines after debugging to improve code readability.