Eike Welk wrote:
On Tuesday February 2 2010 20:28:03 Grigor Kolev wrote:
Can I use something like this
#--------------------------------------------------
import sys
sys.path.append("/home/user/other")
import module
#-------------------------------------------------


Yes I think so. I just tried something similar:
--------------------------------------------------


IPython 0.10 -- An enhanced Interactive Python.

<------- snip -------->

In [1]: import sys

In [2]: sys.path.append("/home/eike/codedir/freeode/trunk/freeode_py/freeode/")

<------- snip -------->
<------- The next line is a special command of IPython: ---------------->

In [8]: !ls /home/eike/codedir/freeode/trunk/freeode_py/freeode/
ast.py pygenerator.pyc test_1_interpreter.pyc test_pygenerator.pyc ast.pyc simlcompiler.py test_2_interpreter.py test_simlcompiler.py __init__.py simlcompiler.pyc test_2_interpreter.pyc <------- snip -------->


In [9]: import simlcompiler
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

/home/eike/<ipython console> in <module>()

/home/eike/codedir/freeode/trunk/freeode_py/freeode/simlcompiler.py in <module>()
     36 import stat
     37 from subprocess import Popen #, PIPE, STDOUT
---> 38 import pyparsing
     39 import freeode.simlparser as simlparser
     40 import freeode.interpreter as interpreter

ImportError: No module named pyparsing


----------------------------------------------------------
Well... the import fails, but it finds the module and starts to import it.

HTH,
Eike.



I have no idea what freode looks like, but I have a guess, based on your error messages.

I'd guess that you want to append without the freeode directory:


    sys.path.append("/home/eike/codedir/freeode/trunk/freeode_py/")

and import with it. That's because freeode is a package name, not a directory name (I can tell because __init__.py is present)
         import freeode.simlcompiler

See if that works any better.

DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to