Re: .pth files in working directory



On Wed, 31 Aug 2005 15:07:41 +0200
Peter Maas <peter@xxxxxxxxxxxxx> wrote:
> I want a tree
>
> top/
> install.py
> sub1/
> __init__.py
> mod1.py
> sub2/
> mod2.py
>
> where I can do "from sub1 import mod1" in mod2.py no matter what the
> absolute path of top is. To achieve this I start install.py once to
> retrieve the absolute dir of itself (= abspath of top/) and creates
> .pth files with its absolute dir in every subdirectory.

If top/ is the working directory for your Python interpreter, the
problem is solved automatically. Python puts the current working
directory in the default search path. So, if you run

python sub2/mod2.py

then it would work.

HTH,
-Michael
.



Relevant Pages

  • Re: Determine if path is absolute or relative
    ... even a simple file name could be called an absolute path.] ... It was you having a Q, Anthony, not me. ... size of the universe you are working in. ... Web Application I would call the path /mydir/subir/ an absolute path ...
    (microsoft.public.scripting.jscript)
  • Re: require_once() ... gone mad? !
    ... I am passing the fully qualified (i.e. absolute pathname) to a file that exists on my machine. ... I suspect you're missing the 'www' part in the absolute path. ... Now temporarily looking for some smaller PHP/MySQL projects/work to fund a self developed bigger project, mail me at rik at rwasmus.nl. ...
    (comp.lang.php)
  • hyperlinks - absolute path refuses to stay!!!!
    ... disk and run it off the disk, meaning any relative paths will not ... an absolute path into a hyperlink in excel is to manually go and look ... I know you can set a 'hyperlink base address' for all hyperlinks in the ...
    (microsoft.public.excel.misc)
  • Re: Saving Absolute Hyperlinks
    ... The terms absolute and relative ... hyperlinks were new to me although I use these forms ... Microsoft MVP - Excel ... > Could you please indicate me how to conserve the absolute path? ...
    (microsoft.public.excel.programming)
  • Re: Relative pathnames
    ... >to the email program's working directory, and all my file accesses fail. ... >Am I wrong to be using absolute paths? ... >at startup and then using this to create absolute file paths everywhere? ... Catherine Rees Lay ...
    (comp.lang.pascal.delphi.misc)