Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d65d73

Browse files
committed
Document hexversion (incompletely explained) and version_info (easily
explained).
1 parent 801c08d commit 4d65d73

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Doc/lib/libsys.tex

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,28 @@ \section{\module{sys} ---
138138
(temporary) reference as an argument to \function{getrefcount()}.
139139
\end{funcdesc}
140140

141+
\begin{datadesc}{hexversion}
142+
The version number encoded as a single integer. This is guaranteed to
143+
increase with each version, including proper support for
144+
non-production releases. For example, to test that the Python
145+
interpreter is at least version 1.5.2, use:
146+
147+
\begin{verbatim}
148+
if sys.hexversion >= 0x010502F0:
149+
# use some advanced feature
150+
...
151+
else:
152+
# use an alternative implementation or warn the user
153+
...
154+
\end{verbatim}
155+
156+
This is called \samp{hexversion} since it only really looks meaningful
157+
when viewed as the result of passing it to the built-in
158+
\function{hex()} function. The \code{version_info} value may be used
159+
for a more human-friendly encoding of the same information.
160+
\versionadded{1.5.2}
161+
\end{datadesc}
162+
141163
\begin{datadesc}{last_type}
142164
\dataline{last_value}
143165
\dataline{last_traceback}
@@ -304,6 +326,16 @@ \section{\module{sys} ---
304326
\end{verbatim}
305327
\end{datadesc}
306328

329+
\begin{datadesc}{version_info}
330+
A tuple containing the four components of the version number:
331+
\var{major}, \var{minor}, \var{micro} as integers, and
332+
\var{releaselevel} as a string. The \var{releaselevel} value will be
333+
an empty string for a final release. The \code{version_info} value
334+
corresponding to the \code{version} string shown above is
335+
\code{(1, 5, 2, '')}.
336+
\versionadded{1.6}
337+
\end{datadesc}
338+
307339
\begin{datadesc}{winver}
308340
The version number used to form registry keys on Windows platforms.
309341
This is stored as string resource 1000 in the Python DLL. The value

0 commit comments

Comments
 (0)