Running a file, with a relative filename

Phil Hunt philh at vision25.demon.co.uk
Thu May 13 18:33:50 EDT 1999


In article <926371468snz at vision25.demon.co.uk>
           philh at vision25.demon.co.uk "Phil Hunt" writes: 
> I want to run a python program, where one module causes another Python
> module to execute, where the pathname of the second module is known 
> relative to the first module.
> 
> i.e. I have:
> 
>    ~/project/dev/xxx/prog1.py
>    ~/project/dev/xxx/prog2.py
> 
> And:
> 
>    ~/project/live/yyy/prog1.py
>    ~/project/live/yyy/prog2.py

Oops, mistake there. I should have said:

Ý 
Ý    ~/project/dev/xxx/prog1.py
Ý    ~/project/dev/yyy/prog2.py
Ý 
Ý And:
Ý 
Ý    ~/project/live/xxx/prog1.py
Ý    ~/project/live/yyy/prog2.py

Is there a way of saying ``import "../yyy/prog2.py"''?


> (The reason for this is that I have separate development and live 
> versions of the project, and the development version of prog1 wants
> to run the development version of prog2, and the live version of
> prog1 wants to run the live version of prog2).
> 
> prog2.py typically contains constants for the progject, e.g:
> 
>    nntpServer = "news.demon.co.uk"
> 
> etc. The constants will typically be different on the live and
> development versions.
> 

-- 
Phil Hunt....philh at vision25.demon.co.uk





More information about the Python-list mailing list