ThreeCheeseHigh
ThreeCheeseHigh

Reputation: 1498

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?

Upvotes: 8

Views: 7625

Answers (3)

Silvan Marco Fin
Silvan Marco Fin

Reputation: 171

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

Upvotes: 17

cha0site
cha0site

Reputation: 10717

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).

Upvotes: 7

Marcin
Marcin

Reputation: 49816

Nothing is the problem. Python code is executed line-by-line.

If your code does not work when executed line-by-line, it should not work when loaded from a file (assuming in both cases a "clean" environment).

Upvotes: 4

Related Questions