Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-line editing broken in IPython 7.0.1

I'm using IPython in zsh shell and I'm having a trouble defining a function with multiple lines.

For example, in the original Python shell, I can define a function f like this:

>>> def f(x):
...     a = x + 1
...     return a
... 
>>>

When I did it in IPython, the defination ends immediately when The line 'a = x + 1' ends. It looks like this:

In [4]: def f(x): 
   ...:     a = x + 1                                                                                                                              

In [5]:   

How can I fix it by changing some configuration or installing another version of IPython?

My version of Python and IPython:

Python 3.5.6 |Anaconda, Inc.|  
Type 'copyright', 'credits' or 'license' for more information
IPython 7.0.1 -- An enhanced Interactive Python. Type '?' for help.
like image 745
shb Avatar asked Oct 12 '18 08:10

shb


1 Answers

It's a known bug (see also this).

As it's clear from the issues I've referenced, it's not a bug with the Anaconda distribution but something that slipped into the 7.0 release of IPython.

Matthias Bussonier suggested to use C-o (that is Control o) as a stop gap measure. C-o opens new blank lines below the current line that you can reach and edit using the arrow keys — it's not a very satisfactory solution but for now there is no other solution (except, of course, downgrading IPython to 6.x).

Concluding, use C-o to open new lines and wait for a bug fix or downgrade to IPython 6.x.


Additional Info

Carlos Cordoba, one of the Spyder maintainers, in a comment to an answer of mine says that also the qtconsole is affected by this bug...

Moreover the bug, fixed in the IPython 7.1 shell, is still present in the same version of qtconsole and the stop-gap measure I've mentioned (Ctrl-o to open a line below the current one) does not work in qtconsole.

like image 120
gboffi Avatar answered Oct 07 '22 06:10

gboffi