• Offers
    • RegisterLogin
      • Learn More
    PythonPoint.netPythonPoint.net
    • Offers
    • RegisterLogin
      • Learn More

      Python

      SKILL IS IMPORTANT THAN DEGREE Be skill full.
      • Home
      • Blog
      • Python
      • What is sys in Python

      What is sys in Python

      • Posted by Python Point Team
      • Categories Python
      • Date December 26, 2020
      • Comments 0 comment
      what is sys in python

      The Python sys module provides easy functions that allow us to interact with the interpreter directly. It lets us access system-specific parameters and functions.

      First, we have to import the sys module in our program before running any functions.

      import sys

      sys.modules

      This function provides the name of the existing python modules which have been imported.

      sys.argv

      This function returns a list of command line arguments passed to a Python script. The name of the script is always the item at index 0, and the rest of the arguments are stored at subsequent indices.

      import sys
      print('The command line arguments are:')
      for i in sys.argv:
          print(i)

      sys.base_exec_prefix

      This function provides an efficient way to the same value as exec_prefix. If not running a virtual environment, the value will remain the same.

      sys.base_prefix

      It is set up during Python startup, before site.py is run, to the same value as prefix.

      sys.byteorder

      It is an indication of the native byteorder that provides an efficient way to do something.

      sys.maxsize

      This function returns the largest integer of a variable.

      sys.path

      This function shows the PYTHONPATH set in the current system. It is an environment variable that is a search path for all the python modules.

      >>> import sys
      >>> sys.path
      ['', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38\\DLLs', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38\\lib', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38', 'C:\\Users\\user\\AppData\\Roaming\\Python\\Python38\\site-packages', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\win32', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\win32\\lib', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\Pythonwin']
      >>>

      sys.stdin

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

      sys.getrefcount

      This function returns the reference count of an object.

      sys.exit

      This function is used to exit from either the Python console or command prompt, and also used to exit from the program in case of an exception.

      sys executable

      The value of this function is the absolute path to a Python interpreter. It is useful for knowing where python is installed on someone else machine.

      sys.platform

      This value of this function is used to identify the platform on which we are working.

      • Share:
      author avatar
      Python Point Team

      Previous post

      How to Increment in Python
      December 26, 2020

      Next post

      "not in" belongs to which type of operator in python?
      December 29, 2020

      You may also like

      15 Powerful Step for Mastering JSON Parsing in Python: Boosting Data Manipulation and Validation
      21 June, 2023

      Introduction In the world of programming, data plays a crucial role, and managing it efficiently is of utmost importance. JSON (JavaScript Object Notation) has emerged as a popular data interchange format due to its simplicity and flexibility. In this article, …

      Introduction to Transfer Learning with Python: A Practical Guide
      31 December, 2022

      Introduction: Definition of transfer learning Overview of how transfer learning works in the context of machine learning Why transfer learning is useful and important Section 1: Transfer learning in Python with Keras In this section, we will explore how to …

      How to Check Type in Python
      31 December, 2022

      In this article, we will learn to check type in Python. The built-in function type() can be used to check the type of data in Python.

      Subscribe
      Login
      Notify of
      Please login to comment
      0 Discussion
      Inline Feedbacks
      View all comments

      Latest Courses

      (Hindi) Ways to earn minimum 1 Lakh Per month as Programmer

      (Hindi) Ways to earn minimum 1 Lakh Per month as Programmer

      ₹10,000
      (HINDI) Full Stack Web Development In Python 3.8 And Django 3.1

      (HINDI) Full Stack Web Development In Python 3.8 And Django 3.1

      ₹25,000 ₹2,500

      Latest Posts

      • 15 Powerful Step for Mastering JSON Parsing in Python: Boosting Data Manipulation and Validation
      • Introduction to Transfer Learning with Python: A Practical Guide
      • How to Check Type in Python
      • How to make web crawler in python?
      • Why was the language called “python”?
      Contact
      •   support@pythonpoint.com

      We get you the best Python Courses and Blogs aiming to provide skill.

      We Believe Skill is much more important than a Degree

      Company
      • About Us
      • Blog
      • Offers
      • Contact
      Useful Links
      • Courses
      Support
      • Need Support

      © 2020 ALL RIGHTS RESERVED​ PYTHONPOINT.NET

      PythonPoint

      • Terms of Use
      • Refund Policy
      • Privacy Policy

      Login with your site account

      Lost your password?

      Not a member yet? Register now

      Register a new account

      Are you a member? Login now

      wpDiscuz