views:

31

answers:

2

I want IPython or the Python interpreter to auto-load a module when I start them.
Is it possible?

For example when I start IPython:

$ ipython

...

>>> from __future__ import division
>>> from mymodule import *

In [1]:

Something like this.

Thanks!

+2  A: 

Check the file ~/.ipython/ipythonrc - you can list all modules you want to load at the startup.

eumiro
Thank you! Now I check it.
rubik
+2  A: 
Have a .pythonstartup in your home directory and load modules there 
and point PYTHONSTARTUP env to that file.

Python commands in that file are executed before the first prompt is displayed in interactive mode.

I use it for enabling command line completion in python interpreter shell

pyfunc
Thank you too! But now how can I choose two accepted answer??
rubik
@rubik: @eumiro: eumiro answered first and his answer is unique and my answer works too. Accept eumiro's answer.
pyfunc
Ok, thank you again
rubik