Using ipython 0.11 if I type a function definition, like
def f(s): print s
then I can use that function in that ipython session, but I don’t know how to define that
in the ipython_config.py file.
If I just type the function definition in the file and try to use the function it it undefined.
Any idea?
Two answers here:
First, for super simple functions like the one above, you can define them in
exec_lines, e.g.:(you can define arbitrarily complex functions this way, but it gets annoying beyond a couple of lines)
For more complicated code, you can write a script that you would like to run at startup, and add that to the
exec_fileslist:We realized this is slightly annoying, so in 0.12, there will be a startup folder in profile directories, and anything you put in there will be run automatically. This is essentially adding an extra
glob.glob('*.py')to exec_files (which you can do yourself in 0.11, of course).