Running code in PyCharm's console

night_bat picture night_bat · Feb 2, 2014 · Viewed 21.3k times · Source

Are there any smooth way to run Python scripts in the PyCharm's console?

My previous IDE - PyScripter - provides me with that nice little feature. As far as I know PyCharm has 2 ways of running script in console: 1) Select a bunch of code and press Ctrl+Alt+E. 2) Save the code in a file and import it from the Console.

Are the any way to do it by pressing "Run" or "Debug" buttons? I need to see the result of my script in the console and all variables available to manipulate.

Answer

Patrick picture Patrick · Mar 13, 2014

In the Run/Debug Configuration, add -i to the interpreter options. This will stop it from closing a python session even after a successful run. I.e. you will be able to see all the variable contents