[Q] ipython: Multiple commands on the same line and newlines

Phil Winder philipwinder at gmail.com
Sat Apr 16 15:55:43 CEST 2011

I'm having a go at using ipython as a command prompt for data
analysis. Coming from Matlab, I'm used to typing multiple commands on
the same line then using the up arrow to go through my history.
How can I write multiple python commands on the same line?
E.g. "x = 0; while x < 10: x = x + 1;" returns an "invalid syntax"
error on the 'e' in while.

Also, how can I produce a new line, without it running the command? I
would have expected a ctrl-enter or shift-enter to produce the
expected results.
E.g. I want:
"x = 0; <ctrl-enter>
while x < 10: <ctrl-enter>
    x = x + 1; <ctrl-enter>
" <enter to run>
It seems to work automatically for the "while xxx:", but combinations
of keys+enter do not work for "normal" lines.


More information about the Python-list mailing list