Pycharm: run only part of my Python file

FrankTheTank picture FrankTheTank · May 3, 2014 · Viewed 119k times · Source

Is it possible to run only a part of a program in PyCharm?

In other editors there is something like a cell which I can run, but I can't find such an option in PyCharm?

If this function doesn't exist it would be a huge drawback for me... Because for my data analysis I very often only need to run the last few lines of my code.

Answer

Willian Adamczyk picture Willian Adamczyk · Jul 19, 2017

I found out an easier way.

  • go to File -> Settings -> Keymap
  • Search for Execute Selection in Console and reassign it to a new shortcut, like Crl + Enter.

This is the same shortcut to the same action in Spyder and R-Studio.