On 2007-04-09, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
> i have 2 python files in *different directory* , how can I import
> python functions from 1 python file to another?
>
> i get this error:
> import task
> ImportError: No module named task/
>


The directory that module is in must by on your python
path in order to import it. You can do it by modifying
sys.path or by setting the PYTHONPATH env variable.


$ mkdir otherdir
$ cat > otherdir/amod.py
def afunc():
    return 'found'
$ python
>>> import amod
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named amod
>>> import sys
>>> sys.path.append('otherdir')
>>> import amod
>>> amod.afunc()
'found'
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to