Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython 5, key for executing block of code instead of inserting new line

Tags:

python

ipython

The "Enter" key in new IPython versions (5+) inserts a line break instead of executing the current block of code (e.g. inside a function definition); to execute the code block you have to navigate the cursor to the last line and then hit "Enter". In older version hitting "Enter" would directly execute the block. How can we execute the current code from the current cursor location without navigating to the end?

The following image shows what I mean, the curser is at the end of the line b=20, I want to execute this block of code without having to navigate the cursor to the end of the next line. Is there a way to achieve this?

enter image description here

like image 244
CentAu Avatar asked Nov 24 '16 16:11

CentAu


2 Answers

Alt + Enter or Esc + Enter execute the current code block, regardless of cursor position.

like image 120
Andy Avatar answered Sep 17 '22 23:09

Andy


Esc + Enter execute the block of code.

like image 34
Matthew Avatar answered Sep 18 '22 23:09

Matthew