Dived a bit into the source code.
The output of sys.platform and os.name are determined at compile time. platform.system() determines the system type at run time.
sys.platformis specified as a compiler define during the build configuration.os.namechecks whether certain os specific modules are available (e.g.posix,nt, …)platform.system()actually runsunameand potentially several other functions to determine the system type at run time.
My suggestion:
- Use
os.nameto check whether it’s a posix-compliant system. - Use
sys.platformto check whether it’s a linux, cygwin, darwin, atheos, etc. - Use
platform.system()if you don’t believe the other sources.