summaryrefslogtreecommitdiffstats
path: root/Doc/library/sys.rst
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-07-09 13:48:29 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-07-09 13:48:29 (GMT)
commitea901ad2c6207f44bf1f5b99abfaf349e0ca2145 (patch)
tree72c2b21fe6058effe6fb0c238e347609559a90c9 /Doc/library/sys.rst
parent4a4a0fed0797b641d2a980cc1b8ef4c77bbae9b5 (diff)
downloadcpython-ea901ad2c6207f44bf1f5b99abfaf349e0ca2145.zip
cpython-ea901ad2c6207f44bf1f5b99abfaf349e0ca2145.tar.gz
cpython-ea901ad2c6207f44bf1f5b99abfaf349e0ca2145.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/sys.rst')
-rw-r--r--Doc/library/sys.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 305d477..32ec03d 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -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