diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-09 13:54:23 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-09 13:54:23 (GMT) |
commit | a83cdaae89b9565bd3c6f78c14a23befcac24e76 (patch) | |
tree | 8e1261c0f6e60cbedd7e5d67c87c14cdcaebb4dd /Doc/library | |
parent | 00ebeb540f48cf22878f82f274a82df36b01fda8 (diff) | |
download | cpython-a83cdaae89b9565bd3c6f78c14a23befcac24e76.zip cpython-a83cdaae89b9565bd3c6f78c14a23befcac24e76.tar.gz cpython-a83cdaae89b9565bd3c6f78c14a23befcac24e76.tar.bz2 |
Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Also, point to the various alternatives.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/os.rst | 7 | ||||
-rw-r--r-- | Doc/library/sys.rst | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index c412ee1..5c84e85 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -61,6 +61,13 @@ Notes on the availability of these functions: names have currently been registered: ``'posix'``, ``'nt'``, ``'mac'``, ``'os2'``, ``'ce'``, ``'java'``. + .. seealso:: + :attr:`sys.platform` has a finer granularity. :func:`os.uname` gives + system-dependent version information. + + The :mod:`platform` module provides detailed checks for the + system's identity. + .. _os-filenames: diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index ae2dbf3..95dc662 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -714,6 +714,12 @@ always available. For Unix systems, this is the lowercased OS name as returned by ``uname -s`` with the first part of the version as returned by ``uname -r`` appended, e.g. ``'sunos5'`` or ``'linux2'``, *at the time when Python was built*. + Unless you want to test for a specific system version, it is therefore + recommended to use the following idiom:: + + if sys.platform.startswith('linux'): + # Linux-specific code here... + For other systems, the values are: ================ =========================== @@ -726,6 +732,12 @@ always available. OS/2 EMX ``'os2emx'`` ================ =========================== + .. seealso:: + :attr:`os.name` has a coarser granularity. :func:`os.uname` gives + system-dependent version information. + + The :mod:`platform` module provides detailed checks for the + system's identity. .. data:: prefix |