bpo-31928: DOC: Update sys.version_info references to reflect named tu…#4239
bpo-31928: DOC: Update sys.version_info references to reflect named tu…#4239csabella wants to merge 1 commit intopython:masterfrom
Conversation
| is ``(2, 0, 0, 'final', 0)``. The components can also be accessed by name, | ||
| so ``sys.version_info[0]`` is equivalent to ``sys.version_info.major`` | ||
| and so on. | ||
| A :class:`~collections.namedtuple` containing the five components of the |
There was a problem hiding this comment.
version_info is not a collections.namedtuple. It is a named tuple. collections.namedtuple implements named tuple interface, but not all named tuples are collections.namedtuple.
Just add the word "named" before "tuple".
| All values except *releaselevel* are integers; the release level is | ||
| ``'alpha'``, ``'beta'``, ``'candidate'``, or ``'final'``. The | ||
| ``version_info`` value corresponding to the Python version 3.6.3 is | ||
| ``(major=3, minor=6, micro=3, releaselevel='final', serial=0)``. The |
There was a problem hiding this comment.
(major=3, minor=6, micro=3, releaselevel='final', serial=0) looks too verbose. And this is not a valid Python syntax. If you want to expose repr(sys.version_info), you should add sys.version_info at the start and make it yet more verbose.
The current writing looks better to me. This is a tuple of version_info components. It is common to compare version_info with a tuple.
if sys.version_info < (3, 7):
...| ``sys.version_info(1, 8, 0, 'final', 0)``, whereas ``sys.version_info`` | ||
| would be ``sys.version_info(2, 7, 2, 'final', 0)``. For CPython they | ||
| are the same value, since it is the reference implementation. | ||
| ``sys.version_info(major=1, minor=8, micro=0, releaselevel='final', serial=0)``, |
There was a problem hiding this comment.
The current writing LGTM. sys.version_info(1, 8, 0, 'final', 0) is not a repr, this is a constructor. sys.version_info(major=1, minor=8, micro=0, releaselevel='final', serial=0) looks too verbose.
There was a problem hiding this comment.
Sorry, I thought it should look the way it is in the console when sys.version_info is typed. I didn't realize it was a constructor. I'll withdraw the PR.
…ple format.
https://bugs.python.org/issue31928