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?
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.
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!
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With