Teks sumber — English
Terjemahan — Bahasa Indonesia
When awaited, return the next item from the given :term:`asynchronous iterator`, or *default* if given and the iterator is :term:`exhausted`.
This calls the :meth:`~object.__anext__` method of *async_iterator*, returning an :term:`awaitable`. Awaiting this returns the next value of the iterator. If *default* is given, it is returned if the iterator is exhausted, otherwise :exc:`StopAsyncIteration` is raised.
This function drops you into the debugger at the call site. Specifically, it calls :func:`sys.breakpointhook`, passing ``args`` and ``kws`` straight through. By default, ``sys.breakpointhook()`` calls :func:`pdb.set_trace` expecting no arguments. In this case, it is purely a convenience function so you don't have to explicitly import :mod:`pdb` or type as much code to enter the debugger. However, :func:`sys.breakpointhook` can be set to some other function and :func:`breakpoint` will automatically call that, allowing you to drop into the debugger of choice. If :func:`sys.breakpointhook` is not accessible, this function will raise :exc:`RuntimeError`.
By default, the behavior of :func:`breakpoint` can be changed with the :envvar:`PYTHONBREAKPOINT` environment variable. See :func:`sys.breakpointhook` for usage details.
The argument *optimize* specifies the optimization level of the compiler; the default value of ``-1`` selects the optimization level of the interpreter as given by :option:`-O` options. Explicit levels are ``0`` (no optimization; ``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false) or ``2`` (docstrings are removed too).
Argumen *optimize* menentukan tingkat optimisasi *compiler*; nilai default ``-1`` memilih tingkat optimisasi interpreter seperti yang diberikan oleh opsi :option:`-O`. Level eksplisitnya adalah ``0`` (tidak ada optimisasi; ``__debug__`` bernilai benar), ``1`` (*asserts* dihapus, ``__debug__`` bernilai salah) atau ``2`` (*docstrings* juga dihapus ).
The default :func:`dir` mechanism behaves differently with different types of objects, as it attempts to produce the most relevant, rather than complete, information:
Mekanisme bawaan :func:`dir` berperilaku berbeda dengan berbagai jenis objek, karena berusaha menghasilkan informasi yang paling relevan, dibanding lengkap,:
Return an enumerate object. *iterable* must be a sequence, an :term:`iterator`, or some other object which supports iteration. The :meth:`~iterator.__next__` method of the iterator returned by :func:`enumerate` returns a tuple containing a count (from *start* which defaults to 0) and the values obtained from iterating over *iterable*.
Kembalikan objek enumerasi. *iterable* harus berupa urutan, sebuah :term:`iterator`, atau objek lain yang mendukung iterasi. The :meth:`~iterator.__next__` metode iterator dikembalikan oleh :func:`enumerate` mengembalikan tuple yang berisi hitungan (dari *start* yang bawaan ke 0) dan nilai yang diperoleh dari mengelilingi *iterable*.
The global namespace (default: ``None``).
The local namespace (default: ``None``).
The *source* argument is parsed and evaluated as a Python expression (technically speaking, an :ref:`expression list <exprlists>`) using the *globals* and *locals* mappings as global and local namespace. If the *globals* dictionary is present and does not contain a value for the key ``__builtins__``, a reference to the dictionary of the built-in module :mod:`builtins` is inserted under that key before *source* is parsed. Overriding ``__builtins__`` can be used to restrict or change the available names, but this is **not** a security mechanism: the executed code can still access all builtins. If the *locals* mapping is omitted it defaults to the *globals* dictionary. If both mappings are omitted, the source is executed with the *globals* and *locals* in the environment where :func:`eval` is called. Note, *eval()* will only have access to the :term:`nested scopes <nested scope>` (non-locals) in the enclosing environment if they are already referenced in the scope that is calling :func:`eval` (e.g. via a :keyword:`nonlocal` statement).
The semantics of the default *locals* namespace have been adjusted as described for the :func:`locals` builtin.
The default *locals* act as described for function :func:`locals` below. Pass an explicit *locals* dictionary if you need to see effects of the code on *locals* after function :func:`exec` returns.
The default *format_spec* is an empty string which usually gives the same effect as calling :func:`str(value) <str>`.
Default *format_spec* adalah string kosong yang biasanya memberikan efek yang sama dengan memanggil :func:`str(value) <str>`.
Return the value of the named attribute of *object*. *name* must be a string. If the string is the name of one of the object's attributes, the result is the value of that attribute. For example, ``getattr(x, 'foobar')`` is equivalent to ``x.foobar``. If the named attribute does not exist, *default* is returned if provided, otherwise :exc:`AttributeError` is raised. *name* need not be a Python identifier (see :func:`setattr`).
A base-n integer string contains digits, each representing a value from 0 to n-1. The values 0--9 can be represented by any Unicode decimal digit. The values 10--35 can be represented by ``a`` to ``z`` (or ``A`` to ``Z``). The default *base* is 10. The allowed bases are 0 and 2--36. Base-2, -8, and -16 strings can be optionally prefixed with ``0b``/``0B``, ``0o``/``0O``, or ``0x``/``0X``, as with integer literals in code. For base 0, the string is interpreted in a similar way to an :ref:`integer literal in code <integers>`, in that the actual base is 2, 8, 10, or 16 as determined by the prefix. Base 0 also disallows leading zeros: ``int('010', 0)`` is not legal, while ``int('010')`` and ``int('010', 8)`` are.
There are two optional keyword-only arguments. The *key* argument specifies a one-argument ordering function like that used for :meth:`list.sort`. The *default* argument specifies an object to return if the provided iterable is empty. If the iterable is empty and *default* is not provided, a :exc:`ValueError` is raised.
Ada dua opsional hanya argumen kata kunci *keyword arguments*. Argumen *key* menentukan fungsi pengurutan satu argumen seperti yang digunakan untuk :meth:`list.sort`. Argumen *default* menentukan objek yang akan dikembalikan jika yang disediakan itu kosong. Jika iterable kosong dan *default* tidak disediakan, :exc:`ValueError` akan dimunculkan.
Added the *default* keyword-only parameter.
Retrieve the next item from the :term:`iterator` by calling its :meth:`~iterator.__next__` method. If *default* is given, it is returned if the iterator is :term:`exhausted`, otherwise :exc:`StopIteration` is raised.
*mode* is an optional string that specifies the mode in which the file is opened. It defaults to ``'r'`` which means open for reading in text mode. Other common values are ``'w'`` for writing (truncating the file if it already exists), ``'x'`` for exclusive creation, and ``'a'`` for appending (which on *some* Unix systems, means that *all* writes append to the end of the file regardless of the current seek position). In text mode, if *encoding* is not specified, UTF-8 is used by default; if :ref:`Python UTF-8 Mode <utf8-mode>` is disabled, :func:`locale.getencoding` is called to get the current locale encoding. (For reading and writing raw bytes use binary mode and leave *encoding* unspecified.) The available modes are:
open for reading (default)
terbuka untuk membaca (bawaan)
text mode (default)
mode teks (bawaan)
The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and ``'r+b'`` open the file with no truncation.
As mentioned in the :ref:`io-overview`, Python distinguishes between binary and text I/O. Files opened in binary mode (including ``'b'`` in the *mode* argument) return contents as :class:`bytes` objects without any decoding. In text mode (the default, or when ``'t'`` is included in the *mode* argument), the contents of the file are returned as :class:`str`, the bytes having been first decoded using the default encoding or using the specified *encoding* if given.
*buffering* is an optional integer used to set the buffering policy. Pass 0 to switch buffering off (only allowed in binary mode), 1 to select line buffering (only usable when writing in text mode), and an integer > 1 to indicate the size in bytes of a fixed-size chunk buffer. Note that specifying a buffer size this way applies for binary buffered I/O, but ``TextIOWrapper`` (i.e., files opened with ``mode='r+'``) would have another buffering. To disable buffering in ``TextIOWrapper``, consider using the ``write_through`` flag for :func:`io.TextIOWrapper.reconfigure`. When no *buffering* argument is given, the default buffering policy works as follows:
Binary files are buffered in fixed-size chunks; the size of the buffer is ``max(min(blocksize, 8 MiB), DEFAULT_BUFFER_SIZE)`` when the device block size is available. On most systems, the buffer will typically be 128 kilobytes long.
*encoding* is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is UTF-8; if :ref:`Python UTF-8 Mode <utf8-mode>` is disabled, the default is platform-dependent (whatever :func:`locale.getencoding` returns). Any :term:`text encoding` supported by Python can be used, and ``encoding="locale"`` specifies the current locale encoding explicitly. See the :mod:`codecs` module for the list of supported encodings.
When writing output to the stream, if *newline* is ``None``, any ``'\n'`` characters written are translated to the system default line separator, :data:`os.linesep`. If *newline* is ``''`` or ``'\n'``, no translation takes place. If *newline* is any of the other legal values, any ``'\n'`` characters written are translated to the given string.
Saat menulis keluaran ke aliran *stream*, jika *newline* adalah ``None``, setiap karakter ``'\n'`` yang ditulis diterjemahkan ke pemisah garis bawaan sistem, :data:`os.linesep`. Jika *newline* adalah ``''`` atau ``'\n'``, tidak ada terjemahan yang terjadi. Jika *newline* adalah salah satu dari nilai legal lainnya, setiap karakter ``'\n'`` yang ditulis diterjemahkan ke string yang diberikan.
If *closefd* is ``False`` and a file descriptor rather than a filename was given, the underlying file descriptor will be kept open when the file is closed. If a filename is given *closefd* must be ``True`` (the default); otherwise, an error will be raised.
UTF-8 is now the default encoding, instead of the platform-dependent locale encoding (:pep:`686`).
All non-keyword arguments are converted to strings like :func:`str` does and written to the stream, separated by *sep* and followed by *end*. Both *sep* and *end* must be strings; they can also be ``None``, which means to use the default values. If no *objects* are given, :func:`print` will just write *end*.
Semua argumen non-kata kunci dikonversi ke string seperti :func:`str` dan ditulis ke aliran *stream*, dipisahkan oleh *sep* dan diikuti oleh *end*. Baik *sep* dan *end* harus berupa string; mereka juga bisa ``None``, yang berarti menggunakan nilai bawaan. Jika tidak ada *objects* yang diberikan, :func:`print` hanya akan menulis *end*.
Return a new unique sentinel object. *name* must be a :class:`str`, and is used by default as the returned object's representation::
MISSING = sentinel("MISSING")
def next_value(default: int | MISSING = MISSING):
...
Return a :term:`slice` object representing the set of indices specified by ``range(start, stop, step)``. The *start* and *step* arguments default to ``None``.
These read-only attributes are set to the argument values (or their default). They have no other explicit functionality; however, they are used by NumPy and other third-party packages.
*key* specifies a function of one argument that is used to extract a comparison key from each element in *iterable* (for example, ``key=str.lower``). The default value is ``None`` (compare the elements directly).
*key* menentukan sebuah fungsi dari satu argumen yang digunakan untuk mengekstrak kunci perbandingan dari setiap elemen di *iterable* (misalnya, ``key=str.lower``). Nilai bawaannya adalah ``None`` (bandingkan elemen secara langsung).
By default, :func:`zip` stops when the shortest iterable is :term:`exhausted`. It will ignore the remaining items in the longer iterables, cutting off the result to the length of the shortest iterable::
Unlike the default behavior, it raises a :exc:`ValueError` if one iterable is :term:`exhausted` before the others:
This function is invoked by the :keyword:`import` statement. It can be replaced (by importing the :mod:`builtins` module and assigning to ``builtins.__import__``) in order to change semantics of the :keyword:`!import` statement, but doing so is **strongly** discouraged as it is usually simpler to use import hooks (see :pep:`302`) to attain the same goals and does not cause issues with code which assumes the default import implementation is in use. Direct use of :func:`__import__` is also discouraged in favor of :func:`importlib.import_module`.
Fungsi ini dipanggil oleh pernyataan :keyword:`import`. Itu dapat diganti (dengan mengimpor modul :mod:`builtins` dan mengisi ke ``builtins.__import__``) untuk mengubah semantik pernyataan :keyword:`!import`, tetapi melakukannya **strongly** atau tidak disarankan karena biasanya lebih mudah menggunakan kait impor (lihat :pep:`302`) untuk mencapai tujuan yang sama dan tidak menyebabkan masalah dengan kode yang mengasumsikan implementasi impor standar sedang digunakan. Penggunaan langsung :func:`__import__` juga tidak disarankan untuk kepentingan :func:`importlib.import_module`.
*level* specifies whether to use absolute or relative imports. ``0`` (the default) means only perform absolute imports. For relative imports, ``1`` refers to the current package, ``2`` to its parent package, and so on (see :pep:`328` for details).
Negative values for *level* are no longer supported (which also changes the default value to 0).
Nilai negatif untuk *level* tidak lagi didukung (juga mengubah nilai default menjadi 0).