Built-in Functions — Python 3.14.7 documentation

docs.python.org

Tin mới

Built-in Constants

Python Module Index

3.14.7 Documentation

The Python Standard Library

asynchronous iterator

Return an asynchronous iterator for an asynchronous iterable. Equivalent to calling x.__aiter__().

StopAsyncIteration

When awaited, return the next item from the given asynchronous iterator, or default if given and the iterator is exhausted.

truth testing procedure

Return a Boolean value, i.e. one of True or False. The argument is converted using the standard truth testing procedure. If the argument is false or omitted, this returns False; otherwise, it returns True. The bool class

sys.breakpointhook()

By default, the behavior of breakpoint() can be changed with the PYTHONBREAKPOINT environment variable. See sys.breakpointhook() for usage details.

pdb: The Python debugger for interactive interpreters.

By default, the behavior of breakpoint() can be changed with the PYTHONBREAKPOINT environment variable. See sys.breakpointhook() for usage details.

String and Bytes literals

Return a new “bytes” object which is an immutable sequence of integers in the range 0 <= x < 256. bytes is an immutable version of bytearray – it has the same non-mutating methods and the same indexing and slicing behavi

Function definitions

A class method receives the class as an implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

The standard type hierarchy

A class method receives the class as an implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

ast: Abstract Syntax Tree classes and manipulation.

Compile the source into a code or AST object. Code objects can be executed by exec() or eval(). source can either be a normal string, a byte string, or an AST object. Refer to the ast module documentation for information

__future__._Feature.compiler_flag

Compile the source into a code or AST object. Code objects can be executed by exec() or eval(). source can either be a normal string, a byte string, or an AST object. Refer to the ast module documentation for information

code: Facilities to implement read-eval-print loops.

When compiling a string with multi-line code in 'single' or 'eval' mode, input must be terminated by at least one newline character. This is to facilitate detection of incomplete and complete statements in the code modul

collections: Container datatypes

Create a new dictionary. The dict object is the dictionary class. See also Mapping Types — dict for documentation about this class.

builtins: The module that provides the built-in namespace.

globals (dict | None) – The global namespace (default: None).

itertools.filterfalse()

Construct an iterator from those elements of iterable for which function is true. iterable may be either a sequence, a container which supports iteration, or an iterator. If function is None, the identity function is ass

Format specification mini-language

Convert a value to a “formatted” representation, as controlled by format_spec. The interpretation of format_spec will depend on the type of the value argument; however, there is a standard formatting syntax that is used

private name mangling

Since private name mangling happens at compilation time, one must manually mangle a private attribute’s (attributes with two leading underscores) name in order to retrieve it with getattr().

the FAQ entry on positional-only parameters

Note that if a slash(/) appears in the parameter list of a function when invoking help(), it means that the parameters prior to the slash are positional-only. For more info, see the FAQ entry on positional-only parameter

site: Module responsible for site-specific configuration.

Note that if a slash(/) appears in the parameter list of a function when invoking help(), it means that the parameters prior to the slash are positional-only. For more info, see the FAQ entry on positional-only parameter

pydoc: Documentation generator and online help system.

Changed in version 3.4: Changes to pydoc and inspect mean that the reported signatures for callables are now more comprehensive and consistent.

inspect: Extract information and source code from live objects.

Changed in version 3.4: Changes to pydoc and inspect mean that the reported signatures for callables are now more comprehensive and consistent.

readline: GNU readline support for Python.

If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EO

Reading and Writing Files

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

locale.getencoding()

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

io.TextIOWrapper.reconfigure()

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

codecs: Encode and decode data and streams.

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

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

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

os: Miscellaneous operating system interfaces.

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

os.path: Operations on pathnames.

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

tempfile: Generate temporary files and directories.

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

shutil: High-level file operations, including copying.

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function.

Floating-Point Arithmetic: Issues and Limitations

The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented ex

functools.cmp_to_key()

Return a new sorted list from the items in iterable.

Sorting Techniques

Return a new sorted list from the items in iterable.

pickle: Convert Python objects to streams of bytes and back.

Changed in version 3.14: super objects are now pickleable and copyable.

copy: Shallow and deep copy operations.

Changed in version 3.14: super objects are now pickleable and copyable.

types.MappingProxyType

Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.

importlib.import_module()

This is an advanced function that is not needed in everyday Python programming, unlike importlib.import_module().