Python Module sys: Difference between revisions
Jump to navigation
Jump to search
Line 24: | Line 24: | ||
patch = sys.version_info[2] | patch = sys.version_info[2] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<code>sys.version_info[0]</code>, <code>sys.version_info[1]</code> and <code>sys.version_info[2]</code> are <code>int</code>s. |
Latest revision as of 19:29, 6 September 2022
External
Internal
Overview
This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter.
Variables
sys.argv
sys.modules
A dictionary that maps module names to modules instances, for modules have already been loaded. It can be manipulated to force reloading of modules. However, replacing the dictionary will not necessarily work as expected and deleting essential items from the dictionary may cause Python to fail. If you want to iterate over this global dictionary always use sys.modules.copy()
or tuple(sys.modules)
to avoid exceptions as its size may change during iteration as a side effect of code or activity in other threads.
sys.version_info
import sys
major = sys.version_info[0]
major = sys.version_info.major
minor = sys.version_info[1]
minor = sys.version_info.minor
patch = sys.version_info[2]
sys.version_info[0]
, sys.version_info[1]
and sys.version_info[2]
are int
s.