Run code in console without 'runfile'

Answered

I have currently updated PyCharm to v2018.2.4 (Professional). After updating, the behavior of the Run button has changed and I'd like to get it back to what it was.

Prior to updating, clicking on 'Run' would

  • Create a new Python console
  • Run my code in that console, as if I had copied-and-pasted the code onto it.
  • If an exception was raised, the code would stop there, and the control of the console would be passed back to me (assuming I had "Run with Python Console" enabled). Importantly, all variables defined prior to the exception would still be there.

After updating:

  • Instead of seeing my code, I see runfile("path/to/code.py")
  • If the code runs without issues, then after it finishes the control is passed back to me. All variables defined in the code are still defined.
  • If the code raises an Exception, then I see the error message and all variables are destroyed.

See the screenshots below. In the first one, `x` is still defined because the script ran without issues. In the second, neither `x` nor `y` are defined anymore.

This disrupts my workflow a lot, as I write a lot of code that is expected to break. Any help in choosing the correct configuration to get back to what I had before would be very much appreciated.

EDIT: Note that I do not want to copy and paste the code onto the console (e.g. using the Shift+Alt+E shortcut.) I'd like to have that done automatically, like previously.

 

 

 

3 comments

I have also run into the same problem 

3

Following this as I am dealing with the same issue 

2

Hi,

I have checked and it seams that this problem is resolved in 2018.3. Could you please also check it in latest EAP build? https://www.jetbrains.com/pycharm/nextversion/

0

Please sign in to leave a comment.