These are chat archives for ipython/ipython
$ ipython Python 3.7.0 (default, Jun 29 2018, 20:14:27) Type 'copyright', 'credits' or 'license' for more information IPython 7.0.1 -- An enhanced Interactive Python. Type '?' for help. In : def foo(): ...: x = 1 In :
x = 1
$ uname -a Darwin zag 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 21 20:07:39 PDT 2018; root:xnu-3789.73.14~1/RELEASE_X86_64 x86_64
@parmentelat You’re not doing anything wrong. There is a lot of discussion about how Enter should behave in IPython terminal (and lots of constraints). The default behavior seems to be—if the code can execute, then execute it. This behavior is customizable too, if you are willing to write some code in your configuration.
You can find more detail about this behavior here.
In the meantime, you can add a dummy line to your function (maybe
return None) and move your cursor above that line to add code inside the function. Hitting enter between the function
def line and the last line won’t execute the function. It’s not ideal, but its workable.