sys — System-specific parameters and functions — Python 3.16.0a0 documentation

docs.python.org

Tin mới

Python Runtime Services

sys.monitoring — Execution event monitoring

Python Module Index

3.16.0a0 Documentation

The Python Standard Library

PySys_AddAuditHook()

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

ctypes: A foreign function library for Python.

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 Environments

Equivalent to exec_prefix, but referring to the base Python installation.

virtual environment

Equivalent to prefix, but referring to the base Python installation.

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.

built in debug mode

Print low-level information to stderr about the state of CPython’s memory allocator.

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().

site: Module responsible for site-specific configuration.

Changed in version 3.14: When running under a virtual environment, prefix and exec_prefix are now set to the virtual environment prefix by the path initialization, instead of site. This means that prefix and exec_prefix

Python Development Mode

integer string conversion length limitation

-X int_max_str_digits (integer string conversion length limitation)

platform.android_ver()

Return the build-time API level of Android as an integer. This represents the minimum version of Android this build of Python can run on. For runtime version information, see platform.android_ver().

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).

filesystem encoding

Get the filesystem encoding: the encoding used with the filesystem error handler to convert between Unicode filenames and bytes filenames. The filesystem error handler is returned from getfilesystemencodeerrors().

filesystem_encoding

Get the filesystem encoding: the encoding used with the filesystem error handler to convert between Unicode filenames and bytes filenames. The filesystem error handler is returned from getfilesystemencodeerrors().

PyInterpreterConfig.use_main_obmalloc

This function only exists if CPython was built using the specialized configure option --with-trace-refs. It is intended only for debugging garbage-collection issues.

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

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

concurrent.interpreters

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)

Installation paths

A string giving the site-specific directory prefix where the platform independent Python files are installed; on Unix, the default is /usr/local. This can be set at build time with the --prefix argument to the configure

profile — Pure Python profiler

The same tracing mechanism is used for setprofile() as settrace(). To trace calls with setprofile() inside a tracing function (e.g. in a debugger breakpoint), see call_tracing().

current stack frame

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

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

Python support for the perf map compatible profilers

Remote debugging attachment protocol

Executes script, a file containing Python code in the remote process with the given pid.

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').

PYTHON_API_VERSION

The C API version, equivalent to the C macro PYTHON_API_VERSION. Defined for backwards compatibility.

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.