A simpler more pythonic approach to adding in
- From: "rh0dium" <sklass@xxxxxxxxxxxxxxx>
- Date: 18 Jan 2006 14:38:29 -0800
Hi all,
I need a cleaner ( and shorter ) way to to look in my home directory or
any directory for a directory called modules. This is what I currently
have - but it is really ugly. Some a few of you experts point me to a
cleaner more pythonic approach?
mod = 0
if os.path.exists( os.environ['HOME'] + "/modules"):
sys.path.insert( 0, os.environ['HOME'] + "/modules")
mod =1
else:
path = os.environ['PWD']
while path != "/":
if os.path.exists( path + "/modules"):
sys.path.insert( 0, path + "/modules")
mod= 1
path = "/"
else:
path = os.path.split(path)[0]
if mod:
from foo import foo
.
- Follow-Ups:
- Re: A simpler more pythonic approach to adding in
- From: George Sakkis
- Re: A simpler more pythonic approach to adding in
- Prev by Date: Problem getting MoinMoin going
- Next by Date: Re: MSSQL LIKE and IN statements in ADO problem
- Previous by thread: Problem getting MoinMoin going
- Next by thread: Re: A simpler more pythonic approach to adding in
- Index(es):
Relevant Pages
|
|