1

If I open the Pycharm IDE, go to "tools" and select "Python Console", and copy and paste

a=1
b=1
c=1

into the console, how do I execute this? If my cursor is at the end of the script (i.e., placed after c=1), I can just hit enter and it works. But the script will not execute if the cursor is placed on one of the first two lines. Hitting Enter only adds a new line between a=1 and b=1. Shift+Enter doesn't work either. Does anyone know how to execute the code without worrying if the cursor is at the very end of the script?

1

2 Answers 2

4

To run source code from the editor in console:

  1. Open file in the editor, and select a fragment of code to be executed.

  1. On the context menu of the selection, choose Execute selection in console, or press Ctrl+Alt+E:

origin link

Sign up to request clarification or add additional context in comments.

4 Comments

Be careful! on the Shift-Alt-E picture but in reality Ctrl+Alt+E
both work for me. But sometimes I get a weird behaviour where an unwanted "recent locations" window appears (see: intellij-support.jetbrains.com/hc/en-us/community/posts/…). Does that ever happen to you?
somehow the window stopped showing up once I did right click and ran the code using the menu...though, not sure if that's a permanent solution...
Possible, different OS has system hotkeys, which differ in Linux and MacOS. Perhaps, this is such a case.
1

Alt + Shift + E to execute current line in console

2 Comments

Thank you! Is there a way to execute all lines simultaneously in a similar way?
Just select lines you want to execute and press Alt + Shift + E

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.