Reputation: 1498
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
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
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
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