

{"id":27250,"date":"2018-09-08T05:15:02","date_gmt":"2018-09-07T23:45:02","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=27250"},"modified":"2026-04-24T15:01:06","modified_gmt":"2026-04-24T09:31:06","slug":"python-sys-module","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-sys-module\/","title":{"rendered":"Python sys Module &#8211; Important Functions"},"content":{"rendered":"<p><span style=\"font-weight: 400\">In our last Python tutorial, we discussed Python Subprocess. Today, we will discuss Python sys Module.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Moreover, we learn about functions like version, displayhook, stderr, and more. Also, we will see how to import sys in Python.\u00a0<\/span><\/p>\n<p>So, let&#8217;s start the Python sys Module tutorial.<\/p>\n<div id=\"attachment_27275\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27275\" class=\"wp-image-27275 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg\" alt=\"Python sys Module - Important Functions\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-27275\" class=\"wp-caption-text\">Python sys Module &#8211; Important Functions<\/p><\/div>\n<h2><span style=\"font-weight: 400\">What is the Python sys Module?<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Let\u2019s get to know it first. The sys module in Python lets us access system-specific parameters and functions. <\/span><\/p>\n<p><span style=\"font-weight: 400\">It gives us information about constants, functions, and methods of the interpreter.<\/span><\/p>\n<p><strong> The need for the sys Module in Python:<\/strong><\/p>\n<ul>\n<li>It provides access to some specific functions and parameters, like command line arguments.<\/li>\n<li>It makes reading and writing easier by using sys.stdin and sys.stdout.<\/li>\n<li>It allows clear interaction with Python&#8217;s runtime environment.<\/li>\n<li>It helps in debugging and managing the system behaviour in a Python script.<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">To find out more about it, you can try one of two functions:<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>1. Summarized information-<\/strong> constants, functions, methods:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; dir(sys)<\/pre>\n<p><strong>2. Detailed information-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; help(sys)<\/pre>\n<p><span style=\"font-weight: 400\">Some things you can do with it are:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import sys #Get version information\r\n&gt;&gt;&gt; sys.version<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)]&#8217;<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.version_info<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">sys.version_info(major=3, minor=7, micro=0, releaselevel=&#8217;final&#8217;, serial=0)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.getrecursionlimit() #Get maximal recursion depth<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">1000<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.setrecursionlimit(1500) #Set maximal recursion depth\r\n&gt;&gt;&gt; sys.getrecursionlimit()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">1500<\/div>\n<h3>Command-line Arguments in Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">We can store the command-line arguments we pass to a script in a list we call <\/span><i><span style=\"font-weight: 400\">sys.argv<\/span><\/i><span style=\"font-weight: 400\">. <\/span><\/p>\n<p><span style=\"font-weight: 400\">The first item of this is the name of the script; the arguments are next. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Save the following code in a script:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">import sys\r\nprint(sys.argv)\r\nfor i in range(len(sys.argv)):\r\n   if i==0:\r\n       print(\"The function is\",sys.argv[0])\r\n   else:   print(\"Argument:\",sys.argv[i])\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">C:\\Users\\Ayushi\\Desktop&gt;py sysdemo.py 2 3<br \/>\n[\u2018sysdemo.py\u2019,\u20192\u2019,\u20193\u2019]<br \/>\nThe function is sysdemo.py<br \/>\nArgument:2<br \/>\nArgument:3<\/div>\n<h3>Changing the Output Behavior of the Shell<\/h3>\n<p><span style=\"font-weight: 400\">We\u2019ve so often used the Python shell interactively and even as a calculator. But what if we wanted to change how it delivers the output? <\/span><\/p>\n<p><span style=\"font-weight: 400\">Well, we can; we simply rebind sys.displayhook to a callable object.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import sys\r\n&gt;&gt;&gt; x=42\r\n&gt;&gt;&gt; x<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">42<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(x)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">42<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; def show(x):\r\n       print(\"Output:\",x)\r\n&gt;&gt;&gt; sys.displayhook=show\r\n&gt;&gt;&gt; x<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">42<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(x)<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">None<\/div>\n<h3>Ways to Read and Write in Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">We can also use the readline() method to get input from the user:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(\"Type in value: \",sys.stdin.readline()[:-1])\r\n23<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">Type in value: \u00a023<\/div>\n<p><span style=\"font-weight: 400\">The following piece of code lets us print to the screen:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.stdout.write('Way to write')<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">Way to write12<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.stdout.write('Way to write\\n')<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">Way to write<br \/>\n13<\/div>\n<p><span style=\"font-weight: 400\">Notice that it gives us the number of characters, which is why it gives us 13 instead of 12 when we give it a \\n newline character too at the end.<\/span><\/p>\n<h3>Getting the names of the modules in Python<\/h3>\n<p><span style=\"font-weight: 400\">sys.modules in Python gives us a dictionary of the names of the modules existing in the current shell.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import sys\r\n&gt;&gt;&gt; sys.modules<\/pre>\n<div id=\"attachment_27263\" style=\"width: 514px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/modules.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27263\" class=\"wp-image-27263 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/modules.png\" alt=\"Python sys Module\" width=\"504\" height=\"201\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/modules.png 504w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/modules-150x60.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/modules-300x120.png 300w\" sizes=\"auto, (max-width: 504px) 100vw, 504px\" \/><\/a><p id=\"caption-attachment-27263\" class=\"wp-caption-text\">sys Module in Python<\/p><\/div>\n<h3>Investigating the Path using Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">sys.path in Python will give you a list of paths it will search in whenever you make an import.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.path<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\"><span style=\"font-weight: 400\">[&#8221;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\Lib\\\\idlelib&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\python37.zip&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\DLLs&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\lib&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\lib\\\\site-packages&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\lib\\\\site-packages\\\\scrapy-1.5.1-py3.7.egg&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\lib\\\\site-packages\\\\service_identity-17.0.0-py3.7.egg&#8217;, &#8216;C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\\\\lib\\\\site-packages\\\\parsel-1.5.0-py3.7.egg&#8217;]<\/span><\/div>\n<p><span style=\"font-weight: 400\">You can add a path to this with the append() method-<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.path.append('C:\\\\Users\\\\Ayushi\\\\Desktop')<\/pre>\n<p><span style=\"font-weight: 400\">Now, when you make a call to sys.path in Python, you can see this location in the list.<\/span><\/p>\n<h3>Getting the Copyrights using Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">sys.copyright in Python displays the copyright information on the currently-installed version of Python.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(sys.copyright)<\/pre>\n<p>Copyright (c) 2001-2018 Python Software Foundation.<br \/>\nAll Rights Reserved.<br \/>\nCopyright (c) 2000 BeOpen.com.<br \/>\nAll Rights Reserved.<br \/>\nCopyright (c) 1995-2001 Corporation for National Research Initiatives.<br \/>\nAll Rights Reserved.<br \/>\nCopyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.<br \/>\nAll Rights Reserved.<\/p>\n<h3>Exiting Current Flow of Execution using Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">sys.exit in Python lets the interpreter abruptly exit the current flow of execution.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.exit<\/pre>\n<div id=\"attachment_27264\" style=\"width: 226px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/exit.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27264\" class=\"wp-image-27264 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/exit.png\" alt=\"Python sys Module\" width=\"216\" height=\"50\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/exit.png 216w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/exit-150x35.png 150w\" sizes=\"auto, (max-width: 216px) 100vw, 216px\" \/><\/a><p id=\"caption-attachment-27264\" class=\"wp-caption-text\">Exiting Current Flow of Execution<\/p><\/div>\n<p><span style=\"font-weight: 400\">You can use a try-except block to catch this call-<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; try:\r\n       sys.exit(1)\r\nexcept SystemExit:\r\n       pass<\/pre>\n<h3>Getting Reference Count and Platform<\/h3>\n<p><span style=\"font-weight: 400\">The getrefcount function gives us the count of references to an object where used. <\/span><\/p>\n<p><span style=\"font-weight: 400\">When in a program, this value drops to 0, Python cleans up the memory for this variable. Let\u2019s take an example.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=7\r\n&gt;&gt;&gt; sys.getrefcount(a)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">37<\/div>\n<p><span style=\"font-weight: 400\">To get the name of the platform we\u2019re running Python on, we make a call to sys.platform in Python:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sys.platform<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;win32&#8217;<\/div>\n<h3>Redirecting Output using Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">Instead of delivering the output to the console, you can log into a text file.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import sys\r\n&gt;&gt;&gt; print('Hello') #Prints normally<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">Hello<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; saveout=sys.stdout\r\n&gt;&gt;&gt; fsock=open('out.log','w')\r\n&gt;&gt;&gt; sys.stdout=fsock\r\n&gt;&gt;&gt; print('Message to log')\r\n&gt;&gt;&gt; sys.stdout=saveout\r\n&gt;&gt;&gt; fsock.close()<\/pre>\n<div id=\"attachment_27266\" style=\"width: 230px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/output.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27266\" class=\"wp-image-27266 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/output.png\" alt=\"Python sys Module\" width=\"220\" height=\"105\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/output.png 220w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/output-150x72.png 150w\" sizes=\"auto, (max-width: 220px) 100vw, 220px\" \/><\/a><p id=\"caption-attachment-27266\" class=\"wp-caption-text\">Redirecting Output in Python<\/p><\/div>\n<h3>Redirecting Error Information using Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">Using sys.stderr and a text file in Python, we can log error information to the text file. See how:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import sys\r\n&gt;&gt;&gt; fsock=open('error.log','w') #Opening the file\r\n&gt;&gt;&gt; sys.stderr=fsock #Redirecting standard error by assigning file object of file to stderr\r\n&gt;&gt;&gt; raise Exception('this is an error')\r\n&gt;&gt;&gt; fsock.close()<\/pre>\n<div id=\"attachment_27267\" style=\"width: 493px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/error.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27267\" class=\"wp-image-27267 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/error.png\" alt=\"Python sys Module\" width=\"483\" height=\"219\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/error.png 483w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/error-150x68.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/error-300x136.png 300w\" sizes=\"auto, (max-width: 483px) 100vw, 483px\" \/><\/a><p id=\"caption-attachment-27267\" class=\"wp-caption-text\">Redirecting Error Information in Python sys Module<\/p><\/div>\n<p>Note that this traceback doesn\u2019t show up in the log file until we close its file object in Python (which, in this case, is fsock).<\/p>\n<p><span style=\"font-weight: 400\">Another way we use sys.stderr is as follows:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; for i in range(3):\r\n        sys.stderr.write('Hello')<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">Hello5<br \/>\nHello5<br \/>\nHello5<\/div>\n<p><span style=\"font-weight: 400\">Unlike stdout, stderr does not add carriage returns.<\/span><br \/>\n<span style=\"font-weight: 400\">A similar function flush() lets us flush write buffers.<\/span><\/p>\n<h3>More Functions in Python sys Module<\/h3>\n<p><span style=\"font-weight: 400\">The purpose of this tutorial is to get you started with the <\/span><i><span style=\"font-weight: 400\">sys<\/span><\/i><span style=\"font-weight: 400\"> module; there is so much more to it.<\/span><\/p>\n<p><span style=\"font-weight: 400\">To get a list of all the built-in functions and methods we have for <\/span><i><span style=\"font-weight: 400\">sys<\/span><\/i><span style=\"font-weight: 400\">, try calling the dir() function on it.<\/span><\/p>\n<div id=\"attachment_27268\" style=\"width: 535px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/dir.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27268\" class=\"wp-image-27268 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/dir.png\" alt=\"Python sys Module\" width=\"525\" height=\"512\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/dir.png 525w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/dir-150x146.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/dir-300x293.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/a><p id=\"caption-attachment-27268\" class=\"wp-caption-text\">Python sys Module &#8211; Functions<\/p><\/div>\n<p><span style=\"font-weight: 400\">Try them out, won\u2019t you?<\/span><\/p>\n<p>So, this was all in the Python sys Module. Hope you like our explanation.<\/p>\n<h3>Python Interview Questions on the sys module<\/h3>\n<ol>\n<li>What is the sys module in Python?<\/li>\n<li>What is the most common use of the Python sys library?<\/li>\n<li>What is Python sys argv?<\/li>\n<li>What are OS and SYS in Python?<\/li>\n<li>What is Python SYS Path?<\/li>\n<\/ol>\n<h3><span style=\"font-weight: 400\">Conclusion<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Hence, today in this Python sys module tutorial, we took a brief look at various functions and methods available with the Python sys module, including argv, stdin, stdout, stderr, setrecursionlimit, and exit. <\/span><\/p>\n<p><span style=\"font-weight: 400\">We also discussed the meaning of import sys in Python.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last Python tutorial, we discussed Python Subprocess. Today, we will discuss Python sys Module.\u00a0 Moreover, we learn about functions like version, displayhook, stderr, and more. Also, we will see how to import&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":27275,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[6616,6617,9338,10687,10878,10879,10880,14120,14121,14122],"class_list":["post-27250","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-import-sys-in-python-means","tag-import-sys-python-3","tag-os-and-sys-modules-in-python","tag-python-modules","tag-python-sys","tag-python-sys-module","tag-python-sys-module-tutorial","tag-sys-module-python","tag-sys-path-python","tag-sys-stdn-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python sys Module - Important Functions - DataFlair<\/title>\n<meta name=\"description\" content=\"What is Python sys Module, Command-line Arguments,import sys in python means,python modules,python sys Module tutorial,sys modules in Python\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-sys-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python sys Module - Important Functions - DataFlair\" \/>\n<meta property=\"og:description\" content=\"What is Python sys Module, Command-line Arguments,import sys in python means,python modules,python sys Module tutorial,sys modules in Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-sys-module\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-07T23:45:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-24T09:31:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python sys Module - Important Functions - DataFlair","description":"What is Python sys Module, Command-line Arguments,import sys in python means,python modules,python sys Module tutorial,sys modules in Python","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-sys-module\/","og_locale":"en_US","og_type":"article","og_title":"Python sys Module - Important Functions - DataFlair","og_description":"What is Python sys Module, Command-line Arguments,import sys in python means,python modules,python sys Module tutorial,sys modules in Python","og_url":"https:\/\/data-flair.training\/blogs\/python-sys-module\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-09-07T23:45:02+00:00","article_modified_time":"2026-04-24T09:31:06+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python sys Module &#8211; Important Functions","datePublished":"2018-09-07T23:45:02+00:00","dateModified":"2026-04-24T09:31:06+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/"},"wordCount":1060,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg","keywords":["import sys in python means","import sys Python 3","os and sys modules in Python","Python Modules","python sys","python sys module","python sys module tutorial","sys module Python","sys.path python","sys.stdn Python"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-sys-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/","url":"https:\/\/data-flair.training\/blogs\/python-sys-module\/","name":"Python sys Module - Important Functions - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg","datePublished":"2018-09-07T23:45:02+00:00","dateModified":"2026-04-24T09:31:06+00:00","description":"What is Python sys Module, Command-line Arguments,import sys in python means,python modules,python sys Module tutorial,sys modules in Python","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-sys-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/09\/Python-sys-Module-01.jpg","width":1200,"height":628,"caption":"Python sys Module - Important Functions"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-sys-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python sys Module &#8211; Important Functions"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/27250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=27250"}],"version-history":[{"count":11,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/27250\/revisions"}],"predecessor-version":[{"id":147838,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/27250\/revisions\/147838"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/27275"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=27250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=27250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=27250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}