[Baypiggies] Locating the directory you are executing from

Aahz aahz at pythoncraft.com
Sun May 4 22:15:29 CEST 2008


On Sun, May 04, 2008, Jeff Younker wrote:
> 
> I have a set of development scripts.  The scripts can potentially
> be executed from many places.  They reference information which is
> relative to their installation paths.  (These are build scripts.)
>
> The CI system can supply a fixed root, but when run by the developers
> I'd like them to be runnable from anywhere in the project, and still
> have them work.

If you're willing to require that the script directory NOT be on the
path, just do some manipulation of sys.argv[0].  Otherwise, __file__ is
the right approach.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Help a hearing-impaired person: http://rule6.info/hearing.html


More information about the Baypiggies mailing list