The %pylab
magic in IPython imports a bunch of functions into the user's workspace, which is very convenient. Looking at the code, it's not at all obvious how this is done. What I have so far is a magic function in my startup folder:
from IPython.core.magic import register_line_magic
@register_line_magic
def import_my_functions(line):
"""
Import functions into namespace somehow....
e.g. import numpy as np
"""
It then should be possible:
In[1]: %import_my_functions
imported the following:
numpy as np
.....
In[2]: np
Out[2]: <module 'numpy' from ..../venv/lib/python2.7/site-packages/numpy/__init__.pyc'>
Bonus would be if the command also reloads changed modules.