More elegant way to cwd?

Kamilche kamilche at kamilche.com
Tue Dec 28 02:53:55 EST 2004


> Other than using os.pardir instead of '..', and possibly adding
> an "os.path.abspath()" call to the last bit (or does realpath
> already do that?  It's unclear from the docs), I can't see
> anything fundamental I'd do differently... except package these
> functions up as nice clean subroutines, possibly in a library
> package, that I could then use in code that would magically
> become "elegant" (IMHO) by avoiding the repetition of all
> that non-elegant stuff above...
> 
> -Peter

Well... but to call it from the shared directory, I'd have to first 
switch to the shared directory! Which would defeat the purpose.

I wish there was a way to store this in a single file and call it from 
any script, but I'm unwilling to keep all my scripts in one folder to 
accomodate it. If only Python would let you import modules from 
different directories. :-/

--Kamilche



More information about the Python-list mailing list