[Tutor] Question about importing
Alan Gauld
alan.gauld at btinternet.com
Wed Feb 3 00:21:48 CET 2010
"Grigor Kolev" <grigor.kolev at gmail.com> wrote
> Can I use something like this
> #--------------------------------------------------
> import sys
> sys.path.append("/home/user/other")
> import module
> #-------------------------------------------------
Yes but if you have a lot of modules in there that you might
want to use in other programs you might prefer to add the
folder to your PYTHONPATH environment variable. That
way Python will always look in that folder for your modules.
Thats what I do - I gave a folder whee I put all my reusable
modules. This folder is not under my Python install folder
so that when I install a new Python and delete the old I
don't lose my code... And the PYTHONPATH variable
works with the new Python.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list