[Tutor] HI, #Include like in python

wesley chun wescpy at gmail.com
Fri Mar 20 06:54:56 CET 2009


>    import listen
>
> You can use the __import__ function if you want, but generally you
> want the import statement as above.  The equivalent to 'import listen'
> is:
>
>    listen = __import__('listen')
>
> See the tutorial here: http://docs.python.org/tutorial/modules.html


you also have to make sure that your .py file is in one of the
folders/directories listed in sys.path (to see it, import sys then do
print sys.path). if the file is not in one of those folders, you will
also get an import error.

you can either add the correct directory to your PYTHONPATH
environment variable, or manually add it at run-time using
sys.path.append/insert.

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list