Teks sumber — English
Terjemahan — Bahasa Indonesia
Return the absolute value of a number. The argument may be an integer, a floating-point number, or an object implementing :meth:`~object.__abs__`. If the argument is a complex number, its magnitude is returned.
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.
As :func:`repr`, return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by :func:`repr` using ``\x``, ``\u``, or ``\U`` escapes. This generates a string similar to that returned by :func:`repr` in Python 2.
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*.
Otherwise, if the argument is an integer or a floating-point number, a floating-point number with the same value (within Python's floating-point precision) is returned. If the argument is outside the range of a Python float, an :exc:`OverflowError` will be raised.
If no argument is given, ``0.0`` is returned.
Jika tidak ada argumen yang diberikan, dikembalikan sebagai ``0.0``.
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`).
Return an :term:`iterator` object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, the single argument must be a collection object which supports the :term:`iterable` protocol (the :meth:`~object.__iter__` method), or it must support the sequence protocol (the :meth:`~object.__getitem__` method with integer arguments starting at ``0``). If it does not support either of those protocols, :exc:`TypeError` is raised. If the second argument, *sentinel*, is given, then the first argument must be a callable object. The iterator created in this case will call *callable* with no arguments for each call to its :meth:`~iterator.__next__` method; if the value returned is equal to *sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be returned.
In all of the above cases, each call to ``locals()`` in a given frame of execution will return the *same* mapping object. Changes made through the mapping object returned from ``locals()`` will be visible as assigned, reassigned, or deleted local variables, and assigning, reassigning, or deleting local variables will immediately affect the contents of the returned mapping object.
In an :term:`optimized scope` (including functions, generators, and coroutines), each call to ``locals()`` instead returns a fresh dictionary containing the current bindings of the function's local variables and any nonlocal cell references. In this case, name binding changes made via the returned dict are *not* written back to the corresponding local variables or nonlocal cell references, and assigning, reassigning, or deleting local variables and nonlocal cell references does *not* affect the contents of previously returned dictionaries.
As part of :pep:`667`, the semantics of mutating the mapping objects returned from this function are now defined. The behavior in :term:`optimized scopes <optimized scope>` is now as described above. Aside from being defined, the behaviour in other scopes remains unchanged from previous versions.
If one positional argument is provided, it should be an :term:`iterable`. The largest item in the iterable is returned. If two or more positional arguments are provided, the largest of the positional arguments is returned.
Jika satu argumen posisi disediakan, itu harus berupa :term:`iterable`. Item terbesar di *iterable* dikembalikan. Jika dua atau lebih argumen posisi disediakan, argumen posisi terbesar dikembalikan.
If one positional argument is provided, it should be an :term:`iterable`. The smallest item in the iterable is returned. If two or more positional arguments are provided, the smallest of the positional arguments is returned.
Jika satu argumen posisi disediakan, itu harus berupa :term:`iterable`. Item terkecil di *iterable* dikembalikan. Jika dua atau lebih argumen posisional disediakan, argumen posisional terkecil akan dikembalikan.
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.
*file* is a :term:`path-like object` giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to ``False``.)
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.
When reading input from the stream, if *newline* is ``None``, universal newlines mode is enabled. Lines in the input can end in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these are translated into ``'\n'`` before being returned to the caller. If it is ``''``, universal newlines mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated.
Saat membaca masukan dari aliran *stream*, jika *newline* adalah ``None``, mode universal baris baru diaktifkan. Baris dalam masukan dapat diakhiri dengan ``'\n'``, ``'\r'``, atau ``'\r\n'``, dan ini diterjemahkan ke dalam ``'\n'`` sebelum dikembalikan ke pemanggil. Jika ``''``, mode baris baru universal diaktifkan, tetapi akhir baris dikembalikan ke pemanggil yang tidak diterjemahkan. Jika memiliki salah satu nilai legal lainnya, jalur masukan hanya diakhiri oleh string yang diberikan, dan akhir baris dikembalikan ke pemanggil yang tidak diterjemahkan.
The type of :term:`file object` returned by the :func:`open` function depends on the mode. When :func:`open` is used to open a file in a text mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of :class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used to open a file in a binary mode with buffering, the returned class is a subclass of :class:`io.BufferedIOBase`. The exact class varies: in read binary mode, it returns an :class:`io.BufferedReader`; in write binary and append binary modes, it returns an :class:`io.BufferedWriter`, and in read/write mode, it returns an :class:`io.BufferedRandom`. When buffering is disabled, the raw stream, a subclass of :class:`io.RawIOBase`, :class:`io.FileIO`, is returned.
Tipe :term:`file object` yang dikembalikan oleh fungsi :func:`open` tergantung pada mode. Ketika :func:`open` digunakan untuk membuka berkas dalam mode teks (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, dll.), ia mengembalikan subkelas dari :class:`io.TextIOBase` (khusus :class:`io.TextIOWrapper`). Ketika digunakan untuk membuka file dalam mode biner dengan *buffering*, kelas yang dikembalikan adalah subkelas dari :class:`io.BufferedIOBase`. Kelas yang tepat bervariasi: dalam mode baca biner, ia mengembalikan :class:`io.BufferedReader`; dalam mode tulis biner dan *append* biner, ia mengembalikan sebuah :class:`io.BufferedWriter`, dan dalam mode baca/tulis, ia mengembalikan sebuah :class:`io.BufferedRandom`. Ketika *buffering* dinonaktifkan, aliran tak diproses *raw stream*, subkelas dari :class:`io.RawIOBase`, :class:`io.FileIO`, dikembalikan.
For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must also be of integer type and *mod* must be nonzero. If *mod* is present and *exp* is negative, *base* must be relatively prime to *mod*. In that case, ``pow(inv_base, -exp, mod)`` is returned, where *inv_base* is an inverse to *base* modulo *mod*.
Untuk operan :class:`int` *base* dan *exp*, jika *mod* ada, *mod* juga harus bertipe integer dan *mod* harus bukan nol. Jika *mod* ada dan *exp* negatif, *basis* harus relatif prima ke *mod*. Dalam kasus itu, ``pow(inv_base, -exp, mod)`` dikembalikan, di mana *inv_base* adalah kebalikan dari *base* *modulo* *mod*.
The returned property object also has the attributes ``fget``, ``fset``, and ``fdel`` corresponding to the constructor arguments.
Properti dari objek yang dikembalikan juga memiliki atribut ``fget``, ``fset``, dan ``fdel`` yang sesuai dengan argumen pembangun *constructor*.
Return a new unique sentinel object. *name* must be a :class:`str`, and is used by default as the returned object's representation::
If the second argument is omitted, the super object returned is unbound. If the second argument is an object, ``isinstance(obj, type)`` must be true. If the second argument is a type, ``issubclass(type2, type)`` must be true (this is useful for classmethods).
Jika argumen kedua dihilangkan, objek super yang dikembalikan tidak terikat *unbound*. Jika argumen kedua adalah objek, ``isinstance(obj, type)`` harus benar. Jika argumen kedua adalah tipe, ``issubclass(type2, type)`` harus benar (ini berguna untuk metode-metode kelas).
With one argument, return the type of an *object*. The return value is a type object and generally the same object as returned by :attr:`object.__class__`.
When the *name* variable is of the form ``package.module``, normally, the top-level package (the name up till the first dot) is returned, *not* the module named by *name*. However, when a non-empty *fromlist* argument is given, the module named by *name* is returned.
Ketika variabel *name* dalam bentuk ``package.module``, biasanya, paket tingkat atas (nama hingga titik pertama) dikembalikan, *not* modul dinamai dengan *name*. Namun, ketika argumen tidak-kosong *fromlist * diberikan, modul bernama oleh *name* dikembalikan.
Here, the ``spam.ham`` module is returned from :func:`__import__`. From this object, the names to import are retrieved and assigned to their respective names.
Di sini, modul ``spam.ham`` dikembalikan dari :func:`__import__`. Dari objek ini, nama yang akan diimpor diambil dan diisikan ke nama masing-masing.