win32api... another question: GetEnvironmentVariable("PATH")

Gordon McMillan gmcm at hypernet.com
Mon Nov 15 17:33:49 CET 1999


Kevin Cazabon wrote:

> Interesting... it doesn't work on Win98 for me (The exact statement
> below...).
> 
> Anyone have suggestions for Win95/98?
> 
> 
> Kiss, Arpad <AKiss at GEOMETRIA.hu> wrote in message
> news:01BF2F61.1D2B8DB0 at exchange1.geometria.hu...
> > Hi,
> >
> > Kevin Cazabon <kcazabon at home.com> wrote in message
> > news:<fcMX3.65012$Rx2.773564 at news1.rdc1.bc.home.com>...
> > > I can't seem to get the win32api.GetEnvironmentVariable() function to
> > work
> > > properly... am I not using it correctly by the following?
> > >
> > > path = win32api.GetEnvironmentVariable("PATH")
> >
> > It works for me on a Windows NT Workstation (sp5).

First, why not use os.environ['PATH']?

Second, while I'm on NT and 'PATH' and 'path' return the same 
answer (both the os and the win32api way), I had a bug report 
from someone on Win9x and the solution turned out to be:
 try:
   value = os.environ[key]
 except KeyError:
   value = os.environ[string.lower(key)]



- Gordon




More information about the Python-list mailing list