Python Module sys

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

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

Command Line Argument Processing

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 ints.