]> granicus.if.org Git - python/commitdiff
Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 9 Jul 2011 13:48:29 +0000 (15:48 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 9 Jul 2011 13:48:29 +0000 (15:48 +0200)
Also, point to the various alternatives.

Doc/library/os.rst
Doc/library/sys.rst

index c6e32f66a34f4dc124632127625e0947524e8fad..326215f69a7933ce2a636764468f09c97632faba 100644 (file)
@@ -53,6 +53,13 @@ Notes on the availability of these functions:
    names have currently been registered: ``'posix'``, ``'nt'``,
    ``'os2'``, ``'ce'``, ``'java'``, ``'riscos'``.
 
+   .. 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-procinfo:
 
index 305d477fbf27214c2bb7f06c68e62dbde22983e8..32ec03d539ffc10ed40187951e7a298dd776786b 100644 (file)
@@ -726,6 +726,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:
 
    ================ ===========================
@@ -740,6 +746,12 @@ always available.
    AtheOS           ``'atheos'``
    ================ ===========================
 
+   .. 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