Teks sumber — English
Terjemahan — Bahasa Indonesia
Return :const:`True` if the *object* argument appears callable, :const:`False` if not. If this returns ``True``, it is still possible that a call fails, but if it is ``False``, calling *object* will never succeed. Note that classes are callable (calling a class returns a new instance); instances are callable if their class has a :meth:`~object.__call__` method.
For other containers see the built-in :class:`frozendict`, :class:`list`, :class:`set`, and :class:`tuple` classes, as well as the :mod:`collections` module.
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.
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).
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`.
This is the ultimate base class of all other classes. It has methods that are common to all instances of Python classes. When the constructor is called, it returns a new featureless object. The constructor does not accept any arguments.
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`.
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).
Note that :func:`super` is implemented as part of the binding process for explicit dotted attribute lookups such as ``super().__getitem__(name)``. It does so by implementing its own :meth:`~object.__getattribute__` method for searching classes in a predictable order that supports cooperative multiple inheritance. Accordingly, :func:`super` is undefined for implicit lookups using statements or operators such as ``super()[name]``.
For practical suggestions on how to design cooperative classes using :func:`super`, see `guide to using super() <https://rhettinger.wordpress.com/2011/05/26/super-considered-super/>`_.
Untuk saran praktis tentang bagaimana merancang kelas kooperatif menggunakan :func:`super`, lihat `guide to using super() <https://rhettinger.wordpress.com/2011/05/26/super-considered-super/>`_.
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.
With three arguments, return a new type object. This is essentially a dynamic form of the :keyword:`class` statement. The *name* string is the class name and becomes the :attr:`~type.__name__` attribute. The *bases* tuple contains the base classes and becomes the :attr:`~type.__bases__` attribute; if empty, :class:`object`, the ultimate base of all classes, is added. The *dict* dictionary contains attribute and method definitions for the class body; it may be copied or wrapped before becoming the :attr:`~type.__dict__` attribute. The following two statements create identical :class:`!type` objects:
:ref:`Documentation on attributes and methods on classes <class-attrs-and-methods>`.
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).