Teks sumber — English
Terjemahan — Bahasa Indonesia
Tuple Objects
This subtype of :c:type:`PyObject` represents a Python tuple object.
This instance of :c:type:`PyTypeObject` represents the Python tuple type; it is the same object as :class:`tuple` in the Python layer.
Return true if *p* is a tuple object or an instance of a subtype of the tuple type. This function always succeeds.
Return true if *p* is a tuple object, but not an instance of a subtype of the tuple type. This function always succeeds.
Return a new tuple object of size *len*, or ``NULL`` with an exception set on failure.
Return a new tuple object of size *n*, or ``NULL`` with an exception set on failure. The tuple values are initialized to the subsequent *n* C arguments pointing to Python objects. ``PyTuple_Pack(2, a, b)`` is equivalent to ``Py_BuildValue("(OO)", a, b)``.
Take a pointer to a tuple object, and return the size of that tuple. On error, return ``-1`` with an exception set.
Return the object at position *pos* in the tuple pointed to by *p*. If *pos* is negative or out of bounds, return ``NULL`` and set an :exc:`IndexError` exception.
Insert a reference to object *o* at position *pos* of the tuple pointed to by *p*. Return ``0`` on success. If *pos* is out of bounds, return ``-1`` and set an :exc:`IndexError` exception. This function should only be used to fill in brand new tuples; using it on an existing tuple is thread-unsafe.
Can be used to resize a tuple. *newsize* will be the new length of the tuple. Because tuples are *supposed* to be immutable, this should only be used if there is only one reference to the object. Do *not* use this if the tuple may already be known to some other part of the code. The tuple will always grow or shrink at the end. Think of this as destroying the old tuple and creating a new one, only more efficiently. Returns ``0`` on success. Client code should never assume that the resulting value of ``*p`` will be the same as before calling this function. If the object referenced by ``*p`` is replaced, the original ``*p`` is destroyed. On failure, returns ``-1`` and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` or :exc:`SystemError`.
Struct Sequence Objects
A struct sequence object is a :term:`named tuple`, that is, a sequence whose items can also be accessed through attributes. It is similar to :func:`collections.namedtuple`, but provides a slightly different interface.
Describes a field of a struct sequence. As a struct sequence is modeled as a tuple, all fields are typed as :c:expr:`PyObject*`. The index in the :c:member:`~PyStructSequence_Desc.fields` array of the :c:type:`PyStructSequence_Desc` determines which field of the struct sequence is described.
Return the object at position *pos* in the struct sequence pointed to by *p*. The returned reference is borrowed from the struct sequence *p* (that is: it is only valid as long as you hold a reference to *p*).
object
objek