May 2018
Beginner to intermediate
452 pages
11h 26m
English
As you've seen so far, there are certain situations where you simply can't avoid writing platform-specific code, either because a high-level library is unavailable or because the actions that need to be performed are fundamentally different.
In this case, it becomes necessary to detect the platform. There are a few ways of doing this in Python, including os.system() and sys.platform, but the platform module contains the best set of functionality for determining the OS details most useful in making decisions.
We'll mostly rely on the system() function, which returns a string identifying the operating system: Windows, Linux, freebsd7, or Darwin (for macOS).
Some other useful functions include ...