How to tell if you're running on windows?

Ross Ridge rridge at csclub.uwaterloo.ca
Fri Dec 4 14:50:26 EST 2009


Roy Smith  <roy at panix.com> wrote:
>The real problem I'm trying to solve is whether to build a LIBPATH
>environment variable with ';' or ':' delimiting the entries.  On the
>cygwin build, os.pathsep returns ':', which isn't really correct.  If
>you use that, you end up building paths that look like c:foo:c:bar.
>It should be c:foo;c:bar

What application is intepretting this LIBPATH environment variable?  If
it's another Cygwin app then ":" should be the correct seperator and you
should be building paths that look like "/cygdrive/c/foo:/cygdrive/c/bar".

I normally use the "os.name" variable to detect whether the script is
running on Windows, but the Cygwin version of Python sets it to "posix".
That works for me, since Cygwin tries hard to look like a Unix-type
operating system, my scripts should too.  In your case you can use
the "sys.platform" variable to distinguish between Cygwin and a real
Unix-type OS.  You may end up needing to treat Cygwin as a special case.

					Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge at csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  



More information about the Python-list mailing list