How Can I Determine the Operating System with Python?
David Eppstein
eppstein at ics.uci.edu
Thu Mar 21 14:27:20 EST 2002
In article <mailman.1016735254.27977.python-list at python.org>,
Cliff Wells <logiplexsoftware at earthlink.net> wrote:
> > >>> 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).
Another one where os.environ['OS'] doesn't exist:
>>> import sys
>>> sys.platform
'mac'
>>> import os
>>> os.environ
{}
>>> os.name
'mac'
Not sure how you're supposed to distinguish Classic from Darwin...
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list