Pelokalan
Python ID
id en
Masuk
Proyek
builtins__functions.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.
Interpreter Python memiliki sejumlah fungsi dan tipe bawaan di dalamnya yang selalu tersedia. Mereka terdaftar di sini dalam urutan abjad.
|func-list|_
|func-list|_
For other containers see the built-in :class:`frozendict`, :class:`list`, :class:`set`, and :class:`tuple` classes, as well as the :mod:`collections` module.
Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object.
Tanpa argumen, kembalikan daftar *list* nama dalam lingkup lokal saat ini. Dengan argumen, mencoba untuk mengembalikan daftar *list* atribut yang valid untuk objek itu.
If the object has a method named :meth:`~object.__dir__`, this method will be called and must return the list of attributes. This allows objects that implement a custom :func:`~object.__getattr__` or :func:`~object.__getattribute__` function to customize the way :func:`dir` reports their attributes.
If the object does not provide :meth:`~object.__dir__`, the function tries its best to gather information from the object's :attr:`~object.__dict__` attribute, if defined, and from its type object. The resulting list is not necessarily complete and may be inaccurate when the object has a custom :func:`~object.__getattr__`.
If the object is a module object, the list contains the names of the module's attributes.
Jika objek adalah objek modul, daftar berisi nama-nama atribut modul.
If the object is a type or class object, the list contains the names of its attributes, and recursively of the attributes of its bases.
Jika objek adalah tipe atau objek kelas, daftar berisi nama atributnya, dan secara rekursif atribut dari basisnya.
Otherwise, the list contains the object's attributes' names, the names of its class's attributes, and recursively of the attributes of its class's base classes.
Jika tidak, daftar berisi nama atribut objek, nama atribut kelasnya, dan secara rekursif atribut dari kelas dasar kelasnya.
The resulting list is sorted alphabetically. For example:
Daftar yang dihasilkan diurutkan berdasarkan abjad. Sebagai contoh:
Because :func:`dir` is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its detailed behavior may change across releases. For example, metaclass attributes are not in the result list when the argument is a class.
Karena :func:`dir` disediakan terutama sebagai kenyamanan untuk digunakan pada prompt interaktif, ia mencoba untuk memasok sekumpulan nama yang menarik lebih dari sekedar untuk menyediakan sekumpulan nama yang didefinisikan secara ketat atau konsisten, dan perilakunya yang terperinci dapat berubah lintas rilis. Misalnya, atribut metaclass tidak ada dalam daftar hasil ketika argumennya adalah kelas.
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).
For other containers see the built-in :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple` classes, as well as the :mod:`collections` module.
For other containers see the built-in :class:`set`, :class:`list`, :class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module.
Untuk wadah *containers* lain lihat kelas-kelas bawaan :class:`set`, :class:`list`,: :class:`tuple`, dan :class:`dict`, serta modul :mod:`collections`.
Note that if a slash(/) appears in the parameter list of a function when invoking :func:`help`, it means that the parameters prior to the slash are positional-only. For more info, see :ref:`the FAQ entry on positional-only parameters <faq-positional-only-arguments>`.
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).
Mengembalikan panjang (jumlah item) suatu objek. Argumennya bisa berupa urutan (seperti string, byte, *tuple*, *list*, atau *range*) atau koleksi (seperti *dictionary*, set, atau *frozen set*).
Rather than being a function, :class:`list` is actually a mutable sequence type, as documented in :ref:`typesseq-list` and :ref:`typesseq`.
Alih-alih menjadi sebuah fungsi, :class:`list` sebenarnya adalah tipe urutan yang bisa berubah *mutable*, seperti yang didokumentasikan dalam :ref:`typesseq-list` dan :ref:`typesseq`.
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.
*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.
For other containers see the built-in :class:`frozenset`, :class:`list`, :class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module.
Untuk wadah *containers* lain lihat kelas-kelas bawaan :class:`frozenset`, :class:`list`, :class:`tuple`, dan :class:`dict`, juga modul :mod:`collections`.
Return a new sorted list from the items in *iterable*.
Kembalikan daftar baru yang diurutkan dari item di *iterable*.
*reverse* is a boolean value. If set to ``True``, then the list elements are sorted as if each comparison were reversed.
*reverse* adalah nilai *boolean*. Jika diatur ke ``True``, maka elemen list atau daftar diurutkan seolah-olah setiap perbandingan dibalik.
The :attr:`~type.__mro__` attribute of the class corresponding to *object_or_type* lists the method resolution search order used by both :func:`getattr` and :func:`super`. The attribute is dynamic and can change whenever the inheritance hierarchy is updated.
:func:`zip` is lazy: The elements won't be processed until the iterable is iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:`list`.
>>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum'])) [(0, 'fee'), (1, 'fi'), (2, 'fo')]
>>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True)) [('a', 1), ('b', 2), ('c', 3)]
:func:`zip` in conjunction with the ``*`` operator can be used to unzip a list::
:func:`zip` bersama dengan operator ``*`` dapat digunakan untuk *unzip* sebuah list atau daftar::
>>> x = [1, 2, 3] >>> y = [4, 5, 6] >>> list(zip(x, y)) [(1, 4), (2, 5), (3, 6)] >>> x2, y2 = zip(*zip(x, y)) >>> x == list(x2) and y == list(y2) True
The function imports the module *name*, potentially using the given *globals* and *locals* to determine how to interpret the name in a package context. The *fromlist* gives the names of objects or submodules that should be imported from the module given by *name*. The standard implementation does not use its *locals* argument at all and uses its *globals* only to determine the package context of the :keyword:`import` statement.
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.