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
Built-in functions
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.
Built-in Functions
Fungsi Bawaan
Hints: dynamic execution of statements is supported by the :func:`exec` function. The :func:`globals` and :func:`locals` functions return the current global and local dictionary, respectively, which may be useful to pass around for use by :func:`eval` or :func:`exec`.
When ``exec`` gets two separate objects as *globals* and *locals*, the code will be executed as if it were embedded in a class definition. This means functions and classes defined in the executed code will not be able to access variables assigned at the top level (as the "top level" variables are treated as class variables in a class definition).
The built-in functions :func:`globals` and :func:`locals` return the current global and local namespace, respectively, which may be useful to pass around for use as the second and third argument to :func:`exec`.
Return the dictionary implementing the current module namespace. For code within functions, this is set when the function is defined and remains the same regardless of where the function is called.
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.
This code is exactly equivalent to the first example. Be sure to give the additional functions the same name as the original property (``x`` in this case.)
Kode ini persis sama dengan contoh pertama. Pastikan untuk memberi fungsi tambahan nama yang sama dengan properti asli (``x`` dalam kasus ini.)
Static methods now inherit the method attributes (:attr:`~function.__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__` and :attr:`~function.__annotations__`), have a new ``__wrapped__`` attribute, and are now callable as regular functions.
When called directly within an ordinary method of a class, both arguments may be omitted ("zero-argument :func:`!super`"). In this case, *type* will be the enclosing class, and *object_or_type* will be the first argument of the immediately enclosing function (typically ``self``). Zero-argument :func:`!super` will not work as expected within nested functions, including generator expressions, which implicitly create nested functions.