sys — System-specific parameters and functions — Python 3.9.25 documentation

docs.python.org

Tin mới

Python Runtime Services

sysconfig — Provide access to Python’s configuration information

sysconfig — Provide access to Python’s configuration information

Python documentation for the current stable release

sysconfig — Provide access to Python’s configuration information

Python Module Index

3.9.25 Documentation

The Python Standard Library

PySys_AddAuditHook()

Append the callable hook to the list of active auditing hooks for the current (sub)interpreter.

audit events table

Append the callable hook to the list of active auditing hooks for the current (sub)interpreter.

fileinput: Loop over standard input or a list of files.

The list of command line arguments passed to a Python script. argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the -c command line op

virtual environment

traceback: Print or retrieve a stack traceback.

Return a dictionary mapping each thread’s identifier to the topmost stack frame currently active in that thread at the time the function is called. Note that functions in the traceback module can build the call stack giv

pdb: The Python debugger for interactive interpreters.

This hook function is called by built-in breakpoint(). By default, it drops you into the pdb debugger, but it can be set to any other function so that you can choose which debugger gets used.

UnicodeEncodeError

Changed in version 3.2: Use 'backslashreplace' error handler on UnicodeEncodeError.

PYTHONDONTWRITEBYTECODE

If this is true, Python won’t try to write .pyc files on the import of source modules. This value is initially set to True or False depending on the -B command line option and the PYTHONDONTWRITEBYTECODE environment vari

compileall: Tools for byte-compiling all Python source files in a directory tree.

A relative path is interpreted relative to the current working directory.

threading.excepthook()

The sys.unraisablehook() function handles unraisable exceptions and the threading.excepthook() function handles exception raised by threading.Thread.run().

inspect: Extract information and source code from live objects.

Python Development Mode

integer string conversion length limitation

-X int_max_str_digits (integer string conversion length limitation)

os: Miscellaneous operating system interfaces.

Return the current value of the flags that are used for dlopen() calls. Symbolic names for the flag values can be found in the os module (RTLD_xxx constants, e.g. os.RTLD_LAZY).

platform: Retrieves as much platform identifying data as possible.

platform_version derives the version from kernel32.dll which can be of a different version than the OS version. Please use platform module for achieving accurate OS version.

collections.namedtuple

Returns an asyncgen_hooks object, which is similar to a namedtuple of the form (firstiter, finalizer), where firstiter and finalizer are expected to be either None or functions which take an asynchronous generator iterat

asynchronous generator iterator

Returns an asyncgen_hooks object, which is similar to a namedtuple of the form (firstiter, finalizer), where firstiter and finalizer are expected to be either None or functions which take an asynchronous generator iterat

API and ABI Versioning

The version number encoded as a single integer. This is guaranteed to increase with each version, including proper support for non-production releases. For example, to test that the Python interpreter is at least version

site: Module responsible for site-specific configuration.

When this attribute exists, its value is automatically called (with no arguments) when the interpreter is launched in interactive mode. This is done after the PYTHONSTARTUP file is read, so that you can set this hook the

importlib.abc.MetaPathFinder.find_spec

The abstract base class defining the interface of finder objects on meta_path.

errno: Standard errno system symbols.

/usr/lib64/pythonX.Y/lib-dynload/: C extension modules of the standard library (like the errno module, the exact filename is platform specific)

The Python Profilers

Profile functions should have three arguments: frame, event, and arg. frame is the current stack frame. event is a string: 'call', 'return', 'c_call', 'c_return', or 'c_exception'. arg depends on the event type.

dis: Disassembler for Python bytecode.

The interpreter is about to execute a new opcode (see dis for opcode details). The local trace function is called; arg is None; the return value specifies the new local trace function. Per-opcode events are not emitted b

The standard type hierarchy

Set the system’s trace function, which allows you to implement a Python source code debugger in Python. The function is thread-specific; for a debugger to support multiple threads, it must register a trace function using

locale.getpreferredencoding()

The character encoding is platform-dependent. Non-Windows platforms use the locale encoding (see locale.getpreferredencoding()).

io.TextIOBase.buffer

To write or read binary data from/to the standard streams, use the underlying binary buffer object. For example, to write bytes to stdout, use sys.stdout.buffer.write(b'abc').

warnings: Issue warning messages and control their disposition.

This is an implementation detail of the warnings framework; do not modify this value. Refer to the warnings module for more information on the warnings framework.