Learn Python – Python sys module- Basic and advance

The python sys module offers functions and variables which are used to manipulate extraordinary parts of the Python Runtime Environment. It lets us get right of entry to system-specific parameters and functions.

import sys

First, we have to import the sys module in our application before walking any functions.


This feature provides the identify of the current python modules which have been imported.


This feature returns a listing of command line arguments handed to a Python script. The title of the script is continually the item at index 0, and the relaxation of the arguments are saved at subsequent indices.


This feature presents an efficient way to the identical fee as exec_prefix. If no longer jogging a digital environment, the price will continue to be the same.


It is set up at some point of Python startup, earlier than site.py is run, to the identical price as prefix.


It is an indication of the native byteorder that offers an environment friendly way to do something.


This feature returns the largest integer of a variable.


This feature suggests the PYTHONPATH set in the current system. It is an surroundings variable that is a search direction for all the python modules.


It is an object that contains the unique values of stdin at the start of the program and used during finalization. It can repair the files.


This characteristic returns the reference rely of an object.


This feature is used to exit from both the Python console or command prompt, and additionally used to exit from the software in case of an exception.

sys executable

The value of this feature is the absolute route to a Python interpreter. It is beneficial for understanding where python is established on someone else machine.


This fee of this function is used to become aware of the platform on which we are working.