问题
When I am building a function in python, using spyder, the function object is not working properly.
e.g.,
def first_order(y,t):
tau=5
After introducing the 2nd line it automatically closes the function. How can I change this behavior?
It used to be like this
def first_order(y,t):
> tau=5
...: (first Enter, creates a new line)
(second Enter, to close the function)
回答1:
Spyder uses IPython in its interactive console. What you report is a bug in IPython 7.0, so the cleanest solution is to upgrade to IPython 7.1.
As a stop gap measure, if your platform doesn't provide 7.1 yet, you can use the key-chord Ctrl-o
(instead of Return
) to open a new line below the second line of the function definition and move there using the cursor key — after this maneuver the situation will be normal for the rest of the function definition.
Update
I knew that Spyder uses IPython, I didn't knew that it uses it via the qtconsole
and the bug I described was still not fixed in 7.1 qtconsole
(thank you Carlos Cordoba for pointing out).
The reason why OP has a problem still stands as valid, I fear that we have to wait 7.2 to have a fix for the qtconsole
because the ad interim solution that I've described doesn't work in qtconsole
回答2:
(Spyder maintainer here) This is a bug in the Qtconsole package and it'll be fixed in its 4.4.3 version, to be released today.
来源:https://stackoverflow.com/questions/53223311/function-object-in-spyder-not-working-properly