How Can I Determine the Operating System with Python?

Cliff Wells logiplexsoftware at earthlink.net
Thu Mar 21 13:14:35 EST 2002


On Thu, 21 Mar 2002 13:42:03 GMT
ingo wrote:

> in news:mailman.1016713720.31917.python-list at python.org Mark Gash
> wrote: 
> 
> > The only way of defining the os name that I have found is then to
> > examine the os.environ .By examining the COMSPEC you will be able to
> > determine a win 9X machine opposed to an NT or 2000 machine (comspec
> > for 9X will show command.com whereas win32 machines will show
> > cmd.exe). 
> > 
> 
> >>> os.environ['OS']
> 'Windows_NT'
> 
> No idea what it does on other platforms.

It depends upon whether the environment variable "OS" is present, so it's
probably less reliable than sys.platform (doesn't exist on RH Linux, at
least).

-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308




More information about the Python-list mailing list