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
If the prefix "0b" is desired or not, you can use either of the following ways.
The optional *source* parameter can be used to initialize the array in a few different ways:
Parameter opsional *source* dapat digunakan untuk menginisialisasi array dengan beberapa cara berbeda:
If it is an object conforming to the :ref:`buffer interface <bufferobjects>`, a read-only buffer of the object will be used to initialize the bytes array.
Jika itu adalah objek yang sesuai dengan :ref:`buffer interface <bufferobjects>`, buffer yang hanya baca dari objek tersebut akan digunakan untuk menginisialisasi array byte.
If it is an *iterable*, it must be an iterable of integers in the range ``0 <= x < 256``, which are used as the initial contents of the array.
Jika ini adalah *iterable*, itu harus iterable dari bilangan bulat dalam kisaran ``0 <= x < 256``, yang digunakan sebagai konten awal array.
A class method receives the class as an implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom::
The *filename* argument should give the file from which the code was read; pass some recognizable value if it wasn't read from a file (``'<string>'`` is commonly used).
Argumen *filename* harus memberikan berkas dari mana kode dibaca; berikan nilai yang dapat dikenali jika tidak dibaca dari berkas (``'<string>'`` biasa digunakan).
The optional arguments *flags* and *dont_inherit* control which :ref:`compiler options <ast-compiler-flags>` should be activated and which :ref:`future features <future>` should be allowed. If neither is present (or both are zero) the code is compiled with the same flags that affect the code that is calling :func:`compile`. If the *flags* argument is given and *dont_inherit* is not (or is zero) then the compiler options and the future statements specified by the *flags* argument are used in addition to those that would be used anyway. If *dont_inherit* is a non-zero integer then the *flags* argument is it -- the flags (future features and compiler options) in the surrounding code are ignored.
Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode does not have to end in a newline anymore. Added the *optimize* parameter.
If two arguments are provided or keyword arguments are used, each argument may be any numeric type (including complex). If both arguments are real numbers, return a complex number with the real component *real* and the imaginary component *imag*. If both arguments are complex numbers, return a complex number with the real component ``real.real-imag.imag`` and the imaginary component ``real.imag+imag.real``. If one of arguments is a real number, only its real component is used in the above expressions.
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.
This function executes arbitrary code. Calling it with untrusted user-supplied input will lead to security vulnerabilities.
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).
This function can also be used to execute arbitrary code objects (such as those created by :func:`compile`). In this case, pass a code object instead of a string. If the code object has been compiled with ``'exec'`` as the *mode* argument, :func:`eval`\'s return value will be ``None``.
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`.
This function supports dynamic execution of Python code. *source* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). If it is a code object, it is simply executed. In all cases, the code that's executed is expected to be valid as file input (see the section :ref:`file-input` in the Reference Manual). Be aware that the :keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements may not be used outside of function definitions even within the context of code passed to the :func:`exec` function. The return value is ``None``.
In all cases, if the optional parts are omitted, the code is executed in the current scope. If only *globals* is provided, it must be a dictionary (and not a subclass of dictionary), which will be used for both the global and the local variables. If *globals* and *locals* are given, they are used for the global and local variables, respectively. If provided, *locals* can be any mapping object. Remember that at the module level, globals and locals are the same dictionary.
If the *globals* dictionary 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. 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.
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`.
Convert a *value* to a "formatted" representation, as controlled by *format_spec*. The interpretation of *format_spec* will depend on the type of the *value* argument; however, there is a standard formatting syntax that is used by most built-in types: :ref:`formatspec`.
Return the hash value of the object (if it has one). Hash values are integers. They are used to quickly compare dictionary keys during a dictionary lookup. Numeric values that compare equal have the same hash value (even if they are of different types, as is the case for 1 and 1.0).
Kembalikan nilai hash objek (jika ada). Nilai hash adalah bilangan bulat. Mereka digunakan untuk dengan cepat membandingkan kunci kamus *dictionary keys* selama pencarian dictionary. Nilai numerik yang membandingkan sama memiliki nilai hash yang sama (bahkan jika mereka dari jenis yang berbeda, seperti halnya untuk 1 dan 1.0).
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Meminta sistem bantuan bawaan. (Fungsi ini dimaksudkan untuk penggunaan interaktif.) Jika tidak ada argumen yang diberikan, sistem bantuan interaktif dimulai pada konsol interpreter. Jika argumennya adalah string, maka string tersebut dicari sebagai nama modul, fungsi, kelas, metode, kata kunci, atau topik dokumentasi, dan halaman bantuan dicetak pada konsol. Jika argumennya adalah objek jenis apa pun, halaman bantuan tentang objek tersebut dihasilkan.
If you want to convert an integer number to an uppercase or lower hexadecimal string with prefix or not, you can use either of the following ways:
Jika Anda ingin mengonversi bilangan bulat menjadi string heksadesimal huruf besar atau huruf kecil dengan awalan atau tidak, Anda dapat menggunakan salah satu dari cara berikut:
To obtain a hexadecimal string representation for a float, use the :meth:`float.hex` method.
Untuk mendapatkan representasi string heksadesimal untuk float, gunakan metode :meth:`float.hex`.
If the :mod:`readline` module was loaded, then :func:`input` will use it to provide elaborate line editing and history features.
Jika modul :mod:`readline` dimuat, maka :func:`input` akan menggunakannya untuk menyediakan fitur pengeditan baris dan riwayat.
If *base* is not an instance of :class:`int` and the *base* object has a :meth:`base.__index__ <object.__index__>` method, that method is called to obtain an integer for the base. Previous versions used :meth:`base.__int__ <object.__int__>` instead of :meth:`base.__index__ <object.__index__>`.
Jika *base* bukan turunan dari :class:`int` dan objek *base* memiliki metode :meth:`base.__index__ <object.__index__>`, metode itu dipanggil untuk mendapatkan integer untuk basis. Versi sebelumnya menggunakan <object.__int__>` alih-alih :meth: `base.__index__ <object.__index__>`.
One useful application of the second form of :func:`iter` is to build a block-reader. For example, reading fixed-width blocks from a binary database file until the end of file is reached::
Salah satu kegunaan dari bentuk kedua dari :func:`iter` adalah untuk membangun pembaca blok. Misalnya, membaca blok dengan lebar tetap dari berkas basis data biner hingga akhir file tercapai::
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.
If you want to convert an integer number to an octal string either with the prefix "0o" or not, you can use either of the following ways.
Open *file* and return a corresponding :term:`file object`. If the file cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more examples of how to use this function.
Buka *file* dan mengembalikan yang sesuai dengan :term:`file object`. Jika file tersebut tidak dapat dibuka, sebuah :exc:`OSError` akan dinaikkan. Lihat :ref:`tut-files` untuk contoh yang lebih banyak terkait bagaimana menggunakan fungsi ini.
*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:
*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:
"Interactive" text files (files for which :meth:`~io.IOBase.isatty` returns ``True``) use line buffering. Other text files use the policy described above for binary files.
Berkas teks "interactive" (berkas yang :meth:`~io.IOBase.isatty` mengembalikan ``True``) menggunakan *line buffering*. File teks lainnya menggunakan kebijakan yang dijelaskan di atas untuk file biner.
*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.
*errors* is an optional string that specifies how encoding and decoding errors are to be handled—this cannot be used in binary mode. A variety of standard error handlers are available, though any error handling name that has been registered with :func:`codecs.register_error` is also valid. The standard names can be found in :ref:`error-handlers`.
A custom opener can be used by passing a callable as *opener*. The underlying file descriptor for the file object is then obtained by calling *opener* with (*file*, *flags*). *opener* must return an open file descriptor (passing :mod:`os.open` as *opener* results in functionality similar to passing ``None``).
Pembuka khusus dapat digunakan dengan melewatkan *callable* sebagai *opener*. Deskriptor berkas yang mendasari untuk objek berkas kemudian diperoleh dengan memanggil *opener* dengan (*file*, *flags*). *opener* harus mengembalikan deskriptor berkas terbuka (lewat :mod:`os.open` sebagai *opener* menghasilkan fungsionalitas yang mirip dengan melewatkan ``None``).
The following example uses the :ref:`dir_fd <dir_fd>` parameter of the :func:`os.open` function to open a file relative to a given directory::
Contoh berikut menggunakan parameter :ref:`dir_fd <dir_fd>` dari fungsi :func:`os.open` untuk membuka berkas relatif ke direktori yang diberikan::
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.
:exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`.
:exc:`IOError` sebelumnya ditimbulkan, sekarang merupakan alias dari :exc:`OSError`.
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*.
The *file* argument must be an object with a ``write(string)`` method; if it is not present or ``None``, :data:`sys.stdout` will be used. Since printed arguments are converted to text strings, :func:`print` cannot be used with binary mode file objects. For these, use ``file.write(...)`` instead.
Argumen *file* harus berupa objek dengan metode ``write(string)``; jika tidak ada atau ``None``, :data:`sys.stdout` akan digunakan. Karena argumen yang dicetak dikonversi ke string teks, :func:`print` tidak dapat digunakan dengan objek file mode biner. Untuk ini, gunakan ``file.write(...)`` sebagai gantinya.
A typical use is to define a managed attribute ``x``::
Penggunaan khasnya untuk mendefinisikan atribut yang dikelola ``x``::
Return a new unique sentinel object. *name* must be a :class:`str`, and is used by default as the returned object's representation::
The optional *repr* argument can be used to specify a different representation::
Sentinels are conventionally assigned to a variable with a matching name. Sentinels defined in this way can be used in :term:`type hints <type hint>`::
Sentinel objects support the :ref:`| <bitwise>` operator for use in type expressions.
Slice objects are also generated when :ref:`slicing syntax <slicings>` is used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``.
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).
Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a *key* function.
Gunakan :func:`functools.cmp_to_key` untuk mengubah fungsi *cmp* gaya lama menjadi fungsi *key*.
The sort algorithm uses only ``<`` comparisons between items. While defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` recommends that all six :ref:`rich comparisons <comparisons>` be implemented. This will help avoid bugs when using the same data with other ordering tools such as :func:`max` that rely on a different underlying method. Implementing all six comparisons also helps avoid confusion for mixed type comparisons which can call the reflected :meth:`~object.__gt__` method.
A static method does not receive an implicit first argument. To declare a static method, use this idiom::
Metode statis tidak menerima argumen implisit pertama. Untuk mendeklarasikan metode statis, gunakan idiom ini::
A static method can be called either on the class (such as ``C.f()``) or on an instance (such as ``C().f()``). Moreover, the static method :term:`descriptor` is also callable, so it can be used in the class definition (such as ``f()``).
Static methods in Python are similar to those found in Java or C++. Also, see :deco:`classmethod` for a variant that is useful for creating alternate class constructors.
Like all decorators, it is also possible to call ``staticmethod`` as a regular function and do something with its result. This is needed in some cases where you need a reference to a function from a class body and you want to avoid the automatic transformation to instance method. For these cases, use this idiom::
Seperti semua dekorator, dimungkinkan juga untuk memanggil ``staticmethod`` sebagai fungsi biasa dan melakukan sesuatu dengan hasilnya. Ini diperlukan dalam beberapa kasus di mana Anda memerlukan referensi ke fungsi dari badan kelas dan Anda ingin menghindari transformasi otomatis ke metode *instance*. Untuk kasus ini, gunakan idiom ini::
For some use cases, there are good alternatives to :func:`sum`. The preferred, fast way to concatenate a sequence of strings is by calling ``''.join(sequence)``. To add floating-point values with extended precision, see :func:`math.fsum`\. To concatenate a series of iterables, consider using :func:`itertools.chain`.
Return a proxy object that delegates method calls to a parent or sibling class of *type*. This is useful for accessing inherited methods that have been overridden in a class.
Kembalikan objek proxy yang mendelegasikan panggilan metode ke kelas orang tua atau saudara dari *type*. Ini berguna untuk mengakses metode yang diwariskan yang telah ditimpa di suatu kelas.
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.
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).
There are two typical use cases for *super*. In a class hierarchy with single inheritance, *super* can be used to refer to parent classes without naming them explicitly, thus making the code more maintainable. This use closely parallels the use of *super* in other programming languages.
Ada dua kasus penggunaan khas untuk *super*. Dalam hierarki kelas dengan pewarisan tunggal *single inheritance*, *super* dapat digunakan untuk merujuk ke kelas induk tanpa menyebutkannya secara eksplisit, sehingga membuat kode lebih mudah dikelola. Penggunaan ini sangat mirip dengan penggunaan *super* dalam bahasa pemrograman lain.
The second use case is to support cooperative multiple inheritance in a dynamic execution environment. This use case is unique to Python and is not found in statically compiled languages or languages that only support single inheritance. This makes it possible to implement "diamond diagrams" where multiple base classes implement the same method. Good design dictates that such implementations have the same calling signature in every case (because the order of calls is determined at runtime, because that order adapts to changes in the class hierarchy, and because that order can include sibling classes that are unknown prior to runtime).
For both use cases, a typical superclass call looks like this::
Untuk kedua kasus penggunaan, pemanggilan *superclass* yang khas terlihat seperti ini::
In addition to method lookups, :func:`super` also works for attribute lookups. One possible use case for this is calling :term:`descriptors <descriptor>` in a parent or sibling class.
Selain pencarian metode, :func:`super` juga berfungsi untuk pencarian atribut. Salah satu kemungkinan kasus penggunaan ini adalah pemanggilan :term:`descriptors <descriptor>` di kelas induk atau saudara kandung.
Also note that, aside from the zero argument form, :func:`super` is not limited to use inside methods. The two argument form specifies the arguments exactly and makes the appropriate references. The zero argument form only works inside a class definition, as the compiler fills in the necessary details to correctly retrieve the class being defined, as well as accessing the current instance for ordinary methods.
Juga perhatikan bahwa, selain dari bentuk tanpa argumen, :func:`super` tidak terbatas untuk menggunakan metode di dalam. Bentuk dua argumen menentukan argumen dengan tepat dan membuat referensi yang sesuai. Bentuk tanpa argumen hanya bekerja di dalam definisi kelas, karena *compiler* mengisi rincian yang diperlukan untuk mengambil kelas yang didefinisikan dengan benar, serta mengakses *instance* saat ini untuk metode biasa.
The :func:`isinstance` built-in function is recommended for testing the type of an object, because it takes subclasses into account.
Fungsi bawaan :func:`isinstance` direkomendasikan untuk menguji jenis objek, karena ia memperhitungkan subkelas.
Unlike a :keyword:`class` statement, the three argument form does not call the metaclass ``__prepare__`` method (see :ref:`prepare`). Use :func:`types.new_class` to dynamically create a class using the appropriate metaclass.
Subclasses of :class:`!type` which don't override ``type.__new__`` may no longer use the one-argument form to get the type of an object.
Objects such as modules and instances have an updateable :attr:`~object.__dict__` attribute; however, other objects may have write restrictions on their :attr:`!__dict__` attributes (for example, classes use a :class:`types.MappingProxyType` to prevent direct dictionary updates).
One thing to consider is that the iterables passed to :func:`zip` could have different lengths; sometimes by design, and sometimes because of a bug in the code that prepared these iterables. Python offers three different approaches to dealing with this issue:
:func:`zip` is often used in cases where the iterables are assumed to be of equal length. In such cases, it's recommended to use the ``strict=True`` option. Its output is the same as regular :func:`zip`::
: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::
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`.
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.
*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).
Note how :func:`__import__` returns the toplevel module here because this is the object that is bound to a name by the :keyword:`import` statement.
Perhatikan caranya :func:`__import__` mengembalikan modul tingkat atas di sini karena ini adalah objek yang terikat pada nama oleh pernyataan :keyword:`import`.
If you simply want to import a module (potentially within a package) by name, use :func:`importlib.import_module`.
Jika Anda hanya ingin mengimpor sebuah modul (berpotensi dalam suatu paket) dengan nama, gunakan :func:`importlib.import_module`.
When the command line options :option:`-E` or :option:`-I` are being used, the environment variable :envvar:`PYTHONCASEOK` is now ignored.