Python - sys Functions



The sys module in Python provides access to variables used by the Python interpreter and functions for interacting with the Python runtime environment.

Sr.No. Function & Description

1

sys.exit()

Exits the program by raising the SystemExit exception.

2

sys.getsizeof()

Returns the size of an object in bytes.

3

sys.setrecursionlimit(limit)

Sets the maximum depth of the Python interpreter stack.

4

sys.getrecursionlimit()

Used to access the current value of the recursion limit.

5

sys.exc_info()

Returns a tuple of three values representing the type of the exception, the exception itself, and a traceback object

6

sys.exception()

Returns the exception instance caught by the innermost exception handler currently executing, or None if no handler is active.

7

sys.getallocatedblocks()

Returns the number of memory blocks currently allocated by the interpreter.

8

sys.getdefaultencoding()

Return the name of the current default string encoding used by the Unicode implementation.

9

sys.getrefcount()

Returns the reference count of on object.

10

sys.getwindowsversion()

Return a named tuple describing the Windows version currently running.

11

sys.is_finalizing()

Used to check whether the Python interpreter is in the process of shutting down.

12

sys.setswitchinterval()

Used to set the interpreter's thread switch interval in seconds.

13

sys.settrace()

Used to set the systems trace function.

python_modules.htm
Advertisements