Run part of code in a terminal Follow
Sometimes you want to run part of a larger script in a terminal.
Example:
foo=3
type(foo)
What is to do?
Copy the first line of the code manually into the clipboard >
Tools >
Terminal >
type: python >
Enter >
Paste clipboard >
Enter >
Copy the second line of the code manually into the clipboard >
Enter
Many steps.
Is there any way to handle that faster and easier?
And further:
Is there any terminal in PyCharm, which offers syntax highlighting?
Thanks for your help :)
Example:
foo=3
type(foo)
What is to do?
Copy the first line of the code manually into the clipboard >
Tools >
Terminal >
type: python >
Enter >
Paste clipboard >
Enter >
Copy the second line of the code manually into the clipboard >
Enter
Many steps.
Is there any way to handle that faster and easier?
And further:
Is there any terminal in PyCharm, which offers syntax highlighting?
Thanks for your help :)
Please sign in to leave a comment.
PyCharm has special console for Python - it is located at: Tools | Python console. There you have syntax highlighting and with it you can execute parts of your scripts with 'Execute selection in console' action (Ctrl+Shift+E).
I selected
foo=3
type(foo)
Than I choosed 'Execute selection in console' from the context menu.
But the result isn't
<class 'int'>
as it appears, when you enter code manually.
Does 'Execute selection in console' only works for single lines only?
The shortcut is Alt+Shift+E on Windows.