Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 77 additions & 24 deletions c-api/tuple.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
#
# Translators:
# Leon H., 2017
# Yorkxe <[email protected]>, 2025
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-11-05 00:16+0000\n"
"PO-Revision-Date: 2017-09-22 18:26+0000\n"
"Last-Translator: Leon H.\n"
"PO-Revision-Date: 2025-11-13 21:53+0000\n"
"Last-Translator: Yorkxe <[email protected]>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
Expand All @@ -24,31 +25,36 @@ msgstr "Tuple(元組)物件"

#: ../../c-api/tuple.rst:13
msgid "This subtype of :c:type:`PyObject` represents a Python tuple object."
msgstr ""
msgstr "此 :c:type:`PyObject` 子型別代表 Python 元組物件"

#: ../../c-api/tuple.rst:18
msgid ""
"This instance of :c:type:`PyTypeObject` represents the Python tuple type; it "
"is the same object as :class:`tuple` in the Python layer."
msgstr ""
"此 :c:type:`PyTypeObject` 實例代表 Python 元組型別,與 Python 層中的 :class:"
"`tuple` 是同一物件"

#: ../../c-api/tuple.rst:24
msgid ""
"Return true if *p* is a tuple object or an instance of a subtype of the "
"tuple type. This function always succeeds."
msgstr ""
"如果 *p* 為一元組物件或是元組型別的子型別實例時回傳 true。此函式總會執行成功"

#: ../../c-api/tuple.rst:30
msgid ""
"Return true if *p* is a tuple object, but not an instance of a subtype of "
"the tuple type. This function always succeeds."
msgstr ""
"如果 *p* 為一元組物件但不是元組型別的子型別實例時回傳 true。此函式總會執行成"
"功"

#: ../../c-api/tuple.rst:36
msgid ""
"Return a new tuple object of size *len*, or ``NULL`` with an exception set "
"on failure."
msgstr ""
msgstr "回傳一個長度為 *len* 的新元組物件,失敗會時回傳 ``NULL`` 並設定例外。"

#: ../../c-api/tuple.rst:42
msgid ""
Expand All @@ -57,23 +63,30 @@ msgid ""
"pointing to Python objects. ``PyTuple_Pack(2, a, b)`` is equivalent to "
"``Py_BuildValue(\"(OO)\", a, b)``."
msgstr ""
"回傳一個長度為 *n* 的新元組物件,失敗時會回傳 ``NULL`` 並設定例外。元組值被初"
"始化為指向 Python 物件的接續 *n* 個 C 引數。``PyTuple_Pack(2, a, b)`` 等價於 "
"``Py_BuildValue(\"(OO)\", a, b)``。"

#: ../../c-api/tuple.rst:50
msgid ""
"Take a pointer to a tuple object, and return the size of that tuple. On "
"error, return ``-1`` with an exception set."
msgstr ""
"拿取一個元組物件的指標,然後回傳此元組的大小。錯誤發生時,回傳 ``-1`` 並設定"
"例外。"

#: ../../c-api/tuple.rst:56
msgid "Like :c:func:`PyTuple_Size`, but without error checking."
msgstr ""
msgstr "就像 :c:func:`PyTuple_Size` 但沒有錯誤檢查。"

#: ../../c-api/tuple.rst:61
msgid ""
"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."
msgstr ""
"回傳 *p* 指向的元組中位置 *pos* 處的物件。如果 *pos* 為負數或超出範圍,回傳 "
"``NULL`` 並設定 :exc:`IndexError` 例外。"

#: ../../c-api/tuple.rst:64
msgid ""
Expand All @@ -82,62 +95,78 @@ msgid ""
"reference`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) <Py_NewRef>` or :c:"
"func:`PySequence_GetItem`."
msgstr ""
"回傳的參照借自元組 *p*\\ (也就是說:它僅在你持有 *p* 的參照時有效)。若要取"
"得一個 :term:`strong reference`,請使用 :c:func:"
"`Py_NewRef(PyTuple_GetItem(...)) <Py_NewRef>` 或 :c:func:"
"`PySequence_GetItem`。"

#: ../../c-api/tuple.rst:73
msgid "Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments."
msgstr ""
msgstr "與 :c:func:`PyTuple_GetItem` 相似,但不檢查其引數。"

#: ../../c-api/tuple.rst:78
msgid ""
"Return the slice of the tuple pointed to by *p* between *low* and *high*, or "
"``NULL`` with an exception set on failure."
msgstr ""
"回傳由 *p* 指向的元組中介於 *low* 和 *high* 之間的切片或在錯誤時回傳 "
"``NULL`` 並設定例外。"

#: ../../c-api/tuple.rst:81
msgid ""
"This is the equivalent of the Python expression ``p[low:high]``. Indexing "
"from the end of the tuple is not supported."
msgstr ""
msgstr "這與 Python ``p[low:high]`` 運算式等價。但不支援從元組末端開始索引。"

