[FRPythoneers] import question

Sean Reifschneider jafo at tummy.com
Wed Dec 5 13:16:51 MST 2001


On Wed, Dec 05, 2001 at 01:12:50PM -0700, Sherman Lambert wrote:
>to segregate scripts into different directories.  However I have yet to
>figure out how to import scripts not in the current path, or the python
>path.  I am using python on Win 9x.  I thought that I could just give the

Python searches the PYTHONPATH to locate modules.  I have a common
directory where I put my python modules.

>path to the import statement. however that does not seem to work.  I detail
>I have a project in \project, I am trying to reference a script in
>\python\piece1.  Any clues (this should be simple, shouldn't it?).

You can change the PYTHONPATH in your code:

   import sys
   sys.path.append('\\python\\\piece1')
   import piecemodule

Sean
-- 
 Blaming the software quality on the tool is like saying "I can't pick up
 chicks because my car isn't cool enough."  -- Sean Reifschneider, 1998
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python



More information about the FRPythoneers mailing list