Pelokalan
Python ID
id en
Masuk
Proyek
c-api__arg.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
A format string consists of zero or more "format units." A format unit describes one Python object; it is usually a single character or a parenthesized sequence of format units. With a few exceptions, a format unit that is not a parenthesized sequence normally corresponds to a single address argument to these functions. In the following description, the quoted form is the format unit; the entry in (round) parentheses is the Python object type that matches the format unit; and the entry in [square] brackets is the type of the C variable(s) whose address should be passed.
format string terdiri dari nol atau lebih "unit format." Sebuah unit format menjelaskan satu obyek Python; Seringkali adalah sebuah karaketer atau sebuah urutan unit format yang di dalam kurung. Dengan beberapa pengecualian, format unit yang bukan sebuah urutan yang di dalam kurung biasanya berhubungan dengan sebuah argumen yang memanggil fungsi-fungsi ini. Dalam penjelasan berikut ini, bentuk yang dikutip adalah unit format. Entri yang di dalam kurung (bulat) adalah tipe obyek Python yang cocok dengan unit format, dan entri yang di dalam kurung [kotak] adalah tipe variabel C yang perlu dipanggil.
The object must be a Python sequence (except :class:`str`, :class:`bytes` or :class:`bytearray`) whose length is the number of format units in *items*. The C arguments must correspond to the individual format units in *items*. Format units for sequences may be nested.
Objek harus berupa urutan Python (kecuali :class:`str`, :class:`bytes` atau :class:`bytearray`) yang panjangnya adalah jumlah unit format dalam *items*. Argumen C harus sesuai dengan unit format individual dalam *items*. Unit format untuk urutan mungkin menetap.
If *items* contains format units which store a :ref:`borrowed buffer <c-arg-borrowed-buffer>` (``s``, ``s#``, ``z``, ``z#``, ``y``, or ``y#``) or a :term:`borrowed reference` (``S``, ``Y``, ``U``, ``O``, or ``O!``), the object must be a Python tuple. The *converter* for the ``O&`` format unit in *items* must not store a borrowed buffer or a borrowed reference.
Jika *items* berisi unit format yang menyimpan :ref:`borrowed buffer <c-arg-borrowed-buffer>` (``s``, ``s#``, ``z``, ``z#``, ``y``, atau ``y#``) atau :term:`borrowed reference` (``S``, ``Y``, ``U``, ``O``, atau ``O!``), maka objek tersebut haruslah sebuah tuple Python. *converter* untuk unit format ``O&`` dalam *items* tidak boleh menyimpan buffer yang dipinjam atau referensi yang dipinjam.
Non-tuple sequences are deprecated if *items* contains format units which store a borrowed buffer or a borrowed reference.
Urutan non-tuple tidak digunakan lagi jika *item* berisi unit format yang menyimpan buffer yang dipinjam atau referensi yang dipinjam.
The list of format units ends here; the string after the colon is used as the function name in error messages (the "associated value" of the exception that :c:func:`PyArg_ParseTuple` raises).
The list of format units ends here; the string after the semicolon is used as the error message *instead* of the default error message. ``:`` and ``;`` mutually exclude each other.
Na tym kończy się lista jednostek formatu; ciąg po średniku jest traktowany jako informacja o błędzie do użycia *zamiast* automatycznej wiadomości o błędzie. Znaki dwukropka ``:`` i średnika ``;`` wzajemnie się wykluczają.
Additional arguments passed to these functions must be addresses of variables whose type is determined by the format string; these are used to store values from the input tuple. There are a few cases, as described in the list of format units above, where these parameters are used as input values; they should match what is specified for the corresponding format unit in that case.
Dodatkowe parametry przekazywane do tych funkcji muszą być adresami zmiennych których typ jest określany przez ciąg formatu; są one używane do przechowywania wartości z krotki wejściowej. Jest parę przypadków, jak opisuje to lista jednostek formatu powyżej, gdzie te parametry są używane jako wprowadzane wartości; w takich przypadku powinny one odpowiadać temu, co jest określone we właściwych im jednostach formatu.
For the conversion to succeed, the *arg* object must match the format and the format must be exhausted. On success, the ``PyArg_Parse*`` functions return true, otherwise they return false and raise an appropriate exception. When the ``PyArg_Parse*`` functions fail due to conversion failure in one of the format units, the variables at the addresses corresponding to that and the following format units are left untouched.
Agar konversi berhasil, objek *arg* harus sesuai dengan format dan formatnya harus habis. Jika berhasil, fungsi ``PyArg_Parse*`` akan mengembalikan nilai true, jika tidak maka akan mengembalikan nilai false dan memunculkan pengecualian yang sesuai. Ketika fungsi ``PyArg_Parse*`` gagal karena kegagalan konversi pada salah satu unit format, variabel pada alamat yang sesuai dengan itu dan unit format berikutnya tidak disentuh.
:c:func:`Py_BuildValue` does not always build a tuple. It builds a tuple only if its format string contains two or more format units. If the format string is empty, it returns ``None``; if it contains exactly one format unit, it returns whatever object is described by that format unit. To force it to return a tuple of size 0 or one, parenthesize the format string.
In the following description, the quoted form is the format unit; the entry in (round) parentheses is the Python object type that the format unit will return; and the entry in [square] brackets is the type of the C value(s) to be passed.
The characters space, tab, colon and comma are ignored in format strings (but not within format units such as ``s#``). This can be used to make long format strings a tad more readable.