[FRPythoneers] import question

Jim Vickroy Jim.Vickroy at noaa.gov
Wed Dec 5 13:25:37 MST 2001


Even when running on MS Windows, the forward slash '/' may be used to separate
subdirectories.  For example:

   sys.path.append('/python/piece1')

also works and may be preferable.

Alternately, use os.sep (from the os module) which is mapped to backward slash on
MS Windows.

Sean Reifschneider wrote:

> 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
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers




More information about the FRPythoneers mailing list