On Jun 9, 3:28 pm, Emile van Sebille <em...@fenx.com> wrote: > On 6/9/2009 3:00 PM rh0dium said... > > > > > > > I have a .pth file which has some logic in it - but it isn't quite > > enough... > > > It started with this.. > > import os, site; site.addsitedir(os.path.join(os.environ["TECHROOT"], > > "tools/python/modules")) > > > But that eventually evolved into.. > > import os, site; site.addsitedir(os.path.join(os.environ.get > > ("TECHROOT", "/home/tech"), "tools/python/modules")) > > > But now I want to check to make sure this directory exists or fall > > back to "/home/tech". That was the point of the environ.get but what > > if someone sets TECHROOT to /dev/null. Well that will break > > things... I tried this but no go. Can someone help me out.. > > You're not really putting all this on one line are you? If so, that's a > problem. > > > import os, site; smsc = os.environ.get("TECHROOT", "/home/tech"); if > > not os.path.isdir(smsc): smsc = "/home/tech"; site.addsitedir > > (os.path.join(smsc, "tools/python/Linux/%arch/lib/python2.5/site- > > packages")) > > Try it this way... > > import os, site > smsc = os.environ.get("TECHROOT", "/home/tech") > if not os.path.isdir(smsc): > smsc = "/home/tech" > site.addsitedir (os.path.join(smsc, > "tools/python/Linux/%arch/lib/python2.5/site-packages")) > > Emile > > > > > Apparently there is a problem with the if statement??? > > > Thanks
No for .pth files this needs to be on a single line.. -- http://mail.python.org/mailman/listinfo/python-list