Mercurial > cpython-lru_cache-weakref
changeset 71285:8bc9dbc61ba6 3.2
Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Also, point to the various alternatives.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Sat, 09 Jul 2011 15:54:23 +0200 |
| parents | ad9f54c993ae |
| children | 19b3b2d93a63 fc8b5c6a021c |
| files | Doc/library/os.rst Doc/library/sys.rst |
| diffstat | 2 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Doc/library/os.rst Sat Jul 09 10:58:37 2011 +0200 +++ b/Doc/library/os.rst Sat Jul 09 15:54:23 2011 +0200 @@ -61,6 +61,13 @@ 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:
--- a/Doc/library/sys.rst Sat Jul 09 10:58:37 2011 +0200 +++ b/Doc/library/sys.rst Sat Jul 09 15:54:23 2011 +0200 @@ -714,6 +714,12 @@ 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 @@ 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