#: ../../c-api/tuple.rst:87
msgid ""
"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."
msgstr ""
"於 *p* 指向的元組 *pos* 位置處插入對物件 *o* 的參照。成功時回傳 ``0``,如果 "
"*pos* 超出邊界則回傳 ``-1``,並設定 :exc:`IndexError` 例外。"

#: ../../c-api/tuple.rst:93
msgid ""
"This function \"steals\" a reference to *o* and discards a reference to an "
"item already in the tuple at the affected position."
msgstr ""
msgstr "此函式 \"竊取\" 對 *o* 的參照,並丟棄對元組中受影響位置的項目的參照。"

#: ../../c-api/tuple.rst:99
msgid ""
"Like :c:func:`PyTuple_SetItem`, but does no error checking, and should "
"*only* be used to fill in brand new tuples."
msgstr ""
"與 :c:func:`PyTuple_SetItem` 相似,但不進行錯誤檢查,且應 *只* 用於填充全新的"
"元組。"

#: ../../c-api/tuple.rst:102 ../../c-api/tuple.rst:224
#: ../../c-api/tuple.rst:242
msgid ""
"Bounds checking is performed as an assertion if Python is built in :ref:"
"`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`."
msgstr ""
"若 Python 以 :ref:`debug mode <debug-build>` 或 :option:`with assertions <--"
"with-assertions>` 建置,則會進行作為斷言(asserting)的邊界檢查。"

#: ../../c-api/tuple.rst:107
msgid ""
"This function \"steals\" a reference to *o*, and, unlike :c:func:"
"`PyTuple_SetItem`, does *not* discard a reference to any item that is being "
"replaced; any reference in the tuple at position *pos* will be leaked."
msgstr ""
"此函式 \"竊取\" 對 *o* 的參照,且與 :c:func:`PyTuple_SetItem` 不同的是,此函"
"式並 *不* 丟棄任何被替代項目的參照;元組中 *pos* 位置的所有參照皆會被洩漏。"

#: ../../c-api/tuple.rst:114
msgid ""
"This macro should *only* be used on tuples that are newly created. Using "
"this macro on a tuple that is already in use (or in other words, has a "
"refcount > 1) could lead to undefined behavior."
msgstr ""
"此巨集應 *僅* 用於新建立的元組。在正被使用中的元組(或換句話說,參照計數大於 "
"1 的元組)上使用此巨集可能會導致未定義行為。"

#: ../../c-api/tuple.rst:121
msgid ""
Expand All @@ -153,10 +182,17 @@ msgid ""
"and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` or :exc:"
"`SystemError`."
msgstr ""
"可用於調整元組的大小。*newsize* 將是元組的新長度。由於元組 *應該* 是不可變"
"的,因此僅當物件只有一個參照時才應使用此方法。如果程式碼的其他部分已經知道該"
"元組,則 *不要* 使用此方法。最終元組總會變大或縮小。可以將其理解為銷毀舊元組"
"並建立一個新元組,只是有著更高的效率。成功時回傳 ``0``。用戶端程式碼絕不應假"
"設 ``*p`` 的結果值與呼叫此函式之前的值相同。如果 ``*p`` 參照的物件被替換,則"
"原始的 ``*p`` 將被銷毀。失敗時,回傳 ``-1``,並將 ``*p`` 設定為 ``NULL``,並"
"引發 :exc:`MemoryError` 或 :exc:`SystemError` 例外。"

#: ../../c-api/tuple.rst:136
msgid "Struct Sequence Objects"
msgstr ""
msgstr "結構序列物件"

#: ../../c-api/tuple.rst:138
msgid ""
Expand All @@ -165,49 +201,58 @@ msgid ""
"through attributes. To create a struct sequence, you first have to create a "
"specific struct sequence type."
msgstr ""
"結構序列物件是 :func:`~collections.namedtuple` 物件在 C 語言中的等價,換言"
"之,一個序列的元素也可以透過屬性存取。要建立結構序列,首先需要建立特定的結構"
"序列型別。"

#: ../../c-api/tuple.rst:145
msgid ""
"Create a new struct sequence type from the data in *desc*, described below. "
"Instances of the resulting type can be created with :c:func:"
"`PyStructSequence_New`."
msgstr ""
"從 *desc* 中的資料建立一個新的結構序列型別,如下所述。可以使用 :c:func:"
"`PyStructSequence_New` 以建立產生結構序列型別的實例。"

#: ../../c-api/tuple.rst:148 ../../c-api/tuple.rst:217
msgid "Return ``NULL`` with an exception set on failure."
msgstr "失敗時回傳 ``NULL`` 並設定例外。"

#: ../../c-api/tuple.rst:153
msgid "Initializes a struct sequence type *type* from *desc* in place."
msgstr ""
msgstr "從 *desc* 原地(in place)初始化結構序列型別 *type*。"

#: ../../c-api/tuple.rst:158
msgid ""
"Like :c:func:`PyStructSequence_InitType`, but returns ``0`` on success and "
"``-1`` with an exception set on failure."
msgstr ""
"與 :c:func:`PyStructSequence_InitType` 相似,但運行成功時回傳 ``0``,運行失敗"
"時回傳 ``-1`` 並設定例外。"

