views:

48

answers:

3

Hello,

I have written a python script with methods in it. Now I want to use methods from that script in ipython. How do I import it for use in ipython?

Cheers

+2  A: 

If the file with your functions in it is called mod.py, just:

>>> import mod
>>> mod.myfunction()
djc
thanks works good!
pfdevil
djc
This requires that the module is locatable, it has to be either in the current directory or in PYTHONPATH. Hence the 'cd' in my answer. ;)
dash-tom-bang
A: 

Inside IPython:

cd folder/containing/module
import module
module.function(1, 2, 3)
dash-tom-bang
+1  A: 

There are several options and all of them work with specific advantages and disadvantages:

from module import *
import module
%edit module.py
WoLpH