Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run A Section Of Code In PyCharm?

Tags:

pycharm

I am moving from R to Python and have been loving PyCharm for it's similarities to my beloved RStudio. However, someone I can't seem to figure out how to do is run a selection of code in a script.

Is there any way to do this?

like image 336
Anton Avatar asked Dec 03 '13 21:12

Anton


People also ask

How do I run multiple lines of code in PyCharm?

In the IPython-based interactive console in PyCharm, pressing Shift + Enter creates a new line below the current one and moves the caret to it, while Ctrl + Enter splits the line at the current caret position.

How do I run a line of code in Python?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World! If everything works okay, after you press Enter , you'll see the phrase Hello World!

How do you run a line of code?

The usual approach is to set a Breakpoint at the line you wish to examine (click on the line number, to the left of the code), then press F9. Execution will stop at your line of code (or before, if there is an execption). Then press F7 to execute the line of interest.


1 Answers

You can select the code you want to run, right-click, and select 'Execute Selection in Console'. The keyboard shortcut for this is ALT+SHIFT+E on Windows

like image 64
Kewl Avatar answered Oct 27 '22 06:10

Kewl