Make ipython always execute command when I press return key?

谁说我不能喝 提交于 2019-12-10 10:49:33

问题


After migrating to ipython, I noticed that sometimes return key causes a line break instead of executing the command. For example if I have my cursor before ) in print(), it would result in:

print( )

How can I make it just run print() in this and other cases?


回答1:


This happens when you are in multiline mode, e.g.

In [200]: for i in range(3):
 ...:     print(i)
 ...:  

You either need to move to the end of the block (<end>) and return twice (or more if editing has accumulated a bunch of blank lines); or use <esc><return>.

It shouldn't happen in single line entry. Wrapped lines maybe. In any case the <end> and <esc> work. The extra key press is the cost of the multiline editing convenience.



来源:https://stackoverflow.com/questions/43070453/make-ipython-always-execute-command-when-i-press-return-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!