How to avoid step into built-in functions when debugging in PyCharm?

Viewed 203

For example:

df = load_dataset(os.path.join(os.path.dirname(dataset), "aclImdb"))

I don't want to debug dirname and join, since they are Python built-in functions, but only want to debug user defined functions like load_dataset.

Is there a way to control that in PyCharm?

1 Answers

It's possible to stop the debugger from stepping into library functions when you press Step into F7 bu going to File > Settings > Build, Execution, Deployment > Debugger > Stepping > Python and checking the option Do not step into library scripts.

(One alternative could also be using Step into my code Alt + Shift + F7).

As shown in the screenshot.

enter image description here

The following is a code example using only standard library that can be copied for testing

import os


def my_function():
    return 2


my_str = str(os.path.join(os.getcwd(), str(my_function())))

This screenshot shows using Step into F7 having Do not step into library scripts unchecked and Always do smart step into checked.

enter image description here

Notice the 3 setting options are interconnected, if you choose Do not step into library scripts together with Always do smart step into the IDE will still give you a choice to step into the library function. If you uncheck the later option the above example will automatically step into your function.

Related