Pycharm: run only part of my Python file

2019-01-16 09:58发布

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.

4条回答
该账号已被封号
2楼-- · 2019-01-16 10:23

You can select a code snippet and use right click menu to choose the action "Execute Selection in console".

查看更多
\"骚年 ilove
3楼-- · 2019-01-16 10:26

I found out an easier way. Enter the Settings and go to 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.

查看更多
神经病院院长
4楼-- · 2019-01-16 10:28

Pycharm shortcut for running "Selection" in the console is ALT + SHIFT + e

For this to work properly, you'll have to run everything this way.

enter image description here

查看更多
The star\"
5楼-- · 2019-01-16 10:29

You can set a breakpoint, and then just open the debug console. So, the first thing you need to turn on your debug console:

enter image description here

After you've enabled, set a break-point to where you want it to:

enter image description here

After you're done setting the break-point:

enter image description here

Once that has been completed:

enter image description here

查看更多
登录 后发表回答