Skip to content

Python sys Module

The sys module is a standard module in which we manage the Python version installed on our system. Using this module we can use functions and features specific to the Python system. Here we will only talk about the most necessary features of this module.


sys.exit () function

This function terminates our running Python program.

import sys
a = input("a:")
b = input("b:")

sys.exit()

c = input("c:")

stderr ve stdout

When our applications and processes are running, computers use the following files to output and receive input.

stdin: This standard file allows the process to receive input from the user.

stdout: This standard file allows our process to output.

stderr: This standard file is used to output error messages of our process.

When we use our print () function, stdout is used as standard. However, we can also write something to * stderr.

import sys

sys.stderr.write("output: error message\n")

sys.stderr.flush() 

sys.stdout.write("output: normal message\n")

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: