My use case is I want to initialize some functions in a file and then start up ipython with those functions defined. Is there any way to do something like
i
Update to @Caleb's answer for Python 3.5 in Ubuntu 14.04: Made this answer self contained by copying relevant parts of @Caleb's answer.
You can use ipython profiles to define startup scripts that will run every time you start ipython. A full description of profiles, is given here. You can create multiple profiles with different startup files.
Assuming you only need one profile, and always want the same startup files every time you start ipython, you can simply modify the default profile. To do this, first find out where your ipython configuration directory is in an ipython session.:
Input:
import IPython
ipython_config_dir = IPython.paths.get_ipython_dir()
print(ipython_cofig_dir)
Output:
/home/johndoe/.ipython
For this example johndoe
is the username.
Inside the /.ipython
folder, the default_profile is in the profile_default
subdirectory. Put any starting scripts in profile_default/startup. In the example here, the full path would be
/home/johndoe/.ipython/profile_default/startup