Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux - Linebreak in IPython

Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) "normal" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be the problem?

like image 484
ThreeCheeseHigh Avatar asked Apr 03 '12 10:04

ThreeCheeseHigh


2 Answers

I just came across a solution, posted by Kenneth Falck: IPython newlines with ^V^J

While editing a multiline code block use Ctrl+V CTRL+J

like image 110
Silvan Marco Fin Avatar answered Oct 22 '22 03:10

Silvan Marco Fin


If you want to do a line-break, you end the line with the \ escape character, same as you do in a Python file. Shift+Enter doesn't have any special meaning in ipython, and indeed most over places in the shell. It doesn't have special meaning in Python, either.

It does have special meaning in some text editors and word processors, most notably LyX and LibreOffice, and of course on some websites (through a web browser).

like image 25
cha0site Avatar answered Oct 22 '22 01:10

cha0site