How Can I Determine the Operating System with Python?

Gerhard Häring gh_pythonlist at gmx.de
Thu Mar 21 06:53:46 EST 2002


* Mark Hadfield <m.hadfield at niwa.co.nz> [2002-03-21 14:02 +1200]:
> "Jill Obsidian" <obsidian_genius at yahoo.com> wrote in message
> news:cc779aae.0203201733.3717f882 at posting.google.com...
> 
> > How can I put a check in my script which will allow me to determine
> > whether I'm running on Windows or Linux at execution time?
> 
> >>> import sys
> >>> sys.platform
> 'win32'
> >>> import os
> >>> os.name
> 'nt'
 
That's a crude way of determining the platform, because sys.platform
depends on the compiler used to compile Python. Yes, even on Windows.
But I'm  reasonably sure that the Pythonlabs folks won't change their
Windows compiler anytime soon.

I'd very much like to have a real way for determining the platform.
Anybody wants to write a PEP? :-)

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 13.3 °C      Wind: 7.1 m/s




More information about the Python-list mailing list