PyCharm focus Python Console for input upon run

No for PyCharm there is no way to automatically focus the Python console for input when it is launched.

In Notepad ++ i can do the following.

  1. Enter my code
  2. press shift+a to execute a macro which saves the file and execute it with Python 2.7 (or 3). I also made this macro a menu item.
  3. When the console runs and the script asks for input you are already in focus and can directly put in our entry without having to click and highlight the window or so as it is necessary in PyCharm.

So the step between writing the code and executing it to see what it does exactly one hotkey. Its not one hotkey and a mouse click or what ever no.... its exactly one press of a button. This makes learning very effective because there are no detours.

I looked long in PyCHarm but i could not find this functionality or a workaround. So the answer to your question is "With PyCharm this is not possible."

Here is how to do it in Notepad ++.

  • Download Notepad ++
  • In N++ install the NppExec Plugin.
  • Create the "save and run in python" macro: In NppExec create a script as shown here:

    NPP_CONSOLE 0 
    npp_save 
    npp_run cmd /K C:\Python27\python.exe "$(FULL_CURRENT_PATH)"
    
  • Save your macro script as say "Save and run in Python Selfmade"
  • In the hotykeys menu assign your macro to a new hotkey.
  • In the Npp_Exec menu click on Advanced Options and create a menu entry for your macro. To do this select the script you created under "Associated Script" and then click on "Add/Modify"

Another editor that offers you this quick and direct run functionality is "Atom" with its many plugins.

Tags:

Python

Pycharm