From 741bd06233b05d924325dca3cf630ddaf3177da1 Mon Sep 17 00:00:00 2001 From: mattwang44 Date: Sat, 11 Apr 2026 13:19:12 +0800 Subject: [PATCH 1/2] Translate all remaining entries in library/functions.po --- library/functions.po | 188 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 177 insertions(+), 11 deletions(-) diff --git a/library/functions.po b/library/functions.po index a50c6f095f..553e8fd614 100644 --- a/library/functions.po +++ b/library/functions.po @@ -518,7 +518,7 @@ msgstr "如果不一定需要 \"0b\" 前綴,還可以使用如下的方法。" #: ../../library/functions.rst:141 msgid "" "See also :func:`enum.bin` to represent negative values as twos-complement." -msgstr "" +msgstr "也請參閱 :func:`enum.bin` 以二補數表示負數。" #: ../../library/functions.rst:143 ../../library/functions.rst:952 #: ../../library/functions.rst:1336 @@ -1037,7 +1037,7 @@ msgstr "" msgid "" "See also :meth:`complex.from_number` which only accepts a single numeric " "argument." -msgstr "" +msgstr "也請參閱 :meth:`complex.from_number`,它只接受單一數值引數。" #: ../../library/functions.rst:445 msgid "If all arguments are omitted, returns ``0j``." @@ -1065,6 +1065,7 @@ msgid "" "Passing a complex number as the *real* or *imag* argument is now deprecated; " "it should only be passed as a single positional argument." msgstr "" +"傳遞複數作為 *real* 或 *imag* 引數現已被棄用;它只應作為單一位置引數傳遞。" #: ../../library/functions.rst:463 msgid "" @@ -1264,6 +1265,7 @@ msgid "" "This function executes arbitrary code. Calling it with untrusted user-" "supplied input will lead to security vulnerabilities." msgstr "" +"此函式會執行任意程式碼。以不受信任的使用者提供的輸入來呼叫它將導致安全漏洞。" #: ../../library/functions.rst:602 msgid "" @@ -1554,7 +1556,7 @@ msgstr "" #: ../../library/functions.rst:808 msgid "" "See also :meth:`float.from_number` which only accepts a numeric argument." -msgstr "" +msgstr "也請參閱 :meth:`float.from_number`,它只接受一個數值引數。" #: ../../library/functions.rst:810 msgid "If no argument is given, ``0.0`` is returned." @@ -2790,7 +2792,7 @@ msgstr "``'U'`` 模式被移除。" #: ../../library/functions.rst:1568 msgid "Return the ordinal value of a character." -msgstr "" +msgstr "回傳一個字元的序數值。" #: ../../library/functions.rst:1570 msgid "" @@ -2809,6 +2811,8 @@ msgid "" "1, return its single byte value. For example, ``ord(b'a')`` returns the " "integer ``97``." msgstr "" +"如果引數是長度為 1 的 :class:`bytes` 或 :class:`bytearray` 物件,則回傳其單一" +"位元組值。例如 ``ord(b'a')`` 回傳整數 ``97``。" #: ../../library/functions.rst:1582 msgid "" @@ -2980,7 +2984,7 @@ msgstr "" " def delx(self):\n" " del self._x\n" "\n" -" x = property(getx, setx, delx, \"I'm the 'x' property.\")" +" x = property(getx, setx, delx, \"我是 'x' 屬性。\")" #: ../../library/functions.rst:1672 msgid "" @@ -3012,6 +3016,14 @@ msgid "" " \"\"\"Get the current voltage.\"\"\"\n" " return self._voltage" msgstr "" +"class Parrot:\n" +" def __init__(self):\n" +" self._voltage = 100000\n" +"\n" +" @property\n" +" def voltage(self):\n" +" \"\"\"取得目前的電壓。\"\"\"\n" +" return self._voltage" #: ../../library/functions.rst:1688 msgid "" @@ -3058,7 +3070,7 @@ msgstr "" "\n" " @property\n" " def x(self):\n" -" \"\"\"I'm the 'x' property.\"\"\"\n" +" \"\"\"我是 'x' 屬性。\"\"\"\n" " return self._x\n" "\n" " @x.setter\n" @@ -3151,6 +3163,9 @@ msgid "" "(the :meth:`~object.__len__` method and the :meth:`~object.__getitem__` " "method with integer arguments starting at ``0``)." msgstr "" +"回傳一個反向的\\ :term:`疊代器 `。引數必須是一個擁有 :meth:`~object." +"__reversed__` 方法或支援序列協定(即 :meth:`~object.__len__` 方法和以 ``0`` " +"開始的整數引數的 :meth:`~object.__getitem__` 方法)的物件。" #: ../../library/functions.rst:1781 msgid "" @@ -3171,12 +3186,18 @@ msgid "" "negative). The return value is an integer if *ndigits* is omitted or " "``None``. Otherwise, the return value has the same type as *number*." msgstr "" +"對於支援 :func:`round` 的內建型別,值會被四捨五入到最接近 10 的負 *ndigits* " +"次方的倍數;如果兩個倍數一樣接近,則會向偶數方向進位(因此,例如 " +"``round(0.5)`` 和 ``round(-0.5)`` 都是 ``0``,而 ``round(1.5)`` 是 " +"``2``)。*ndigits* 的任何整數值都是有效的(正數、零或負數)。如果省略 " +"*ndigits* 或為 ``None``,則回傳值是整數。否則回傳值與 *number* 有相同的型別。" #: ../../library/functions.rst:1794 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" +"對於一般的 Python 物件 ``number``,``round`` 會委派給 ``number.__round__``。" #: ../../library/functions.rst:1799 msgid "" @@ -3186,6 +3207,9 @@ msgid "" "represented exactly as a float. See :ref:`tut-fp-issues` for more " "information." msgstr "" +":func:`round` 對於浮點數的行為可能出乎意料:例如 ``round(2.675, 2)`` 會得到 " +"``2.67`` 而非預期的 ``2.68``。這不是一個 bug:這是因為大多數十進位小數無法精確" +"地表示為浮點數。更多資訊請參閱 :ref:`tut-fp-issues`。" #: ../../library/functions.rst:1810 msgid "" @@ -3193,6 +3217,9 @@ msgid "" "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" "set` for documentation about this class." msgstr "" +"回傳一個新的 :class:`set` 物件,可選擇性地包含從 *iterable* 取得的元素。" +"``set`` 是一個內建類別。關於此類別的說明文件請參閱 :class:`set` 和 :ref:" +"`types-set`。" #: ../../library/functions.rst:1814 msgid "" @@ -3200,6 +3227,8 @@ msgid "" "class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " "module." msgstr "" +"關於其他容器,請參閱內建的 :class:`frozenset`、:class:`list`、:class:`tuple` " +"和 :class:`dict` 類別,以及 :mod:`collections` 模組。" #: ../../library/functions.rst:1821 msgid "" @@ -3209,6 +3238,9 @@ msgid "" "provided the object allows it. For example, ``setattr(x, 'foobar', 123)`` " "is equivalent to ``x.foobar = 123``." msgstr "" +"這是 :func:`getattr` 的對應函式。引數是一個物件、一個字串和一個任意值。該字串" +"可以指定一個現有屬性或一個新的屬性。此函式會將值賦予該屬性,前提是該物件允許" +"這麼做。例如 ``setattr(x, 'foobar', 123)`` 等效於 ``x.foobar = 123``。" #: ../../library/functions.rst:1827 msgid "" @@ -3218,6 +3250,10 @@ msgid "" "whose name is not an identifier will not be accessible using the dot " "notation, but is accessible through :func:`getattr` etc.." msgstr "" +"*name* 不必是 :ref:`identifiers` 中定義的 Python 識別字,除非該物件選擇強制" +"要求,例如在自訂的 :meth:`~object.__getattribute__` 中或透過 :attr:`~object." +"__slots__`。名稱不是識別字的屬性將無法使用點記法存取,但可以透過 :func:" +"`getattr` 等方式存取。" #: ../../library/functions.rst:1835 msgid "" @@ -3225,6 +3261,9 @@ msgid "" "compilation time, one must manually mangle a private attribute's (attributes " "with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" +"由於\\ :ref:`私有名稱修飾 `\\ 發生在編譯期間,若要使" +"用 :func:`setattr` 設定私有屬性(名稱以兩個底線開頭的屬性),必須手動修飾其名" +"稱。" #: ../../library/functions.rst:1844 msgid "" @@ -3232,18 +3271,24 @@ msgid "" "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" +"回傳一個 :term:`slice` 物件,表示由 ``range(start, stop, step)`` 指定的索引" +"集合。*start* 和 *step* 引數預設為 ``None``。" #: ../../library/functions.rst:1848 msgid "" "Slice objects are also generated when :ref:`slicing syntax ` is " "used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``." msgstr "" +"Slice 物件也會在使用\\ :ref:`切片語法 `\\ 時產生。例如:" +"``a[start:stop:step]`` 或 ``a[start:stop, i]``。" #: ../../library/functions.rst:1851 msgid "" "See :func:`itertools.islice` for an alternate version that returns an :term:" "`iterator`." msgstr "" +"請參閱 :func:`itertools.islice` 以取得回傳\\ :term:`疊代器 `\\ 的替" +"代版本。" #: ../../library/functions.rst:1858 msgid "" @@ -3251,16 +3296,20 @@ msgid "" "default). They have no other explicit functionality; however, they are used " "by NumPy and other third-party packages." msgstr "" +"這些唯讀屬性被設定為引數值(或其預設值)。它們沒有其他明確的功能;然而,它們會" +"被 NumPy 和其他第三方套件使用。" #: ../../library/functions.rst:1862 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" +"Slice 物件現在是\\ :term:`可雜湊的 `\\(前提是 :attr:`~slice." +"start`、:attr:`~slice.stop` 和 :attr:`~slice.step` 都是可雜湊的)。" #: ../../library/functions.rst:1868 msgid "Return a new sorted list from the items in *iterable*." -msgstr "" +msgstr "從 *iterable* 中的項目回傳一個新的已排序 list。" #: ../../library/functions.rst:1870 msgid "" @@ -3273,18 +3322,23 @@ msgid "" "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" +"*key* 指定一個具有一個引數的函式,用於從 *iterable* 中的每個元素提取比較鍵" +"(例如 ``key=str.lower``)。預設值為 ``None``\\(直接比較元素)。" #: ../../library/functions.rst:1876 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" +"*reverse* 是一個布林值。如果設為 ``True``,則 list 元素的排序方式如同每次" +"比較都被反轉一樣。" #: ../../library/functions.rst:1879 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" +"使用 :func:`functools.cmp_to_key` 將舊式的 *cmp* 函式轉換為 *key* 函式。" #: ../../library/functions.rst:1882 msgid "" @@ -3293,6 +3347,9 @@ msgid "" "compare equal --- this is helpful for sorting in multiple passes (for " "example, sort by department, then by salary grade)." msgstr "" +"內建的 :func:`sorted` 函式保證是穩定排序。一個排序如果保證不會改變比較結果" +"相等的元素之間的相對順序,就是穩定的 --- 這對於多次排序很有幫助(例如,先" +"按部門排序,再按薪資等級排序)。" #: ../../library/functions.rst:1887 msgid "" @@ -3305,21 +3362,29 @@ msgid "" "mixed type comparisons which can call the reflected :meth:`~object.__gt__` " "method." msgstr "" +"排序演算法僅使用項目之間的 ``<`` 比較。雖然定義 :meth:`~object.__lt__` 方法" +"就足以進行排序,但 :PEP:`8` 建議實作全部六個\\ :ref:`複合比較 " +"`。這有助於避免在使用相同資料搭配其他排序工具(例如依賴不同" +"底層方法的 :func:`max`)時產生錯誤。實作全部六個比較也有助於避免混合型別" +"比較時的混淆,因為這種比較可能會呼叫被反映的 :meth:`~object.__gt__` 方法。" #: ../../library/functions.rst:1896 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" +"有關排序的範例和簡要的排序教學,請參閱 :ref:`sortinghowto`。" #: ../../library/functions.rst:1900 msgid "Transform a method into a static method." -msgstr "" +msgstr "將一個方法轉換為靜態方法 (static method)。" #: ../../library/functions.rst:1902 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" +"靜態方法不會接收隱含的第一個引數。要宣告一個靜態方法,請使用以下慣用寫" +"法: ::" #: ../../library/functions.rst:1905 msgid "" @@ -3346,6 +3411,9 @@ msgid "" "`descriptor` is also callable, so it can be used in the class definition " "(such as ``f()``)." msgstr "" +"靜態方法可以在類別上呼叫(例如 ``C.f()``),也可以在實例上呼叫(例如 " +"``C().f()``)。此外,靜態方法的\\ :term:`描述器 `\\ 也是可呼叫" +"的,因此可以在類別定義中使用(例如 ``f()``)。" #: ../../library/functions.rst:1917 msgid "" @@ -3353,6 +3421,8 @@ msgid "" "see :func:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" +"Python 中的靜態方法類似於 Java 或 C++ 中的靜態方法。另請參閱 " +":func:`classmethod`,它是一個對於建立替代類別建構式很有用的變體。" #: ../../library/functions.rst:1921 msgid "" @@ -3362,6 +3432,9 @@ msgid "" "want to avoid the automatic transformation to instance method. For these " "cases, use this idiom::" msgstr "" +"如同所有裝飾器,也可以將 ``staticmethod`` 作為一般函式呼叫並對其結果進行操" +"作。這在某些情況下是必要的,例如當你需要從類別主體中引用一個函式,且希望避" +"免自動轉換為實例方法時。對於這些情況,請使用以下慣用寫法: ::" #: ../../library/functions.rst:1927 msgid "" @@ -3396,13 +3469,15 @@ msgstr "" #: ../../library/functions.rst:1953 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." -msgstr "" +msgstr "回傳 *object* 的 :class:`str` 版本。詳細資訊請參閱 :func:`str`。" #: ../../library/functions.rst:1955 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" +"``str`` 是內建的字串\\ :term:`類別 `。有關字串的一般資訊,請參閱 " +":ref:`textseq`。" #: ../../library/functions.rst:1961 msgid "" @@ -3410,6 +3485,8 @@ msgid "" "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" +"從左到右加總 *start* 和一個 *iterable* 的項目並回傳總和。*iterable* 的項目" +"通常是數字,且 start 值不允許為字串。" #: ../../library/functions.rst:1965 msgid "" @@ -3419,6 +3496,10 @@ msgid "" "see :func:`math.fsum`\\. To concatenate a series of iterables, consider " "using :func:`itertools.chain`." msgstr "" +"對於某些使用情境,有比 :func:`sum` 更好的替代方案。串接字串序列的首選快速方" +"式是呼叫 ``''.join(sequence)``。要以延伸精度加總浮點數值,請參閱 " +":func:`math.fsum`。要串接一系列可疊代物件,請考慮使用 " +":func:`itertools.chain`。" #: ../../library/functions.rst:1971 msgid "The *start* parameter can be specified as a keyword argument." @@ -3429,12 +3510,14 @@ msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" +"浮點數的加總已切換到一個在大多數建置上提供更高精確度和更好交換律的演算法。" #: ../../library/functions.rst:1977 msgid "" "Added specialization for summation of complexes, using same algorithm as for " "summation of floats." msgstr "" +"新增了複數加總的特化處理,使用與浮點數加總相同的演算法。" #: ../../library/functions.rst:1985 msgid "" @@ -3442,12 +3525,16 @@ msgid "" "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" +"回傳一個代理物件,該物件會將方法呼叫委派給 *type* 的父類別或兄弟類別。這對" +"於存取在類別中被覆寫的繼承方法很有用。" #: ../../library/functions.rst:1989 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" +"*object_or_type* 決定了要搜尋的\\ :term:`方法解析順序 `。搜尋從 *type* 之後的類別開始。" #: ../../library/functions.rst:1993 msgid "" @@ -3455,6 +3542,9 @@ msgid "" "> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" +"舉例來說,如果 *object_or_type* 的 :attr:`~type.__mro__` 是 ``D -> B -> C " +"-> A -> object``,且 *type* 的值是 ``B``,則 :func:`super` 會搜尋 ``C -> " +"A -> object``。" #: ../../library/functions.rst:1997 msgid "" @@ -3463,6 +3553,9 @@ msgid "" "`getattr` and :func:`super`. The attribute is dynamic and can change " "whenever the inheritance hierarchy is updated." msgstr "" +"與 *object_or_type* 對應的類別之 :attr:`~type.__mro__` 屬性列出了 " +":func:`getattr` 和 :func:`super` 所使用的方法解析搜尋順序。該屬性是動態" +"的,每當繼承階層被更新時就可能改變。" #: ../../library/functions.rst:2002 msgid "" @@ -3471,6 +3564,9 @@ msgid "" "If the second argument is a type, ``issubclass(type2, type)`` must be true " "(this is useful for classmethods)." msgstr "" +"如果省略第二個引數,回傳的 super 物件就是未繫結的。如果第二個引數是一個物" +"件,``isinstance(obj, type)`` 必須為真。如果第二個引數是一個型別," +"``issubclass(type2, type)`` 必須為真(這對類別方法很有用)。" #: ../../library/functions.rst:2007 msgid "" @@ -3481,6 +3577,11 @@ msgid "" "argument :func:`!super` will not work as expected within nested functions, " "including generator expressions, which implicitly create nested functions.)" msgstr "" +"在類別的一般方法中直接呼叫時,兩個引數都可以省略(「零引數 " +":func:`!super`」)。在這種情況下,*type* 將是外圍類別,而 *obj* 將是直接" +"外圍函式的第一個引數(通常是 ``self``)。(這意味著零引數 " +":func:`!super` 在巢狀函式中將無法如預期般運作,包括隱式建立巢狀函式的產" +"生器運算式。)" #: ../../library/functions.rst:2014 msgid "" @@ -3489,6 +3590,9 @@ msgid "" "naming them explicitly, thus making the code more maintainable. This use " "closely parallels the use of *super* in other programming languages." msgstr "" +"*super* 有兩種典型的使用情境。在具有單一繼承的類別階層中,*super* 可以用" +"來參照父類別而不需要明確命名它們,從而使程式碼更易於維護。這種用法與 " +"*super* 在其他程式語言中的用法非常相似。" #: ../../library/functions.rst:2019 msgid "" @@ -3502,10 +3606,16 @@ msgid "" "changes in the class hierarchy, and because that order can include sibling " "classes that are unknown prior to runtime)." msgstr "" +"第二種使用情境是在動態執行環境中支援協作式多重繼承。這種使用情境是 " +"Python 獨有的,在靜態編譯語言或僅支援單一繼承的語言中找不到。這使得實作" +"「鑽石圖」(diamond diagrams)成為可能,其中多個基礎類別實作相同的方" +"法。良好的設計要求這些實作在每種情況下都有相同的呼叫簽名(因為呼叫順序是" +"在執行期決定的,因為該順序會適應類別階層的變化,也因為該順序可以包含在執" +"行期之前未知的兄弟類別)。" #: ../../library/functions.rst:2029 msgid "For both use cases, a typical superclass call looks like this::" -msgstr "" +msgstr "對於這兩種使用情境,一個典型的超類別呼叫如下: ::" #: ../../library/functions.rst:2031 msgid "" @@ -3514,6 +3624,10 @@ msgid "" " super().method(arg) # This does the same thing as:\n" " # super(C, self).method(arg)" msgstr "" +"class C(B):\n" +" def method(self, arg):\n" +" super().method(arg) # 這和以下做法相同:\n" +" # super(C, self).method(arg)" #: ../../library/functions.rst:2036 msgid "" @@ -3521,6 +3635,8 @@ msgid "" "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" +"除了方法查找之外,:func:`super` 也適用於屬性查找。這個功能的一個可能使用情" +"境是在父類別或兄弟類別中呼叫\\ :term:`描述器 `。" #: ../../library/functions.rst:2040 msgid "" @@ -3531,6 +3647,11 @@ msgid "" "inheritance. Accordingly, :func:`super` is undefined for implicit lookups " "using statements or operators such as ``super()[name]``." msgstr "" +"請注意,:func:`super` 是作為顯式點號屬性查找(例如 " +"``super().__getitem__(name)``)之繫結過程的一部分來實作的。它透過實作自己" +"的 :meth:`~object.__getattribute__` 方法來搜尋類別,以可預測的順序來支援協作" +"式多重繼承。因此,:func:`super` 對於使用陳述式或運算子的隱式查找(例如 " +"``super()[name]``)是未定義的。" #: ../../library/functions.rst:2048 msgid "" @@ -3541,6 +3662,10 @@ msgid "" "necessary details to correctly retrieve the class being defined, as well as " "accessing the current instance for ordinary methods." msgstr "" +"另外請注意,除了零引數形式之外,:func:`super` 並不限於在方法內部使用。雙引" +"數形式會精確地指定引數並建立適當的參照。零引數形式只能在類別定義內部使用," +"因為編譯器會填入必要的細節以正確地取得正在被定義的類別,以及存取一般方法的" +"目前實例。" #: ../../library/functions.rst:2055 msgid "" @@ -3548,18 +3673,25 @@ msgid "" "`super`, see `guide to using super() `_." msgstr "" +"有關如何使用 :func:`super` 設計協作式類別的實用建議,請參閱\\ `使用 super() " +"的指南 `_。" #: ../../library/functions.rst:2059 msgid "" ":class:`super` objects are now :mod:`pickleable ` and :mod:" "`copyable `." msgstr "" +":class:`super` 物件現在可以使用 :mod:`pickle ` 序列化以及使用 :mod:" +"`copy ` 複製。" #: ../../library/functions.rst:2068 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" +":class:`tuple` 實際上不是一個函式,而是一個不可變的序列型別,如 :ref:" +"`typesseq-tuple` 和 :ref:`typesseq` 中所述。" #: ../../library/functions.rst:2077 msgid "" @@ -3567,12 +3699,16 @@ msgid "" "type object and generally the same object as returned by :attr:`object." "__class__`." msgstr "" +"傳入一個引數時,回傳一個 *object* 的型別。回傳值是一個型別物件,通常與 " +":attr:`object.__class__` 所回傳的物件相同。" #: ../../library/functions.rst:2081 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." msgstr "" +"建議使用內建函式 :func:`isinstance` 來測試物件的型別,因為它會將子類別納入" +"考量。" #: ../../library/functions.rst:2084 msgid "" @@ -3586,6 +3722,12 @@ msgid "" "__dict__` attribute. The following two statements create identical :class:`!" "type` objects:" msgstr "" +"傳入三個引數時,回傳一個新的型別物件。這本質上是 :keyword:`class` 陳述式的" +"動態形式。*name* 字串是類別名稱,會成為 :attr:`~type.__name__` 屬性。" +"*bases* tuple 包含基底類別,會成為 :attr:`~type.__bases__` 屬性;如果為空," +"則會加入所有類別的最終基底類別 :class:`object`。*dict* 字典包含類別主體的屬" +"性和方法定義;它可能會被複製或包裝後才成為 :attr:`~type.__dict__` 屬性。以下" +"兩個陳述式會建立相同的 :class:`!type` 物件:" #: ../../library/functions.rst:2099 msgid "See also:" @@ -3596,6 +3738,7 @@ msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" +":ref:`類別的屬性和方法的文件 `。" #: ../../library/functions.rst:2102 msgid ":ref:`bltin-type-objects`" @@ -3608,6 +3751,9 @@ msgid "" "in the same way that keywords in a class definition (besides *metaclass*) " "would." msgstr "" +"提供給三引數形式的關鍵字引數會以與類別定義中的關鍵字(除了 *metaclass* 之" +"外)相同的方式,傳遞給適當的元類別機制(通常是 :meth:`~object." +"__init_subclass__`)。" #: ../../library/functions.rst:2109 msgid "See also :ref:`class-customization`." @@ -3618,12 +3764,16 @@ msgid "" "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." msgstr "" +"沒有覆寫 ``type.__new__`` 的 :class:`!type` 子類別不能再使用單引數形式來取" +"得物件的型別。" #: ../../library/functions.rst:2118 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " "or any other object with a :attr:`!__dict__` attribute." msgstr "" +"回傳模組、類別、實例或任何其他具有 :attr:`!__dict__` 屬性的物件的 :attr:" +"`~object.__dict__` 屬性。" #: ../../library/functions.rst:2121 msgid "" @@ -3632,10 +3782,13 @@ msgid "" "their :attr:`!__dict__` attributes (for example, classes use a :class:`types." "MappingProxyType` to prevent direct dictionary updates)." msgstr "" +"像模組和實例這樣的物件具有可更新的 :attr:`~object.__dict__` 屬性;然而,其" +"他物件的 :attr:`!__dict__` 屬性可能有寫入限制(例如,類別使用 :class:`types." +"MappingProxyType` 來防止直接更新字典)。" #: ../../library/functions.rst:2126 msgid "Without an argument, :func:`vars` acts like :func:`locals`." -msgstr "" +msgstr "不帶引數時,:func:`vars` 的行為與 :func:`locals` 相同。" #: ../../library/functions.rst:2128 msgid "" @@ -3643,18 +3796,22 @@ msgid "" "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " "defines the :attr:`~object.__slots__` attribute)." msgstr "" +"如果指定了一個物件但它沒有 :attr:`~object.__dict__` 屬性(例如,如果它的類" +"別定義了 :attr:`~object.__slots__` 屬性),則會引發 :exc:`TypeError` 例外。" #: ../../library/functions.rst:2134 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "" +"不帶引數呼叫此函式的結果已按照內建函式 :func:`locals` 的說明進行更新。" #: ../../library/functions.rst:2140 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" +"平行疊代多個可疊代物件,產生包含每個可疊代物件中一個項目的 tuple。" #: ../../library/functions.rst:2143 msgid "Example::" @@ -3681,6 +3838,8 @@ msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" +"更正式地說::func:`zip` 回傳一個由 tuple 組成的疊代器,其中第 *i* 個 tuple " +"包含來自每個引數可疊代物件的第 *i* 個元素。" #: ../../library/functions.rst:2155 msgid "" @@ -3688,6 +3847,8 @@ msgid "" "columns into rows. This is similar to `transposing a matrix `_." msgstr "" +"另一種理解 :func:`zip` 的方式是它將列(row)轉換為行(column),將行轉換為" +"列。這類似於\\ `轉置矩陣 `_。" #: ../../library/functions.rst:2159 msgid "" @@ -3695,6 +3856,8 @@ msgid "" "iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" "`list`." msgstr "" +":func:`zip` 是惰性的 (lazy):元素在可疊代物件被疊代之前不會被處理,例如透過" +"一個 :keyword:`!for` 迴圈或包裝在一個 :class:`list` 中。" #: ../../library/functions.rst:2163 msgid "" @@ -3703,6 +3866,9 @@ msgid "" "the code that prepared these iterables. Python offers three different " "approaches to dealing with this issue:" msgstr "" +"需要考慮的一點是,傳遞給 :func:`zip` 的可疊代物件可能具有不同的長度;有時候" +"是刻意設計的,有時候是因為準備這些可疊代物件的程式碼中的錯誤。Python 提供三" +"種不同的方式來處理這個問題:" #: ../../library/functions.rst:2168 msgid "" From 4ac066a750839ed4fd1fb2dcaee1f175b2a2ca53 Mon Sep 17 00:00:00 2001 From: mattwang44 Date: Sat, 11 Apr 2026 14:53:41 +0800 Subject: [PATCH 2/2] Translate remaining string in tutorial/datastructures.po --- tutorial/datastructures.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index 1a5b518fd5..6a088ce85f 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -857,7 +857,7 @@ msgstr "" msgid "" "Because sets are unordered, iterating over them or printing them can produce " "the elements in a different order than you expect." -msgstr "" +msgstr "因為 set 是無序的,疊代或印出它們時,元素的順序可能與你預期的不同。" #: ../../tutorial/datastructures.rst:460 msgid "Here is a brief demonstration::"