How Can I Determine the Operating System with Python?
Skip Montanaro
skip at pobox.com
Wed Mar 20 20:58:46 EST 2002
Jill> How can I put a check in my script which will allow me to
Jill> determine whether I'm running on Windows or Linux at execution
Jill> time?
Check the value of sys.platform:
Python 1.5.2 (#1, Nov 27 2000, 02:23:30) [GCC 2.95.2 19991024 (release)] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> sys.platform
'sunos5'
vs.
Python 2.3a0 (#4, Mar 11 2002, 21:35:57)
[GCC 3.0.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.platform
'linux2'
--
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
More information about the Python-list
mailing list