Teks sumber — English
Terjemahan — Bahasa Indonesia
:func:`object`
:func:`object`
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.
Convert an integer number to a binary string prefixed with "0b". The result is a valid Python expression. If *integer* is not a Python :class:`int` object, it has to define an :meth:`~object.__index__` method that returns an integer. Some examples:
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.
Return a new "bytes" object which is an immutable sequence of integers in the range ``0 <= x < 256``. :class:`bytes` is an immutable version of :class:`bytearray` -- it has the same non-mutating methods and the same indexing and slicing behavior.
Bytes objects can also be created with literals, see :ref:`strings`.
Objek byte juga dapat dibuat dengan literal, lihat :ref:`strings`.
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.
A class method can be called either on the class (such as ``C.f()``) or on an instance (such as ``C().f()``). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.
Metode kelas dapat dipanggil baik pada kelas (seperti ``C.f()``) atau pada *instance* (seperti ``C().f()``). Instance diabaikan kecuali untuk kelasnya. Jika metode kelas dipanggil untuk kelas turunan, objek kelas turunan dilewatkan sebagai argumen pertama yang tersirat.
Compile the *source* into a code or AST object. Code objects can be executed by :func:`exec` or :func:`eval`. *source* can either be a normal string, a byte string, or an AST object. Refer to the :mod:`ast` module documentation for information on how to work with AST objects.
Kompilasi *source* menjadi kode atau objek AST. Objek kode dapat dieksekusi oleh :func:`exec` atau :func:`eval`. *source* dapat berupa string normal, string byte, atau objek AST. Rujuk ke dokumentasi modul :mod:`ast` untuk informasi tentang cara bekerja dengan objek AST.
It is possible to crash the Python interpreter with a sufficiently large/complex string when compiling to an AST object due to stack depth limitations in Python's AST compiler.
Dimungkinkan untuk membuat *crash* *interpreter* Python dengan string yang cukup besar/kompleks ketika dikompilasi ke objek AST karena batasan kedalaman tumpukan dalam kompiler AST Python.
If the argument is a number, the constructor serves as a numeric conversion like :class:`int` and :class:`float`. For a general Python object ``x``, ``complex(x)`` delegates to ``x.__complex__()``. If :meth:`~object.__complex__` is not defined then it falls back to :meth:`~object.__float__`. If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__index__`.
Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :meth:`~object.__float__` are not defined.
This is a relative of :func:`setattr`. The arguments are an object and a string. The string must be the name of one of the object's attributes. The function deletes the named attribute, provided the object allows it. For example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``. *name* need not be a Python identifier (see :func:`setattr`).
Create a new dictionary. The :class:`dict` object is the dictionary class. See also :ref:`typesmapping` for documentation about this class.
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__`.
The default :func:`dir` mechanism behaves differently with different types of objects, as it attempts to produce the most relevant, rather than complete, information:
Mekanisme bawaan :func:`dir` berperilaku berbeda dengan berbagai jenis objek, karena berusaha menghasilkan informasi yang paling relevan, dibanding lengkap,:
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.
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*.
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``.
Raises an :ref:`auditing event <auditing>` ``exec`` with the code object as the argument. Code compilation events may also be raised.
Memunculkan :ref:`auditing event <auditing>` ``exec`` dengan objek kode sebagai argumen. Kompilasi kode *events* juga dapat dimunculkan.
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.
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 *closure* argument specifies a closure--a tuple of cellvars. It's only valid when *source* is a code object containing :term:`free (closure) variables <closure variable>`. The length of the tuple must exactly match the length of the code object's :attr:`~codeobject.co_freevars` attribute.
For a general Python object ``x``, ``float(x)`` delegates to ``x.__float__()``. If :meth:`~object.__float__` is not defined then it falls back to :meth:`~object.__index__`.
Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not defined.
A call to ``format(value, format_spec)`` is translated to ``type(value).__format__(value, format_spec)`` which bypasses the instance dictionary when searching for the value's :meth:`~object.__format__` method. A :exc:`TypeError` exception is raised if the method search reaches :mod:`object` and the *format_spec* is non-empty, or if either the *format_spec* or the return value are not strings.
``object().__format__(format_spec)`` raises :exc:`TypeError` if *format_spec* is not an empty string.
``object().__format__(format_spec)`` menimbulkan :exc:`TypeError` jika *format_spec* bukan string kosong.
Create a new frozen dictionary. The :class:`frozendict` object is a built-in class. See also :ref:`typesmapping` for documentation about this class.
Return a new :class:`frozenset` object, optionally with elements taken from *iterable*. :class:`frozenset` is a built-in class. See also :ref:`types-set` for documentation about this class.
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`).
The arguments are an object and a string. The result is ``True`` if the string is the name of one of the object's attributes, ``False`` if not. (This is implemented by calling ``getattr(object, name)`` and seeing whether it raises an :exc:`AttributeError` or not.)
Argumen adalah objek dan string. Hasilnya adalah ``True`` jika string adalah nama salah satu atribut objek, ``False`` jika tidak. (Ini diimplementasikan dengan memanggil ``getattr(object, name)`` dan melihat apakah itu memunculkan :exc:`AttributeError` atau tidak.)
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).
For objects with custom :meth:`~object.__hash__` methods, note that :func:`hash` truncates the return value based on the bit width of the host machine.
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.
Convert an integer number to a lowercase hexadecimal string prefixed with "0x". If *integer* is not a Python :class:`int` object, it has to define an :meth:`~object.__index__` method that returns an integer. Some examples:
Return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same :func:`id` value.
Kembalikan "identity" suatu objek. Ini adalah bilangan bulat yang dijamin unik dan konstan untuk objek ini selama masa pakainya. Dua objek dengan masa hidup yang tidak tumpang tindih mungkin memiliki nilai yang sama :func:`id`.
This is the address of the object in memory.
Return an integer object constructed from a number or a string, or return ``0`` if no arguments are given.
If the argument defines :meth:`~object.__int__`, ``int(x)`` returns ``x.__int__()``. If the argument defines :meth:`~object.__index__`, it returns ``x.__index__()``. For floating-point numbers, this truncates towards zero.
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__>`.
Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not defined.
:func:`int` no longer delegates to the :meth:`~object.__trunc__` method.
Return ``True`` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or :term:`virtual <abstract base class>`) subclass thereof. If *object* is not an object of the given type, the function always returns ``False``. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a :ref:`types-union` of multiple types, return ``True`` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a :exc:`TypeError` exception is raised. :exc:`TypeError` may not be raised for an invalid type if an earlier check succeeds.
Return ``True`` if *cls* is a subclass (direct, indirect, or :term:`virtual <abstract base class>`) of *classinfo*. A class is considered a subclass of itself. *classinfo* may be a tuple of class objects (or recursively, other such tuples) or a :ref:`types-union`, in which case return ``True`` if *cls* is a subclass of any entry in *classinfo*. In any other case, a :exc:`TypeError` exception is raised.
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.
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*).
Return a mapping object representing the current local symbol table, with variable names as the keys, and their currently bound references as the values.
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.
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.
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.
Return a "memory view" object created from the given argument. See :ref:`typememoryview` for more information.
Kembalikan objek "memory view" yang dibuat dari argumen yang diberikan. Lihat :ref:`typememoryview` untuk informasi lebih lanjut.
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.
:class:`object` instances do *not* have :attr:`~object.__dict__` attributes, so you can't assign arbitrary attributes to an instance of :class:`object`.
Convert an integer number to an octal string prefixed with "0o". The result is a valid Python expression. If *integer* is not a Python :class:`int` object, it has to define an :meth:`~object.__index__` method that returns an integer. For example:
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.
*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.
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 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.
Support added to accept objects implementing :class:`os.PathLike`.
Dukungan ditambahkan untuk menerima objek yang mengimplementasikan :class:`os.PathLike`.
If the argument is a :class:`bytes` or :class:`bytearray` object of length 1, return its single byte value. For example, ``ord(b'a')`` returns the integer ``97``.
Print *objects* to the text stream *file*, separated by *sep* and followed by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as keyword arguments.
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 property object has ``getter``, ``setter``, and ``deleter`` methods usable as decorators that create a copy of the property with the corresponding accessor function set to the decorated function. This is best explained with an example:
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*.
The docstrings of property objects are now writeable.
docstrings dari properti objek-objek sekarang dapat ditulisi.
Return a string containing a printable representation of an object. For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to :func:`eval`; otherwise, the representation is a string enclosed in angle brackets that contains the name of the type of the object together with additional information often including the name and address of the object. A class can control what this function returns for its instances by defining a :meth:`~object.__repr__` method.
Return a reverse :term:`iterator`. The argument must be an object which has a :meth:`~object.__reversed__` method or supports the sequence protocol (the :meth:`~object.__len__` method and the :meth:`~object.__getitem__` method with integer arguments starting at ``0``).
For a general Python object ``number``, ``round`` delegates to ``number.__round__``.
Untuk sebuah objek Python ``number`` secara umum, ``round`` mendelegasikan ke ``number.__round__``.
Return a new :class:`set` object, optionally with elements taken from *iterable*. :class:`set` is a built-in class. See also :ref:`types-set` for documentation about this class.
This is the counterpart of :func:`getattr`. The arguments are an object, a string, and an arbitrary value. The string may name an existing attribute or a new attribute. The function assigns the value to the attribute, provided the object allows it. For example, ``setattr(x, 'foobar', 123)`` is equivalent to ``x.foobar = 123``.
*name* need not be a Python identifier as defined in :ref:`identifiers` unless the object chooses to enforce that, for example in a custom :meth:`~object.__getattribute__` or via :attr:`~object.__slots__`. An attribute whose name is not an identifier will not be accessible using the dot notation, but is accessible through :func:`getattr` etc..
Return a new unique sentinel object. *name* must be a :class:`str`, and is used by default as the returned object's representation::
Sentinel objects are true and compare equal only to themselves. They are intended to be compared with the :keyword:`is` operator.
Shallow and deep copies of a sentinel object return the object itself.
Sentinel objects support the :ref:`| <bitwise>` operator for use in type expressions.
:mod:`Pickling <pickle>` is supported for sentinel objects that are placed in the global scope of a module under a name matching the sentinel's name, and for sentinels placed in class scopes with a name matching the :term:`qualified name` of the sentinel. Other sentinels, such as those defined in a function scope, are not picklable. The identity of the sentinel is preserved after pickling::
Sentinel objects have the following attributes:
Return a :term:`slice` object representing the set of indices specified by ``range(start, stop, step)``. The *start* and *step* arguments default to ``None``.
Slice objects are also generated when :ref:`slicing syntax <slicings>` is used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``.
Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:`~slice.stop`, and :attr:`~slice.step` are hashable).
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.
Return a :class:`str` version of *object*. See :func:`str` for details.
Kembalikan sebuah versi :class:`str` dari *objek*. Lihat :func:`str` untuk detailnya.
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 *object_or_type* determines the :term:`method resolution order` to be searched. The search starts from the class right after the *type*.
For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -> A -> object`` and the value of *type* is ``B``, then :func:`super` searches ``C -> A -> object``.
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).
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.
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]``.
:class:`super` objects are now :mod:`pickleable <pickle>` and :mod:`copyable <copy>`.
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__`.
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:`bltin-type-objects`
Keyword arguments provided to the three argument form are passed to the appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) in the same way that keywords in a class definition (besides *metaclass*) would.
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.
Return the :attr:`~object.__dict__` attribute for a module, class, instance, or any other object with a :attr:`!__dict__` attribute.
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).
A :exc:`TypeError` exception is raised if an object is specified but it doesn't have a :attr:`~object.__dict__` attribute (for example, if its class defines the :attr:`~object.__slots__` attribute).
Sebuah pengecualian untuk :exc:`TypeError` akan muncul jika suatu objek yang ditentukan tetapi tidak memiliki sebuah atribut :attr:`~object.__dict__` (contohnya, jika suatu kelas didefinisikan sebagai atribut :attr:`~object.__slots__`).
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.
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`.
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.
file object
objek berkas
object
objek