Pelokalan
Python ID
id en
Masuk
Proyek
glossary.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
A label associated with a variable, a class attribute or a function parameter or return value, used by convention as a :term:`type hint`.
A programming style which does not look at an object's type to determine if it has the right interface; instead, the method or attribute is simply called or used ("If it looks like a duck and quacks like a duck, it must be a duck.") By emphasizing interfaces rather than specific types, well-designed code improves its flexibility by allowing polymorphic substitution. Duck-typing avoids tests using :func:`type` or :func:`isinstance`. (Note, however, that duck-typing can be complemented with :term:`abstract base classes <abstract base class>`.) Instead, it typically employs :func:`hasattr` tests or :term:`EAFP` programming.
A function that can be called to evaluate a lazily evaluated attribute of an object, such as the value of type aliases created with the :keyword:`type` statement.
An object exposing a file-oriented API (with methods such as :meth:`!read` or :meth:`!write`) to an underlying resource. Depending on the way it was created, a file object can mediate access to a real on-disk file or to another type of storage or communication device (for example standard input/output, in-memory buffers, sockets, pipes, etc.). File objects are also called :dfn:`file-like objects` or :dfn:`streams`.
The :term:`filesystem encoding and error handler` are configured at Python startup by the :c:func:`PyConfig_Read` function: see :c:member:`~PyConfig.filesystem_encoding` and :c:member:`~PyConfig.filesystem_errors` members of :c:type:`PyConfig`.
There are two types of finder: :term:`meta path finders <meta path finder>` for use with :data:`sys.meta_path`, and :term:`path entry finders <path entry finder>` for use with :data:`sys.path_hooks`.
Function annotations are usually used for :term:`type hints <type hint>`: for example, this function is expected to take two :class:`int` arguments and is also expected to have an :class:`int` return value::
A function composed of multiple functions implementing the same operation for different types. Which implementation should be used during a call is determined by the dispatch algorithm.
generic type
A :term:`type` that can be parameterized; typically a :ref:`container class<sequence-types>` such as :class:`list` or :class:`dict`. Used for :term:`type hints <type hint>` and :term:`annotations <annotation>`.
For more details, see :ref:`generic alias types<types-genericalias>`, :pep:`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module.
The mechanism used by the :term:`CPython` interpreter to assure that only one thread executes Python :term:`bytecode` at a time. This simplifies the CPython implementation by making the object model (including critical built-in types such as :class:`dict`) implicitly safe against concurrent access. Locking the entire interpreter makes it easier for the interpreter to be multi-threaded, at the expense of much of the parallelism afforded by multi-processor machines.
An object capable of returning its members one at a time. Examples of iterables include all sequence types (such as :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence types like :class:`dict`, :term:`file objects <file object>`, and objects of any classes you define with an :meth:`~object.__iter__` method or with a :meth:`~object.__getitem__` method that implements :term:`sequence` semantics.
More information can be found in :ref:`typeiter`.
Informasi lebih lanjut dapat ditemukan di :ref:`typeiter`.
An operation that does not acquire any :term:`lock` and uses atomic CPU instructions to ensure correctness. Lock-free operations can execute concurrently without blocking each other and cannot be blocked by operations that hold locks. In :term:`free-threaded <free threading>` Python, built-in types like :class:`dict` and :class:`list` provide lock-free read operations, which means other threads may observe intermediate states during multi-step modifications even when those modifications hold the :term:`per-object lock`.
On Unix, it is the encoding of the LC_CTYPE locale. It can be set with :func:`locale.setlocale(locale.LC_CTYPE, new_locale) <locale.setlocale>`.
The term "named tuple" applies to any type or class that inherits from tuple and whose indexable elements are also accessible using named attributes. The type or class may have other features as well.
Several built-in types are named tuples, including the values returned by :func:`time.localtime` and :func:`os.stat`. Another example is :data:`sys.float_info`::
Some named tuples are built-in types (such as the above examples). Alternatively, a named tuple can be created from a regular class definition that inherits from :class:`tuple` and that defines named fields. Such a class can be written by hand, or it can be created by inheriting :class:`typing.NamedTuple`, or with the factory function :func:`collections.namedtuple`. The latter techniques also add some extra methods that may not be found in hand-written or built-in named tuples.
A :term:`lock` associated with an individual object instance rather than a global lock shared across all objects. In :term:`free-threaded <free threading>` Python, built-in types like :class:`dict` and :class:`list` use per-object locks to allow concurrent operations on different objects while serializing operations on the same object. Operations that hold the per-object lock prevent other locking operations on the same object from proceeding, but do not block :term:`lock-free` operations.
An idea or piece of code which closely follows the most common idioms of the Python language, rather than implementing code using concepts common to other languages. For example, a common idiom in Python is to loop over all elements of an iterable using a :keyword:`for` statement. Many other languages don't have this type of construct, so people unfamiliar with Python sometimes use a numerical counter instead::
A condition of a program where the behavior depends on the relative timing or ordering of events, particularly in multi-threaded programs. Race conditions can lead to :term:`non-deterministic` behavior and bugs that are difficult to reproduce. A :term:`data race` is a specific type of race condition involving unsynchronized access to shared memory. The :term:`LBYL` coding style is particularly susceptible to race conditions in multi-threaded code. Using :term:`locks <lock>` and other :term:`synchronization primitives <synchronization primitive>` helps prevent race conditions.
An :term:`iterable` which supports efficient element access using integer indices via the :meth:`~object.__getitem__` special method and defines a :meth:`~object.__len__` method that returns the length of the sequence. Some built-in sequence types are :class:`list`, :class:`str`, :class:`tuple`, and :class:`bytes`. Note that :class:`dict` also supports :meth:`~object.__getitem__` and :meth:`!__len__`, but is considered a mapping rather than a sequence because the lookups use arbitrary :term:`hashable` keys rather than integers.
The :class:`collections.abc.Sequence` abstract base class defines a much richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:`~object.__len__`, adding :meth:`~sequence.count`, :meth:`~sequence.index`, :meth:`~object.__contains__`, and :meth:`~object.__reversed__`. Types that implement this expanded interface can be registered explicitly using :func:`~abc.ABCMeta.register`. For more documentation on sequence methods generally, see :ref:`Common Sequence Operations <typesseq-common>`.
A form of :term:`generic function` dispatch where the implementation is chosen based on the type of a single argument.
An object of type :class:`slice`, used to describe a portion of a :term:`sequence`. A slice object is created when using the :ref:`slicing <slicings>` form of :ref:`subscript notation <subscriptions>`, with colons inside square brackets, such as in ``variable_name[1:3:5]``.
A method that is called implicitly by Python to execute a certain operation on a type, such as addition. Such methods have names starting and ending with double underscores. Special methods are documented in :ref:`specialnames`.
static type checker
An external tool that reads Python code and analyzes it, looking for issues such as incorrect types. See also :term:`type hints <type hint>` and the :mod:`typing` module.
A module, function, or class that behaves correctly when used by multiple threads concurrently. Thread-safe code uses appropriate :term:`synchronization primitives <synchronization primitive>` like :term:`locks <lock>` to protect shared mutable state, or is designed to avoid shared mutable state entirely. In the :term:`free-threaded <free threading>` build, built-in types like :class:`dict`, :class:`list`, and :class:`set` use internal locking to make many operations thread-safe, although thread safety is not necessarily guaranteed. Code that is not thread-safe may experience :term:`race conditions <race condition>` and :term:`data races <data race>` when used in multi-threaded programs.
The :mod:`tokenize` module exposes Python's lexical analyzer. The :mod:`token` module contains information on the various types of tokens.
type
tipe
The type of a Python object determines what kind of object it is; every object has a type. An object's type is accessible as its :attr:`~object.__class__` attribute or can be retrieved with ``type(obj)``.
type alias
A synonym for a type, created by assigning the type to an identifier.
Type aliases are useful for simplifying :term:`type hints <type hint>`. For example::
type hint
An :term:`annotation` that specifies the expected type for a variable, a class attribute, or a function parameter or return value.
Type hints are optional and are not enforced by Python but they are useful to :term:`static type checkers <static type checker>`. They can also aid IDEs with code completion and refactoring.
Type hints of global variables, class attributes, and functions, but not local variables, can be accessed using :func:`typing.get_type_hints`.
Variable annotations are usually used for :term:`type hints <type hint>`: for example this variable is expected to take :class:`int` values::