#: ../../c-api/tuple.rst:166
msgid "Contains the meta information of a struct sequence type to create."
msgstr ""
msgstr "包含要建立的結構序列化型別的中介資訊(meta information)。"

#: ../../c-api/tuple.rst:170
msgid ""
"Fully qualified name of the type; null-terminated UTF-8 encoded. The name "
"must contain the module name."
msgstr ""
"型別的完整限定名稱(Fully qualified name);以 UTF-8 編碼並以空字元結尾。名稱"
"必須包含完整的模組名稱。"

#: ../../c-api/tuple.rst:175
msgid "Pointer to docstring for the type or ``NULL`` to omit."
msgstr ""
msgstr "指向型別說明文件(docstring)的指標或使用 ``NULL`` 表示忽略。"

#: ../../c-api/tuple.rst:179
msgid "Pointer to ``NULL``-terminated array with field names of the new type."
msgstr ""
msgstr "指向一個以 ``NULL`` 結尾的陣列指標,其包含新型別的欄位名稱。"

#: ../../c-api/tuple.rst:183
msgid "Number of fields visible to the Python side (if used as tuple)."
msgstr ""
msgstr "Python 端可以看到欄位的數目(如果作為元組使用)。"

#: ../../c-api/tuple.rst:188
msgid ""
Expand All @@ -217,62 +262,70 @@ msgid ""
"`PyStructSequence_Desc` determines which field of the struct sequence is "
"described."
msgstr ""
"描述結構序列的一個欄位。由於結構序列以元組作為原型,所有欄位的型別均為 :c:"
"expr:`PyObject*`。:c:type:`PyStructSequence_Desc` 在 :c:member:"
"`~PyStructSequence_Desc.fields` 陣列中的索引決定了描述的是結構序列的哪個欄"
"位。"

#: ../../c-api/tuple.rst:196
msgid ""
"Name for the field or ``NULL`` to end the list of named fields, set to :c:"
"data:`PyStructSequence_UnnamedField` to leave unnamed."
msgstr ""
"欄位名稱,或 ``NULL`` 表示命名欄位串列結束,設定為 :c:data:"
"`PyStructSequence_UnnamedField` 表示該欄位不命名。"

#: ../../c-api/tuple.rst:201
msgid "Field docstring or ``NULL`` to omit."
msgstr ""
msgstr "欄位說明字串或為 ``NULL`` 表示忽略。"

#: ../../c-api/tuple.rst:206
msgid "Special value for a field name to leave it unnamed."
msgstr ""
msgstr "給定欄位名稱一個特別值,表示該欄位不命名。"

#: ../../c-api/tuple.rst:208
msgid "The type was changed from ``char *``."
msgstr ""
msgstr "型別原本是 ``char *``,現已被修改。"

#: ../../c-api/tuple.rst:214
msgid ""
"Creates an instance of *type*, which must have been created with :c:func:"
"`PyStructSequence_NewType`."
msgstr ""
msgstr "建立 *type* 的實例,必須以 :c:func:`PyStructSequence_NewType` 建立。"

#: ../../c-api/tuple.rst:222
msgid ""
"Return the object at position *pos* in the struct sequence pointed to by *p*."
msgstr ""
msgstr "回傳結構序列中由 *p* 指向 *pos* 處的物件。"

#: ../../c-api/tuple.rst:230
msgid "Alias to :c:func:`PyStructSequence_GetItem`."
msgstr ""
msgstr ":c:func:`PyStructSequence_GetItem` 的別名。"

#: ../../c-api/tuple.rst:232
msgid "Now implemented as an alias to :c:func:`PyStructSequence_GetItem`."
msgstr ""
msgstr "現在是被實作為 :c:func:`PyStructSequence_GetItem` 的一個別名。"

#: ../../c-api/tuple.rst:238
msgid ""
"Sets the field at index *pos* of the struct sequence *p* to value *o*. "
"Like :c:func:`PyTuple_SET_ITEM`, this should only be used to fill in brand "
"new instances."
msgstr ""
"將結構序列 *p* 中索引 *pos* 處的欄位值設為 *o*。與 :c:func:"
"`PyTuple_SET_ITEM` 類似,此函式僅套用於填充全新實例。"

#: ../../c-api/tuple.rst:247
msgid "This function \"steals\" a reference to *o*."
msgstr ""
msgstr "此函式 \"竊取\" *o* 的參照。"

#: ../../c-api/tuple.rst:252
msgid "Alias to :c:func:`PyStructSequence_SetItem`."
msgstr ""
msgstr ":c:func:`PyStructSequence_SetItem` 的別名。"

#: ../../c-api/tuple.rst:254
msgid "Now implemented as an alias to :c:func:`PyStructSequence_SetItem`."
msgstr ""
msgstr "現在是被實作為 :c:func:`PyStructSequence_SetItem` 的一個別名。"

#: ../../c-api/tuple.rst:8
msgid "object"
Expand Down