diff --git a/howto/instrumentation.po b/howto/instrumentation.po index 961dac6817f..51a18ae4dc5 100644 --- a/howto/instrumentation.po +++ b/howto/instrumentation.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-04 00:15+0000\n" +"POT-Creation-Date: 2026-03-16 00:22+0000\n" "PO-Revision-Date: 2023-08-17 22:17+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -676,10 +676,111 @@ msgstr "" "形式的事件名稱,``arg1`` 是指向元組 (tuple) 物件的 :c:type:`PyObject` 指標。" #: ../../howto/instrumentation.rst:345 +msgid "C Entry Points" +msgstr "" + +#: ../../howto/instrumentation.rst:347 +msgid "" +"To simplify triggering of DTrace markers, Python's C API comes with a number " +"of helper functions that mirror each static marker. On builds of Python " +"without DTrace enabled, these do nothing." +msgstr "" + +#: ../../howto/instrumentation.rst:351 +msgid "" +"In general, it is not necessary to call these yourself, as Python will do it " +"for you." +msgstr "" + +#: ../../howto/instrumentation.rst:358 +msgid "C API Function" +msgstr "" + +#: ../../howto/instrumentation.rst:359 +#, fuzzy +msgid "Static Marker" +msgstr "靜態 SystemTap 標記" + +#: ../../howto/instrumentation.rst:360 +msgid "Notes" +msgstr "" + +#: ../../howto/instrumentation.rst:362 +msgid ":c:func:`!line`" +msgstr "" + +#: ../../howto/instrumentation.rst:365 +#, fuzzy +msgid ":c:func:`!function__entry`" +msgstr "引數與 :c:func:`!function__entry` 相同" + +#: ../../howto/instrumentation.rst:368 +msgid ":c:func:`!function__return`" +msgstr "" + +#: ../../howto/instrumentation.rst:371 +msgid ":c:func:`!gc__start`" +msgstr "" + +#: ../../howto/instrumentation.rst:374 +msgid ":c:func:`!gc__done`" +msgstr "" + +#: ../../howto/instrumentation.rst:377 +msgid ":c:func:`!instance__new__start`" +msgstr "" + +#: ../../howto/instrumentation.rst:378 ../../howto/instrumentation.rst:381 +#: ../../howto/instrumentation.rst:384 ../../howto/instrumentation.rst:387 +msgid "Not used by Python" +msgstr "" + +#: ../../howto/instrumentation.rst:380 +msgid ":c:func:`!instance__new__done`" +msgstr "" + +#: ../../howto/instrumentation.rst:383 +msgid ":c:func:`!instance__delete__start`" +msgstr "" + +#: ../../howto/instrumentation.rst:386 +msgid ":c:func:`!instance__delete__done`" +msgstr "" + +#: ../../howto/instrumentation.rst:389 +msgid ":c:func:`!import__find__load__start`" +msgstr "" + +#: ../../howto/instrumentation.rst:392 +msgid ":c:func:`!import__find__load__done`" +msgstr "" + +#: ../../howto/instrumentation.rst:395 +msgid ":c:func:`!audit`" +msgstr "" + +#: ../../howto/instrumentation.rst:400 +msgid "C Probing Checks" +msgstr "" + +#: ../../howto/instrumentation.rst:415 +msgid "" +"All calls to ``PyDTrace`` functions must be guarded by a call to one of " +"these functions. This allows Python to minimize performance impact when " +"probing is disabled." +msgstr "" + +#: ../../howto/instrumentation.rst:419 +msgid "" +"On builds without DTrace enabled, these functions do nothing and return " +"``0``." +msgstr "" + +#: ../../howto/instrumentation.rst:423 msgid "SystemTap Tapsets" msgstr "SystemTap Tapsets" -#: ../../howto/instrumentation.rst:347 +#: ../../howto/instrumentation.rst:425 msgid "" "The higher-level way to use the SystemTap integration is to use a " "\"tapset\": SystemTap's equivalent of a library, which hides some of the " @@ -688,11 +789,11 @@ msgstr "" "使用 SystemTap 整合的高階方法是使用 \"tapset\":SystemTap 相當於一個函式庫," "它隱藏了靜態標記的一些低階詳細資訊。" -#: ../../howto/instrumentation.rst:351 +#: ../../howto/instrumentation.rst:429 msgid "Here is a tapset file, based on a non-shared build of CPython:" msgstr "這是一個 tapset 檔案,是基於 CPython 的非共享建置版本:" -#: ../../howto/instrumentation.rst:353 +#: ../../howto/instrumentation.rst:431 msgid "" "/*\n" " Provide a higher-level wrapping around the function__entry and\n" @@ -733,7 +834,7 @@ msgstr "" " frameptr = $arg4\n" "}" -#: ../../howto/instrumentation.rst:374 +#: ../../howto/instrumentation.rst:452 msgid "" "If this file is installed in SystemTap's tapset directory (e.g. ``/usr/share/" "systemtap/tapset``), then these additional probepoints become available:" @@ -741,7 +842,7 @@ msgstr "" "如果此檔案是安裝在 SystemTap 的 tapset 目錄中(例如 ``/usr/share/systemtap/" "tapset``),則這些額外的探測點將可被使用:" -#: ../../howto/instrumentation.rst:380 +#: ../../howto/instrumentation.rst:458 msgid "" "This probe point indicates that execution of a Python function has begun. It " "is only triggered for pure-Python (bytecode) functions." @@ -749,7 +850,7 @@ msgstr "" "該探測點表示 Python 函式的執行已經開始。它僅針對純 Python(位元組碼)函式觸" "發。" -#: ../../howto/instrumentation.rst:385 +#: ../../howto/instrumentation.rst:463 msgid "" "This probe point is the converse of ``python.function.return``, and " "indicates that execution of a Python function has ended (either via " @@ -759,11 +860,11 @@ msgstr "" "這個探測點與 ``python.function.return`` 相反,表示 Python 函式的執行已經結束" "(透過 ``return`` 或者透過例外)。它僅針對純 Python(位元組碼)函式觸發。" -#: ../../howto/instrumentation.rst:392 +#: ../../howto/instrumentation.rst:470 msgid "Examples" msgstr "範例" -#: ../../howto/instrumentation.rst:393 +#: ../../howto/instrumentation.rst:471 msgid "" "This SystemTap script uses the tapset above to more cleanly implement the " "example given above of tracing the Python function-call hierarchy, without " @@ -772,7 +873,7 @@ msgstr "" "此 SystemTap 腳本使用上面的 tapset 來更清晰地實作上面給出的追蹤 Python 函式呼" "叫階層結構的範例,而無需直接命名靜態標記:" -#: ../../howto/instrumentation.rst:397 +#: ../../howto/instrumentation.rst:475 msgid "" "probe python.function.entry\n" "{\n" @@ -798,7 +899,7 @@ msgstr "" " thread_indent(-1), funcname, filename, lineno);\n" "}" -#: ../../howto/instrumentation.rst:412 +#: ../../howto/instrumentation.rst:490 msgid "" "The following script uses the tapset above to provide a top-like view of all " "running CPython code, showing the top 20 most frequently entered bytecode " @@ -807,7 +908,7 @@ msgstr "" "以下腳本使用上面的 tapset 來提供所有正在運行之 CPython 程式碼的近乎最高層視" "角,顯示整個系統中每秒最常被進入的 20 個位元組碼幀 (bytecode frame):" -#: ../../howto/instrumentation.rst:416 +#: ../../howto/instrumentation.rst:494 msgid "" "global fn_calls;\n" "\n" diff --git a/library/argparse.po b/library/argparse.po index 255fa7e266c..da692de2a6e 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-04 00:19+0000\n" +"POT-Creation-Date: 2026-03-16 00:22+0000\n" "PO-Revision-Date: 2018-05-23 14:38+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -264,7 +264,7 @@ msgstr "新增 *exit_on_error* 參數。" msgid "*suggest_on_error* and *color* parameters were added." msgstr "新增 *suggest_on_error* 和 *color* 參數。" -#: ../../library/argparse.rst:137 ../../library/argparse.rst:694 +#: ../../library/argparse.rst:137 ../../library/argparse.rst:696 msgid "The following sections describe how each of these are used." msgstr "以下各節描述了這些參數的使用方式。" @@ -1371,11 +1371,15 @@ msgstr "dest_ - 要加入到 :meth:`parse_args` 回傳物件中的屬性名稱 msgid "deprecated_ - Whether or not use of the argument is deprecated." msgstr "deprecated_ - 引數的使用是否已被棄用。" -#: ../../library/argparse.rst:700 +#: ../../library/argparse.rst:694 +msgid "The method returns an :class:`Action` object representing the argument." +msgstr "" + +#: ../../library/argparse.rst:702 msgid "name or flags" msgstr "name or flags" -#: ../../library/argparse.rst:702 +#: ../../library/argparse.rst:704 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " @@ -1388,23 +1392,23 @@ msgstr "" "`~ArgumentParser.add_argument` 的第一個引數必須是一系列旗標或一個簡單的引數名" "稱。" -#: ../../library/argparse.rst:708 +#: ../../library/argparse.rst:710 msgid "For example, an optional argument could be created like::" msgstr "例如,可選引數可以像這樣建立: ::" -#: ../../library/argparse.rst:710 +#: ../../library/argparse.rst:712 msgid ">>> parser.add_argument('-f', '--foo')" msgstr ">>> parser.add_argument('-f', '--foo')" -#: ../../library/argparse.rst:712 +#: ../../library/argparse.rst:714 msgid "while a positional argument could be created like::" msgstr "而位置引數可以像這樣建立: ::" -#: ../../library/argparse.rst:714 +#: ../../library/argparse.rst:716 msgid ">>> parser.add_argument('bar')" msgstr ">>> parser.add_argument('bar')" -#: ../../library/argparse.rst:716 +#: ../../library/argparse.rst:718 msgid "" "When :meth:`~ArgumentParser.parse_args` is called, optional arguments will " "be identified by the ``-`` prefix, and the remaining arguments will be " @@ -1413,7 +1417,7 @@ msgstr "" "當呼叫 :meth:`~ArgumentParser.parse_args` 時,可選引數會透過 ``-`` 前綴來辨" "識,其餘的引數則假設為位置引數: ::" -#: ../../library/argparse.rst:720 +#: ../../library/argparse.rst:722 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1437,7 +1441,7 @@ msgstr "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:731 +#: ../../library/argparse.rst:733 msgid "" "By default, :mod:`!argparse` automatically handles the internal naming and " "display names of arguments, simplifying the process without requiring " @@ -1448,10 +1452,10 @@ msgid "" msgstr "" "預設情況下,:mod:`!argparse` 會自動處理引數的內部命名和顯示名稱,簡化流程而不" "需要額外設定。因此,你不需要指定 dest_ 和 metavar_ 參數。對於可選的引數," -"dest_ 參數預設為引數名稱,以底線 ``_`` 取代連字號 ``-``。metavar_ 參數預設為大" -"寫的名稱。例如: ::" +"dest_ 參數預設為引數名稱,以底線 ``_`` 取代連字號 ``-``。metavar_ 參數預設為" +"大寫的名稱。例如: ::" -#: ../../library/argparse.rst:739 +#: ../../library/argparse.rst:741 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo-bar')\n" @@ -1475,11 +1479,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo-bar FOO-BAR" -#: ../../library/argparse.rst:754 +#: ../../library/argparse.rst:756 msgid "action" msgstr "action" -#: ../../library/argparse.rst:756 +#: ../../library/argparse.rst:758 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -1493,13 +1497,13 @@ msgstr "" "meth:`~ArgumentParser.parse_args` 回傳的物件中。``action`` 關鍵字引數指定命令" "列引數應如何被處理。提供的 action 有:" -#: ../../library/argparse.rst:762 +#: ../../library/argparse.rst:764 msgid "" "``'store'`` - This just stores the argument's value. This is the default " "action." msgstr "``'store'`` - 這只是儲存引數的值。這是預設的 action。" -#: ../../library/argparse.rst:765 +#: ../../library/argparse.rst:767 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -1510,7 +1514,7 @@ msgstr "" "引數預設為 ``None``。``'store_const'`` action 最常與指定某種旗標的可選引數一" "起使用。例如: ::" -#: ../../library/argparse.rst:770 +#: ../../library/argparse.rst:772 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" @@ -1522,7 +1526,7 @@ msgstr "" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:775 +#: ../../library/argparse.rst:777 msgid "" "``'store_true'`` and ``'store_false'`` - These are special cases of " "``'store_const'`` that respectively store the values ``True`` and ``False`` " @@ -1531,7 +1535,7 @@ msgstr "" "``'store_true'`` 和 ``'store_false'`` - 這些是 ``'store_const'`` 的特殊情況," "分別儲存值 ``True`` 和 ``False``,預設值為 ``False`` 和 ``True``: ::" -#: ../../library/argparse.rst:780 +#: ../../library/argparse.rst:782 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1547,7 +1551,7 @@ msgstr "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:787 +#: ../../library/argparse.rst:789 msgid "" "``'append'`` - This appends each argument value to a list. It is useful for " "allowing an option to be specified multiple times. If the default value is a " @@ -1559,7 +1563,7 @@ msgstr "" "很有用。如果預設值是一個非空的串列,剖析後的值會以預設串列的元素開始,命令列" "的任何值則會附加在那些預設值之後。使用範例: ::" -#: ../../library/argparse.rst:793 +#: ../../library/argparse.rst:795 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='append', default=['0'])\n" @@ -1571,7 +1575,7 @@ msgstr "" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" "Namespace(foo=['0', '1', '2'])" -#: ../../library/argparse.rst:798 +#: ../../library/argparse.rst:800 msgid "" "``'append_const'`` - This appends the value specified by the const_ keyword " "argument to a list; note that the const_ keyword argument defaults to " @@ -1582,7 +1586,7 @@ msgstr "" "意 const_ 關鍵字引數預設為 ``None``。``'append_const'`` action 通常在多個引數" "需要將常數儲存到同一個串列時很有用。例如: ::" -#: ../../library/argparse.rst:804 +#: ../../library/argparse.rst:806 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1600,7 +1604,7 @@ msgstr "" ">>> parser.parse_args('--str --int'.split())\n" "Namespace(types=[, ])" -#: ../../library/argparse.rst:810 +#: ../../library/argparse.rst:812 msgid "" "``'extend'`` - This appends each item from a multi-value argument to a list. " "The ``'extend'`` action is typically used with the nargs_ keyword argument " @@ -1613,7 +1617,7 @@ msgstr "" "``None``\\ (預設值)或 ``'?'`` 時,引數字串的每個字元都會被附加到串列中。使" "用範例: ::" -#: ../../library/argparse.rst:818 +#: ../../library/argparse.rst:820 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " @@ -1629,14 +1633,14 @@ msgstr "" "\"f4\"])\n" "Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -#: ../../library/argparse.rst:825 +#: ../../library/argparse.rst:827 msgid "" "``'count'`` - This counts the number of times an argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" "``'count'`` - 這會計算引數出現的次數。例如,這對於增加詳細程度等級很有用: ::" -#: ../../library/argparse.rst:828 +#: ../../library/argparse.rst:830 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" @@ -1648,11 +1652,11 @@ msgstr "" ">>> parser.parse_args(['-vvv'])\n" "Namespace(verbose=3)" -#: ../../library/argparse.rst:833 +#: ../../library/argparse.rst:835 msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." msgstr "請注意,除非明確設為 *0*,否則 *default* 將為 ``None``。" -#: ../../library/argparse.rst:835 +#: ../../library/argparse.rst:837 msgid "" "``'help'`` - This prints a complete help message for all the options in the " "current parser and then exits. By default a help action is automatically " @@ -1663,7 +1667,7 @@ msgstr "" "下,help action 會自動加入到剖析器。有關輸出如何建立的詳情,請參閱 :class:" "`ArgumentParser`。" -#: ../../library/argparse.rst:840 +#: ../../library/argparse.rst:842 msgid "" "``'version'`` - This expects a ``version=`` keyword argument in the :meth:" "`~ArgumentParser.add_argument` call, and prints version information and " @@ -1672,7 +1676,7 @@ msgstr "" "``'version'`` - 這預期在 :meth:`~ArgumentParser.add_argument` 呼叫中有一個 " "``version=`` 關鍵字引數,並在被呼叫時印出版本資訊並退出: ::" -#: ../../library/argparse.rst:844 +#: ../../library/argparse.rst:846 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1688,7 +1692,7 @@ msgstr "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" -#: ../../library/argparse.rst:850 +#: ../../library/argparse.rst:852 msgid "" "You may also specify an arbitrary action by passing an :class:`Action` " "subclass (e.g. :class:`BooleanOptionalAction`) or other object that " @@ -1701,7 +1705,7 @@ msgstr "" "action(例如 ``'store'``、``'append'``、``'extend'`` 或 ``nargs`` 不為零的自" "訂 action)可用於位置引數。" -#: ../../library/argparse.rst:856 +#: ../../library/argparse.rst:858 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " "overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " @@ -1714,11 +1718,11 @@ msgstr "" "使用 :meth:`~ArgumentParser.register` 方法註冊自訂 action,並透過它們的註冊名" "稱來參照。" -#: ../../library/argparse.rst:861 +#: ../../library/argparse.rst:863 msgid "An example of a custom action::" msgstr "自訂 action 的範例: ::" -#: ../../library/argparse.rst:863 +#: ../../library/argparse.rst:865 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1756,15 +1760,15 @@ msgstr "" ">>> args\n" "Namespace(bar='1', foo='2')" -#: ../../library/argparse.rst:881 +#: ../../library/argparse.rst:883 msgid "For more details, see :class:`Action`." msgstr "更多詳情請見 :class:`Action`。" -#: ../../library/argparse.rst:887 +#: ../../library/argparse.rst:889 msgid "nargs" msgstr "nargs" -#: ../../library/argparse.rst:889 +#: ../../library/argparse.rst:891 msgid "" ":class:`ArgumentParser` objects usually associate a single command-line " "argument with a single action to be taken. The ``nargs`` keyword argument " @@ -1776,14 +1780,14 @@ msgstr "" "來。``nargs`` 關鍵字引數會將不同數量的命令列引數與單個 action 關聯。另請參閱" "\\ :ref:`specifying-ambiguous-arguments`。支援的值有:" -#: ../../library/argparse.rst:894 +#: ../../library/argparse.rst:896 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" "``N``\\ (一個整數)。命令列中的 ``N`` 個引數會被收集到一個串列中。例如: ::" -#: ../../library/argparse.rst:897 +#: ../../library/argparse.rst:899 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1797,7 +1801,7 @@ msgstr "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" -#: ../../library/argparse.rst:903 +#: ../../library/argparse.rst:905 msgid "" "Note that ``nargs=1`` produces a list of one item. This is different from " "the default, in which the item is produced by itself." @@ -1805,7 +1809,7 @@ msgstr "" "請注意 ``nargs=1`` 會產生一個只有一個項目的串列。這與預設情況不同,預設情況下" "項目會單獨產生。" -#: ../../library/argparse.rst:908 +#: ../../library/argparse.rst:910 msgid "" "``'?'``. One argument will be consumed from the command line if possible, " "and produced as a single item. If no command-line argument is present, the " @@ -1819,7 +1823,7 @@ msgstr "" "選項字串存在但後面沒有跟著命令列引數,在這種情況下會產生 const_ 的值。以下是" "這個情況的範例: ::" -#: ../../library/argparse.rst:915 +#: ../../library/argparse.rst:917 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1841,13 +1845,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" -#: ../../library/argparse.rst:925 +#: ../../library/argparse.rst:927 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "``nargs='?'`` 比較常見的用途之一是允許可選的輸入和輸出檔案: ::" -#: ../../library/argparse.rst:928 +#: ../../library/argparse.rst:930 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', nargs='?')\n" @@ -1869,7 +1873,7 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(infile=None, outfile=None)" -#: ../../library/argparse.rst:940 +#: ../../library/argparse.rst:942 msgid "" "``'*'``. All command-line arguments present are gathered into a list. Note " "that it generally doesn't make much sense to have more than one positional " @@ -1880,7 +1884,7 @@ msgstr "" "``nargs='*'`` 的位置引數通常沒有太大意義,但多個 ``nargs='*'`` 的可選引數是可" "能的。例如: ::" -#: ../../library/argparse.rst:945 +#: ../../library/argparse.rst:947 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1896,7 +1900,7 @@ msgstr "" ">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" "Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" -#: ../../library/argparse.rst:954 +#: ../../library/argparse.rst:956 msgid "" "``'+'``. Just like ``'*'``, all command-line arguments present are gathered " "into a list. Additionally, an error message will be generated if there " @@ -1905,7 +1909,7 @@ msgstr "" "``'+'``。與 ``'*'`` 一樣,所有存在的命令列引數都會被收集到一個串列中。此外," "如果沒有至少一個命令列引數存在就會產生一個錯誤訊息。例如: ::" -#: ../../library/argparse.rst:958 +#: ../../library/argparse.rst:960 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1923,7 +1927,7 @@ msgstr "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:966 +#: ../../library/argparse.rst:968 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " @@ -1935,11 +1939,11 @@ msgstr "" "意味著會消耗單個命令列引數並產生單個項目(而非串列)。不消耗命令列引數的 " "action(例如 ``'store_const'``)會設定 ``nargs=0``。" -#: ../../library/argparse.rst:976 +#: ../../library/argparse.rst:978 msgid "const" msgstr "const" -#: ../../library/argparse.rst:978 +#: ../../library/argparse.rst:980 msgid "" "The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to " "hold constant values that are not read from the command line but are " @@ -1949,7 +1953,7 @@ msgstr "" ":meth:`~ArgumentParser.add_argument` 的 ``const`` 引數用於保存不從命令列讀取" "但為各種 :class:`ArgumentParser` action 所需的常數值。它最常見的兩種用途是:" -#: ../../library/argparse.rst:982 +#: ../../library/argparse.rst:984 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " @@ -1964,7 +1968,7 @@ msgstr "" "述。如果未向 :meth:`~ArgumentParser.add_argument` 提供 ``const``,它會接收預" "設值 ``None``。" -#: ../../library/argparse.rst:990 +#: ../../library/argparse.rst:992 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1978,7 +1982,7 @@ msgstr "" "數。剖析命令列時,如果遇到選項字串但後面沒有命令列引數,會使用 ``const`` 的" "值。範例請參閱 nargs_ 描述。" -#: ../../library/argparse.rst:997 +#: ../../library/argparse.rst:999 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." @@ -1986,11 +1990,11 @@ msgstr "" "``const=None`` 為預設值,包括當 ``action='append_const'`` 或 " "``action='store_const'`` 時。" -#: ../../library/argparse.rst:1004 +#: ../../library/argparse.rst:1006 msgid "default" msgstr "default" -#: ../../library/argparse.rst:1006 +#: ../../library/argparse.rst:1008 msgid "" "All optional arguments and some positional arguments may be omitted at the " "command line. The ``default`` keyword argument of :meth:`~ArgumentParser." @@ -2004,7 +2008,7 @@ msgstr "" "數不存在時應使用的值。對於可選引數,當選項字串不在命令列上時會使用 " "``default`` 值: ::" -#: ../../library/argparse.rst:1013 +#: ../../library/argparse.rst:1015 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -2020,14 +2024,14 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1020 +#: ../../library/argparse.rst:1022 msgid "" "If the target namespace already has an attribute set, the action *default* " "will not overwrite it::" msgstr "" "如果目標命名空間已經設定了一個屬性,action 的 *default* 不會覆寫它: ::" -#: ../../library/argparse.rst:1023 +#: ../../library/argparse.rst:1025 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -2039,7 +2043,7 @@ msgstr "" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" -#: ../../library/argparse.rst:1028 +#: ../../library/argparse.rst:1030 msgid "" "If the ``default`` value is a string, the parser parses the value as if it " "were a command-line argument. In particular, the parser applies any type_ " @@ -2050,7 +2054,7 @@ msgstr "" "果有提供 type_ 轉換引數,剖析器會在設定 :class:`Namespace` 回傳值的屬性之前先" "套用它。否則剖析器會直接使用該值: ::" -#: ../../library/argparse.rst:1033 +#: ../../library/argparse.rst:1035 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -2064,7 +2068,7 @@ msgstr "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" -#: ../../library/argparse.rst:1039 +#: ../../library/argparse.rst:1041 msgid "" "For positional arguments with nargs_ equal to ``?`` or ``*``, the " "``default`` value is used when no command-line argument was present::" @@ -2072,7 +2076,7 @@ msgstr "" "對於 nargs_ 等於 ``?`` 或 ``*`` 的位置引數,當沒有命令列引數存在時會使用 " "``default`` 值: ::" -#: ../../library/argparse.rst:1042 +#: ../../library/argparse.rst:1044 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -2088,7 +2092,7 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1049 +#: ../../library/argparse.rst:1051 msgid "" "For required_ arguments, the ``default`` value is ignored. For example, this " "applies to positional arguments with nargs_ values other than ``?`` or " @@ -2097,7 +2101,7 @@ msgstr "" "對於 required_ 引數,``default`` 值會被忽略。例如,這適用於 nargs_ 值不是 ``?" "`` 或 ``*`` 的位置引數,或是標記為 ``required=True`` 的可選引數。" -#: ../../library/argparse.rst:1053 +#: ../../library/argparse.rst:1055 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" @@ -2105,7 +2109,7 @@ msgstr "" "若有提供 ``default=argparse.SUPPRESS``,命令列引數不存在時就不會加入任何屬" "性: ::" -#: ../../library/argparse.rst:1056 +#: ../../library/argparse.rst:1058 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -2121,11 +2125,11 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:1067 +#: ../../library/argparse.rst:1069 msgid "type" msgstr "type" -#: ../../library/argparse.rst:1069 +#: ../../library/argparse.rst:1071 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -2137,7 +2141,7 @@ msgstr "" "一種型別,例如 :class:`float` 或 :class:`int`。:meth:`~ArgumentParser." "add_argument` 的 ``type`` 關鍵字允許執行任何必要的型別檢查和型別轉換。" -#: ../../library/argparse.rst:1075 +#: ../../library/argparse.rst:1077 msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." @@ -2145,7 +2149,7 @@ msgstr "" "如果 type_ 關鍵字與 default_ 關鍵字一起使用,型別轉換器只會在預設值為字串時套" "用。" -#: ../../library/argparse.rst:1078 +#: ../../library/argparse.rst:1080 msgid "" "The argument to ``type`` can be a callable that accepts a single string or " "the name of a registered type (see :meth:`~ArgumentParser.register`) If the " @@ -2158,11 +2162,11 @@ msgstr "" "`ArgumentTypeError`、:exc:`TypeError` 或 :exc:`ValueError`,剖析器會捕捉例外" "並顯示格式良好的錯誤訊息。其他例外型別則不處理。" -#: ../../library/argparse.rst:1084 +#: ../../library/argparse.rst:1086 msgid "Common built-in types and functions can be used as type converters:" msgstr "常見的內建型別和函式可以作為型別轉換器使用:" -#: ../../library/argparse.rst:1086 +#: ../../library/argparse.rst:1088 msgid "" "import argparse\n" "import pathlib\n" @@ -2184,11 +2188,11 @@ msgstr "" "parser.add_argument('code_point', type=ord)\n" "parser.add_argument('datapath', type=pathlib.Path)" -#: ../../library/argparse.rst:1098 +#: ../../library/argparse.rst:1100 msgid "User defined functions can be used as well:" msgstr "也可以用那些使用者定義的函式:" -#: ../../library/argparse.rst:1100 +#: ../../library/argparse.rst:1102 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -2206,7 +2210,7 @@ msgstr "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1110 +#: ../../library/argparse.rst:1112 msgid "" "The :func:`bool` function is not recommended as a type converter. All it " "does is convert empty strings to ``False`` and non-empty strings to " @@ -2215,7 +2219,7 @@ msgstr "" "不建議使用 :func:`bool` 函式作為型別轉換器。它所做的只是將空字串轉為 " "``False``,將非空字串轉為 ``True``。這通常不是期望的行為。" -#: ../../library/argparse.rst:1114 +#: ../../library/argparse.rst:1116 msgid "" "In general, the ``type`` keyword is a convenience that should only be used " "for simple conversions that can only raise one of the three supported " @@ -2225,7 +2229,7 @@ msgstr "" "一般而言,``type`` 關鍵字是一個便利功能,應只用於只會引發三種支援的例外之一的" "簡單轉換。任何更複雜的錯誤處理或資源管理都應在引數剖析之後的下游進行。" -#: ../../library/argparse.rst:1119 +#: ../../library/argparse.rst:1121 msgid "" "For example, JSON or YAML conversions have complex error cases that require " "better reporting than can be given by the ``type`` keyword. A :exc:`~json." @@ -2236,7 +2240,7 @@ msgstr "" "好的報告。:exc:`~json.JSONDecodeError` 無法得到良好的格式化,而 :exc:" "`FileNotFoundError` 例外則完全不會處理。" -#: ../../library/argparse.rst:1124 +#: ../../library/argparse.rst:1126 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " "``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " @@ -2250,17 +2254,17 @@ msgstr "" "報告錯誤但檔案不會自動關閉。在這種情況下,最好等到剖析器執行完畢後,再使用 :" "keyword:`with` 陳述式來管理檔案。" -#: ../../library/argparse.rst:1131 +#: ../../library/argparse.rst:1133 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "對於僅檢查固定值集合的型別檢查器,請考慮改用 choices_ 關鍵字。" -#: ../../library/argparse.rst:1138 +#: ../../library/argparse.rst:1140 msgid "choices" msgstr "choices" -#: ../../library/argparse.rst:1140 +#: ../../library/argparse.rst:1142 msgid "" "Some command-line arguments should be selected from a restricted set of " "values. These can be handled by passing a sequence object as the *choices* " @@ -2272,7 +2276,7 @@ msgstr "" "字引數傳給 :meth:`~ArgumentParser.add_argument` 來處理。剖析命令列時會檢查引" "數值,如果引數不是可接受的值之一,就會顯示錯誤訊息: ::" -#: ../../library/argparse.rst:1146 +#: ../../library/argparse.rst:1148 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -2292,7 +2296,7 @@ msgstr "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" -#: ../../library/argparse.rst:1155 +#: ../../library/argparse.rst:1157 msgid "" "Any sequence can be passed as the *choices* value, so :class:`list` " "objects, :class:`tuple` objects, and custom sequences are all supported." @@ -2300,14 +2304,14 @@ msgstr "" "任何序列都可以作為 *choices* 值傳入,因此 :class:`list` 物件、:class:`tuple` " "物件和自訂序列都有被支援。" -#: ../../library/argparse.rst:1158 +#: ../../library/argparse.rst:1160 msgid "" "Use of :class:`enum.Enum` is not recommended because it is difficult to " "control its appearance in usage, help, and error messages." msgstr "" "不建議使用 :class:`enum.Enum`,因為很難控制它在用法、說明和錯誤訊息中的長相。" -#: ../../library/argparse.rst:1161 +#: ../../library/argparse.rst:1163 msgid "" "Note that *choices* are checked after any type_ conversions have been " "performed, so objects in *choices* should match the type_ specified. This " @@ -2317,7 +2321,7 @@ msgstr "" "物件應符合指定的 type_。這可能使 *choices* 在用法、說明或錯誤訊息中的長相看起" "來不尋常。" -#: ../../library/argparse.rst:1166 +#: ../../library/argparse.rst:1168 msgid "" "To keep *choices* user-friendly, consider a custom type wrapper that " "converts and formats values, or omit type_ and handle conversion in your " @@ -2326,7 +2330,7 @@ msgstr "" "若要保持 *choices* 對使用者友善,請考慮使用自訂型別包裝器來轉換和格式化值,或" "是省略 type_ 並在你的應用程式碼中處理轉換。" -#: ../../library/argparse.rst:1170 +#: ../../library/argparse.rst:1172 msgid "" "Formatted choices override the default *metavar* which is normally derived " "from *dest*. This is usually what you want because the user never sees the " @@ -2337,11 +2341,11 @@ msgstr "" "使用者永遠看不到 *dest* 參數。如果此顯示不理想(也許因為有很多選擇),只需指" "定一個明確的 metavar_。" -#: ../../library/argparse.rst:1179 +#: ../../library/argparse.rst:1181 msgid "required" msgstr "required" -#: ../../library/argparse.rst:1181 +#: ../../library/argparse.rst:1183 msgid "" "In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " @@ -2353,7 +2357,7 @@ msgstr "" "以為 :meth:`~ArgumentParser.add_argument` 的 ``required=`` 關鍵字引數指定 " "``True``: ::" -#: ../../library/argparse.rst:1186 +#: ../../library/argparse.rst:1188 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -2371,7 +2375,7 @@ msgstr "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" -#: ../../library/argparse.rst:1194 +#: ../../library/argparse.rst:1196 msgid "" "As the example shows, if an option is marked as ``required``, :meth:" "`~ArgumentParser.parse_args` will report an error if that option is not " @@ -2380,7 +2384,7 @@ msgstr "" "如範例所示,如果一個選項被標記為 ``required``,:meth:`~ArgumentParser." "parse_args` 會在該選項不在命令列上時報告錯誤。" -#: ../../library/argparse.rst:1200 +#: ../../library/argparse.rst:1202 msgid "" "Required options are generally considered bad form because users expect " "*options* to be *optional*, and thus they should be avoided when possible." @@ -2388,11 +2392,11 @@ msgstr "" "必要選項一般認為是不良做法,因為使用者期望\\ *選項*\\ 是\\ *可選的*,因此應盡" "可能避免使用。" -#: ../../library/argparse.rst:1207 +#: ../../library/argparse.rst:1209 msgid "help" msgstr "help" -#: ../../library/argparse.rst:1209 +#: ../../library/argparse.rst:1211 msgid "" "The ``help`` value is a string containing a brief description of the " "argument. When a user requests help (usually by using ``-h`` or ``--help`` " @@ -2402,7 +2406,7 @@ msgstr "" "``help`` 值是一個包含引數簡短描述的字串。當使用者請求說明(通常是在命令列上使" "用 ``-h`` 或 ``--help``)時,這些 ``help`` 描述會與每個引數一起顯示。" -#: ../../library/argparse.rst:1214 +#: ../../library/argparse.rst:1216 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " @@ -2414,7 +2418,7 @@ msgstr "" "內容。可用的說明符號包括程式名稱 ``%(prog)s`` 以及 :meth:`~ArgumentParser." "add_argument` 的大多數關鍵字引數,例如 ``%(default)s``、``%(type)s`` 等: ::" -#: ../../library/argparse.rst:1219 +#: ../../library/argparse.rst:1221 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -2440,7 +2444,7 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1231 +#: ../../library/argparse.rst:1233 msgid "" "As the help string supports %-formatting, if you want a literal ``%`` to " "appear in the help string, you must escape it as ``%%``." @@ -2448,7 +2452,7 @@ msgstr "" "由於 help 字串支援 %-格式化,如果你想讓文字 ``%`` 出現在 help 字串中,你必須" "將它跳脫為 ``%%``。" -#: ../../library/argparse.rst:1234 +#: ../../library/argparse.rst:1236 msgid "" ":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" @@ -2456,7 +2460,7 @@ msgstr "" ":mod:`!argparse` 支援透過將 ``help`` 值設為 ``argparse.SUPPRESS`` 來隱藏某些" "選項的說明條目: ::" -#: ../../library/argparse.rst:1237 +#: ../../library/argparse.rst:1239 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -2474,11 +2478,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1249 +#: ../../library/argparse.rst:1251 msgid "metavar" msgstr "metavar" -#: ../../library/argparse.rst:1251 +#: ../../library/argparse.rst:1253 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " "refer to each expected argument. By default, :class:`!ArgumentParser` " @@ -2495,7 +2499,7 @@ msgstr "" "值轉為大寫。因此,一個 ``dest='bar'`` 的位置引數稱為 ``bar``。一個應後接單一" "命令列引數的 ``--foo`` 可選引數稱為 ``FOO``。範例: ::" -#: ../../library/argparse.rst:1260 +#: ../../library/argparse.rst:1262 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2527,11 +2531,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO" -#: ../../library/argparse.rst:1275 +#: ../../library/argparse.rst:1277 msgid "An alternative name can be specified with ``metavar``::" msgstr "可以用 ``metavar`` 指定替代名稱: ::" -#: ../../library/argparse.rst:1277 +#: ../../library/argparse.rst:1279 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2563,7 +2567,7 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo YYY" -#: ../../library/argparse.rst:1292 +#: ../../library/argparse.rst:1294 msgid "" "Note that ``metavar`` only changes the *displayed* name - the name of the " "attribute on the :meth:`~ArgumentParser.parse_args` object is still " @@ -2572,7 +2576,7 @@ msgstr "" "請注意 ``metavar`` 只會更改\\ *顯示*\\ 的名稱——:meth:`~ArgumentParser." "parse_args` 物件上的屬性名稱仍由 dest_ 值決定。" -#: ../../library/argparse.rst:1296 +#: ../../library/argparse.rst:1298 msgid "" "Different values of ``nargs`` may cause the metavar to be used multiple " "times. Providing a tuple to ``metavar`` specifies a different display for " @@ -2581,7 +2585,7 @@ msgstr "" "不同的 ``nargs`` 值可能導致 metavar 被多次使用。提供一個元組給 ``metavar`` 可" "以為每個引數指定不同的顯示: ::" -#: ../../library/argparse.rst:1300 +#: ../../library/argparse.rst:1302 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2605,11 +2609,11 @@ msgstr "" " -x X X\n" " --foo bar baz" -#: ../../library/argparse.rst:1315 +#: ../../library/argparse.rst:1317 msgid "dest" msgstr "dest" -#: ../../library/argparse.rst:1317 +#: ../../library/argparse.rst:1319 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " @@ -2623,7 +2627,7 @@ msgstr "" "add_argument` 的 ``dest`` 關鍵字引數決定。對於位置引數 action,``dest`` 通常" "作為 :meth:`~ArgumentParser.add_argument` 的第一個引數提供: ::" -#: ../../library/argparse.rst:1324 +#: ../../library/argparse.rst:1326 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" @@ -2635,7 +2639,7 @@ msgstr "" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1329 +#: ../../library/argparse.rst:1331 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -2652,7 +2656,7 @@ msgstr "" "的 ``-`` 字元來衍生。任何內部的 ``-`` 字元都會轉為 ``_`` 字元,以確保該字串是" "有效的屬性名稱。以下範例說明了此行為: ::" -#: ../../library/argparse.rst:1338 +#: ../../library/argparse.rst:1340 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" @@ -2670,11 +2674,11 @@ msgstr "" ">>> parser.parse_args('--foo 1 -y 2'.split())\n" "Namespace(foo_bar='1', x='2')" -#: ../../library/argparse.rst:1346 +#: ../../library/argparse.rst:1348 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "``dest`` 允許提供自訂的屬性名稱: ::" -#: ../../library/argparse.rst:1348 +#: ../../library/argparse.rst:1350 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" @@ -2686,11 +2690,11 @@ msgstr "" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1357 +#: ../../library/argparse.rst:1359 msgid "deprecated" msgstr "deprecated" -#: ../../library/argparse.rst:1359 +#: ../../library/argparse.rst:1361 msgid "" "During a project's lifetime, some arguments may need to be removed from the " "command line. Before removing them, you should inform your users that the " @@ -2706,7 +2710,7 @@ msgstr "" "除。對於引數,如果 ``deprecated`` 為 ``True``,那麼使用該引數時會向 :data:" "`sys.stderr` 印出警告: ::" -#: ../../library/argparse.rst:1369 +#: ../../library/argparse.rst:1371 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='snake.py')\n" @@ -2726,11 +2730,11 @@ msgstr "" "snake.py: warning: option '--legs' is deprecated\n" "Namespace(legs=4)" -#: ../../library/argparse.rst:1382 +#: ../../library/argparse.rst:1384 msgid "Action classes" msgstr "Action 類別" -#: ../../library/argparse.rst:1384 +#: ../../library/argparse.rst:1386 msgid "" ":class:`!Action` classes implement the Action API, a callable which returns " "a callable which processes arguments from the command-line. Any object which " @@ -2741,7 +2745,7 @@ msgstr "" "命令列引數的可呼叫物件。任何遵循此 API 的物件都可以作為 ``action`` 參數傳給 :" "meth:`~ArgumentParser.add_argument`。" -#: ../../library/argparse.rst:1393 +#: ../../library/argparse.rst:1395 msgid "" ":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " "the information needed to parse a single argument from one or more strings " @@ -2754,7 +2758,7 @@ msgstr "" "給 :meth:`ArgumentParser.add_argument` 的任何關鍵字引數(除了 ``action`` 本" "身)。" -#: ../../library/argparse.rst:1399 +#: ../../library/argparse.rst:1401 msgid "" "Instances of :class:`!Action` (or return value of any callable to the " "``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" @@ -2767,7 +2771,7 @@ msgstr "" "attr:`!required`、:attr:`!help` 等屬性。確保這些屬性被定義的最簡單方式是呼" "叫 :meth:`!Action.__init__`。" -#: ../../library/argparse.rst:1407 +#: ../../library/argparse.rst:1409 msgid "" ":class:`!Action` instances should be callable, so subclasses must override " "the :meth:`!__call__` method, which should accept four parameters:" @@ -2775,12 +2779,12 @@ msgstr "" ":class:`!Action` 實例應該是可呼叫的,因此子類別必須覆寫 :meth:`!__call__` 方" "法,它應接受四個參數:" -#: ../../library/argparse.rst:1410 +#: ../../library/argparse.rst:1412 msgid "" "*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "*parser* - 包含此 action 的 :class:`ArgumentParser` 物件。" -#: ../../library/argparse.rst:1412 +#: ../../library/argparse.rst:1414 msgid "" "*namespace* - The :class:`Namespace` object that will be returned by :meth:" "`~ArgumentParser.parse_args`. Most actions add an attribute to this object " @@ -2789,7 +2793,7 @@ msgstr "" "*namespace* - 將由 :meth:`~ArgumentParser.parse_args` 回傳的 :class:" "`Namespace` 物件。大多數 action 使用 :func:`setattr` 將屬性加入此物件。" -#: ../../library/argparse.rst:1416 +#: ../../library/argparse.rst:1418 msgid "" "*values* - The associated command-line arguments, with any type conversions " "applied. Type conversions are specified with the type_ keyword argument to :" @@ -2798,7 +2802,7 @@ msgstr "" "*values* - 相關聯的命令列引數,已套用任何型別轉換。型別轉換透過 :meth:" "`~ArgumentParser.add_argument` 的 type_ 關鍵字引數指定。" -#: ../../library/argparse.rst:1420 +#: ../../library/argparse.rst:1422 msgid "" "*option_string* - The option string that was used to invoke this action. The " "``option_string`` argument is optional, and will be absent if the action is " @@ -2807,7 +2811,7 @@ msgstr "" "*option_string* - 用來呼叫此 action 的選項字串。``option_string`` 引數是可選" "的,如果 action 與位置引數關聯則不會出現。" -#: ../../library/argparse.rst:1424 +#: ../../library/argparse.rst:1426 msgid "" "The :meth:`!__call__` method may perform arbitrary actions, but will " "typically set attributes on the ``namespace`` based on ``dest`` and " @@ -2816,7 +2820,7 @@ msgstr "" ":meth:`!__call__` 方法可以執行任意動作,但通常會根據 ``dest`` 和 ``values`` " "在 ``namespace`` 上設定屬性。" -#: ../../library/argparse.rst:1429 +#: ../../library/argparse.rst:1431 msgid "" ":class:`!Action` subclasses can define a :meth:`!format_usage` method that " "takes no argument and return a string which will be used when printing the " @@ -2827,7 +2831,7 @@ msgstr "" "並回傳一個字串,該字串會在印出程式用法時使用。如果未提供此方法,會使用合理的" "預設值。" -#: ../../library/argparse.rst:1435 +#: ../../library/argparse.rst:1437 msgid "" "A subclass of :class:`Action` for handling boolean flags with positive and " "negative options. Adding a single argument such as ``--foo`` automatically " @@ -2838,7 +2842,7 @@ msgstr "" "foo`` 這樣的單個引數會自動建立 ``--foo`` 和 ``--no-foo`` 選項,其分別儲存 " "``True`` 和 ``False``: ::" -#: ../../library/argparse.rst:1440 +#: ../../library/argparse.rst:1442 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -2852,18 +2856,18 @@ msgstr "" ">>> parser.parse_args(['--no-foo'])\n" "Namespace(foo=False)" -#: ../../library/argparse.rst:1450 +#: ../../library/argparse.rst:1452 msgid "The parse_args() method" msgstr "parse_args() 方法" -#: ../../library/argparse.rst:1454 +#: ../../library/argparse.rst:1456 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" "將引數字串轉換為物件並將它們指定為命名空間的屬性。回傳填充後的命名空間。" -#: ../../library/argparse.rst:1457 +#: ../../library/argparse.rst:1459 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " "created and how they are assigned. See the documentation for :meth:`!" @@ -2872,24 +2876,24 @@ msgstr "" "先前對 :meth:`add_argument` 的呼叫決定了確切建立什麼物件以及如何指定它們。詳" "情請參閱 :meth:`!add_argument` 的文件。" -#: ../../library/argparse.rst:1461 +#: ../../library/argparse.rst:1463 msgid "" "args_ - List of strings to parse. The default is taken from :data:`sys." "argv`." msgstr "args_ - 要剖析的字串串列。預設值取自 :data:`sys.argv`。" -#: ../../library/argparse.rst:1464 +#: ../../library/argparse.rst:1466 msgid "" "namespace_ - An object to take the attributes. The default is a new empty :" "class:`Namespace` object." msgstr "" "namespace_ - 接收屬性的物件。預設值是一個新的空 :class:`Namespace` 物件。" -#: ../../library/argparse.rst:1469 +#: ../../library/argparse.rst:1471 msgid "Option value syntax" msgstr "選項值語法" -#: ../../library/argparse.rst:1471 +#: ../../library/argparse.rst:1473 msgid "" "The :meth:`~ArgumentParser.parse_args` method supports several ways of " "specifying the value of an option (if it takes one). In the simplest case, " @@ -2898,7 +2902,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法支援多種方式來指定選項的值(如果它接受" "值的話)。在最簡單的情況下,選項和它的值作為兩個獨立的引數傳入: ::" -#: ../../library/argparse.rst:1475 +#: ../../library/argparse.rst:1477 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2916,7 +2920,7 @@ msgstr "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1483 +#: ../../library/argparse.rst:1485 msgid "" "For long options (options with names longer than a single character), the " "option and value can also be passed as a single command-line argument, using " @@ -2925,7 +2929,7 @@ msgstr "" "對於長選項(名稱長度超過一個字元的選項),選項和值也可以作為單個命令列引數傳" "入,使用 ``=`` 來分隔它們: ::" -#: ../../library/argparse.rst:1487 +#: ../../library/argparse.rst:1489 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" @@ -2933,13 +2937,13 @@ msgstr "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1490 +#: ../../library/argparse.rst:1492 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "對於短選項(只有一個字元長的選項),選項和它的值可以串接在一起: ::" -#: ../../library/argparse.rst:1493 +#: ../../library/argparse.rst:1495 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" @@ -2947,7 +2951,7 @@ msgstr "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" -#: ../../library/argparse.rst:1496 +#: ../../library/argparse.rst:1498 msgid "" "Several short options can be joined together, using only a single ``-`` " "prefix, as long as only the last option (or none of them) requires a value::" @@ -2955,7 +2959,7 @@ msgstr "" "如果只有最後一個選項需要值(或都不需要),多個短選項就可以被合併在一起、只使" "用一個 ``-`` 前綴: ::" -#: ../../library/argparse.rst:1499 +#: ../../library/argparse.rst:1501 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -2971,11 +2975,11 @@ msgstr "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" -#: ../../library/argparse.rst:1508 +#: ../../library/argparse.rst:1510 msgid "Invalid arguments" msgstr "無效引數" -#: ../../library/argparse.rst:1510 +#: ../../library/argparse.rst:1512 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -2986,7 +2990,7 @@ msgstr "" "的選項、無效的型別、無效的選項、錯誤的位置引數數量等。當遇到此類錯誤時,它會" "退出並印出錯誤及用法訊息: ::" -#: ../../library/argparse.rst:1515 +#: ../../library/argparse.rst:1517 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -3026,11 +3030,11 @@ msgstr "" "usage: PROG [-h] [--foo FOO] [bar]\n" "PROG: error: extra arguments found: badger" -#: ../../library/argparse.rst:1536 +#: ../../library/argparse.rst:1538 msgid "Arguments containing ``-``" msgstr "包含 ``-`` 的引數" -#: ../../library/argparse.rst:1538 +#: ../../library/argparse.rst:1540 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -3047,7 +3051,7 @@ msgstr "" "位置引數只有在看起來像負數且剖析器中沒有看起來像負數的選項時,才可以用 ``-`` " "開頭: ::" -#: ../../library/argparse.rst:1546 +#: ../../library/argparse.rst:1548 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -3109,7 +3113,7 @@ msgstr "" "usage: PROG [-h] [-1 ONE] [foo]\n" "PROG: error: argument -1: expected one argument" -#: ../../library/argparse.rst:1576 +#: ../../library/argparse.rst:1578 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -3119,7 +3123,7 @@ msgstr "" "如果你有必須以 ``-`` 開頭且不像負數的位置引數,你可以插入偽引數 ``'--'``,它" "會告訴 :meth:`~ArgumentParser.parse_args` 在此之後的所有內容都是位置引數: ::" -#: ../../library/argparse.rst:1581 +#: ../../library/argparse.rst:1583 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" @@ -3127,7 +3131,7 @@ msgstr "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1584 +#: ../../library/argparse.rst:1586 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." @@ -3135,11 +3139,11 @@ msgstr "" "更多詳情請參閱 :ref:`argparse howto 中關於有歧義引數的說明 `。" -#: ../../library/argparse.rst:1590 +#: ../../library/argparse.rst:1592 msgid "Argument abbreviations (prefix matching)" msgstr "引數縮寫 (前綴匹配)" -#: ../../library/argparse.rst:1592 +#: ../../library/argparse.rst:1594 msgid "" "The :meth:`~ArgumentParser.parse_args` method :ref:`by default " "` allows long options to be abbreviated to a prefix, if the " @@ -3148,7 +3152,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法\\ :ref:`預設 `\\ 允許長" "選項被縮寫為前綴,只要縮寫是無歧義的(前綴匹配到唯一的選項): ::" -#: ../../library/argparse.rst:1596 +#: ../../library/argparse.rst:1598 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -3172,7 +3176,7 @@ msgstr "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" -#: ../../library/argparse.rst:1607 +#: ../../library/argparse.rst:1609 msgid "" "An error is produced for arguments that could produce more than one options. " "This feature can be disabled by setting :ref:`allow_abbrev` to ``False``." @@ -3180,11 +3184,11 @@ msgstr "" "對於可能產生多個選項的引數會產生錯誤。可以透過將 :ref:`allow_abbrev` 設為 " "``False`` 來停用此功能。" -#: ../../library/argparse.rst:1613 +#: ../../library/argparse.rst:1615 msgid "Beyond ``sys.argv``" msgstr "``sys.argv`` 之外" -#: ../../library/argparse.rst:1615 +#: ../../library/argparse.rst:1617 msgid "" "Sometimes it may be useful to have an :class:`ArgumentParser` parse " "arguments other than those of :data:`sys.argv`. This can be accomplished by " @@ -3195,7 +3199,7 @@ msgstr "" "這可以透過將字串串列傳給 :meth:`~ArgumentParser.parse_args` 來完成。這對於在" "互動式提示中測試很有用: ::" -#: ../../library/argparse.rst:1620 +#: ../../library/argparse.rst:1622 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -3221,11 +3225,11 @@ msgstr "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" -#: ../../library/argparse.rst:1635 +#: ../../library/argparse.rst:1637 msgid "The Namespace object" msgstr "命名空間物件" -#: ../../library/argparse.rst:1639 +#: ../../library/argparse.rst:1641 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." @@ -3233,7 +3237,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 預設使用的簡單類別,用來建立保存屬性的物件" "並回傳它。" -#: ../../library/argparse.rst:1642 +#: ../../library/argparse.rst:1644 msgid "" "This class is deliberately simple, just an :class:`object` subclass with a " "readable string representation. If you prefer to have dict-like view of the " @@ -3242,7 +3246,7 @@ msgstr "" "這個類別刻意保持簡單,只是一個具有可讀字串表示的 :class:`object` 子類別。如果" "你偏好以類字典的方式檢視屬性,可以使用標準 Python 慣用寫法 :func:`vars`: ::" -#: ../../library/argparse.rst:1646 +#: ../../library/argparse.rst:1648 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3256,7 +3260,7 @@ msgstr "" ">>> vars(args)\n" "{'foo': 'BAR'}" -#: ../../library/argparse.rst:1652 +#: ../../library/argparse.rst:1654 msgid "" "It may also be useful to have an :class:`ArgumentParser` assign attributes " "to an already existing object, rather than a new :class:`Namespace` object. " @@ -3266,7 +3270,7 @@ msgstr "" "`Namespace` 物件也可能很有用。這可以透過指定 ``namespace=`` 關鍵字引數來達" "成: ::" -#: ../../library/argparse.rst:1656 +#: ../../library/argparse.rst:1658 msgid "" ">>> class C:\n" "... pass\n" @@ -3288,15 +3292,15 @@ msgstr "" ">>> c.foo\n" "'BAR'" -#: ../../library/argparse.rst:1668 +#: ../../library/argparse.rst:1670 msgid "Other utilities" msgstr "其他工具" -#: ../../library/argparse.rst:1671 +#: ../../library/argparse.rst:1673 msgid "Subcommands" msgstr "子命令" -#: ../../library/argparse.rst:1678 +#: ../../library/argparse.rst:1680 msgid "" "Many programs split up their functionality into a number of subcommands, for " "example, the ``svn`` program can invoke subcommands like ``svn checkout``, " @@ -3319,11 +3323,11 @@ msgstr "" "class:`!ArgumentParser` 建構函式引數,並回傳一個可以像往常一樣修改的 :class:" "`!ArgumentParser` 物件。" -#: ../../library/argparse.rst:1690 +#: ../../library/argparse.rst:1692 msgid "Description of parameters:" msgstr "參數的解釋:" -#: ../../library/argparse.rst:1692 +#: ../../library/argparse.rst:1694 msgid "" "*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " @@ -3332,13 +3336,13 @@ msgstr "" "*title* - 說明輸出中子剖析器群組的標題;預設情況下,若有提供 description 則" "為 \"subcommands\",否則使用位置引數的標題" -#: ../../library/argparse.rst:1696 +#: ../../library/argparse.rst:1698 msgid "" "*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "*description* - 說明輸出中子剖析器群組的描述,預設為 ``None``" -#: ../../library/argparse.rst:1699 +#: ../../library/argparse.rst:1701 msgid "" "*prog* - usage information that will be displayed with subcommand help, by " "default the name of the program and any positional arguments before the " @@ -3347,7 +3351,7 @@ msgstr "" "*prog* - 將與子命令說明一起顯示的用法資訊,預設為程式名稱和子剖析器引數之前的" "任何位置引數" -#: ../../library/argparse.rst:1703 +#: ../../library/argparse.rst:1705 msgid "" "*parser_class* - class which will be used to create sub-parser instances, by " "default the class of the current parser (e.g. :class:`ArgumentParser`)" @@ -3355,29 +3359,29 @@ msgstr "" "*parser_class* - 將用來建立子剖析器實例的類別,預設為目前剖析器的類別(例如 :" "class:`ArgumentParser`)" -#: ../../library/argparse.rst:1706 +#: ../../library/argparse.rst:1708 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "action_ - 在命令列遇到此引數時要執行的基本 action 類型" -#: ../../library/argparse.rst:1709 +#: ../../library/argparse.rst:1711 msgid "" "dest_ - name of the attribute under which subcommand name will be stored; by " "default ``None`` and no value is stored" msgstr "dest_ - 用於儲存子命令名稱的屬性名稱;預設為 ``None`` 且不儲存任何值" -#: ../../library/argparse.rst:1712 +#: ../../library/argparse.rst:1714 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "required_ - 是否必須提供子命令,預設為 ``False``\\ (在 3.7 中新增)" -#: ../../library/argparse.rst:1715 +#: ../../library/argparse.rst:1717 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "help_ - 說明輸出中子剖析器群組的說明,預設為 ``None``" -#: ../../library/argparse.rst:1717 +#: ../../library/argparse.rst:1719 msgid "" "metavar_ - string presenting available subcommands in help; by default it is " "``None`` and presents subcommands in form {cmd1, cmd2, ..}" @@ -3385,11 +3389,11 @@ msgstr "" "metavar_ - 在說明中呈現可用子命令的字串;預設為 ``None`` 並以 {cmd1, " "cmd2, ..} 的形式呈現子命令" -#: ../../library/argparse.rst:1720 +#: ../../library/argparse.rst:1722 msgid "Some example usage::" msgstr "一些使用範例: ::" -#: ../../library/argparse.rst:1722 +#: ../../library/argparse.rst:1724 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -3431,7 +3435,7 @@ msgstr "" ">>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])\n" "Namespace(baz='Z', foo=True)" -#: ../../library/argparse.rst:1741 +#: ../../library/argparse.rst:1743 msgid "" "Note that the object returned by :meth:`parse_args` will only contain " "attributes for the main parser and the subparser that was selected by the " @@ -3445,7 +3449,7 @@ msgstr "" "``foo`` 和 ``bar`` 屬性存在;當指定 ``b`` 命令時,只有 ``foo`` 和 ``baz`` 屬" "性存在。" -#: ../../library/argparse.rst:1748 +#: ../../library/argparse.rst:1750 msgid "" "Similarly, when a help message is requested from a subparser, only the help " "for that particular parser will be printed. The help message will not " @@ -3457,7 +3461,7 @@ msgstr "" "包含父剖析器或兄弟剖析器的訊息。(然而每個子剖析器命令的說明訊息可以透過如上" "所述向 :meth:`~_SubParsersAction.add_parser` 提供 ``help=`` 引數來給定。)" -#: ../../library/argparse.rst:1756 +#: ../../library/argparse.rst:1758 msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" @@ -3515,7 +3519,7 @@ msgstr "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1784 +#: ../../library/argparse.rst:1786 msgid "" "The :meth:`add_subparsers` method also supports ``title`` and " "``description`` keyword arguments. When either is present, the subparser's " @@ -3524,7 +3528,7 @@ msgstr "" ":meth:`add_subparsers` 方法也支援 ``title`` 和 ``description`` 關鍵字引數。當" "任一者存在時,子剖析器的命令會在說明輸出中以自己的群組出現。例如: ::" -#: ../../library/argparse.rst:1788 +#: ../../library/argparse.rst:1790 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -3560,7 +3564,7 @@ msgstr "" "\n" " {foo,bar} additional help" -#: ../../library/argparse.rst:1805 +#: ../../library/argparse.rst:1807 msgid "" "Furthermore, :meth:`~_SubParsersAction.add_parser` supports an additional " "*aliases* argument, which allows multiple strings to refer to the same " @@ -3571,7 +3575,7 @@ msgstr "" "允許多個字串參照同一個子剖析器。這個範例像 ``svn`` 一樣,將 ``co`` 作為 " "``checkout`` 的簡寫別名: ::" -#: ../../library/argparse.rst:1810 +#: ../../library/argparse.rst:1812 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers()\n" @@ -3587,7 +3591,7 @@ msgstr "" ">>> parser.parse_args(['co', 'bar'])\n" "Namespace(foo='bar')" -#: ../../library/argparse.rst:1817 +#: ../../library/argparse.rst:1819 msgid "" ":meth:`~_SubParsersAction.add_parser` supports also an additional " "*deprecated* argument, which allows to deprecate the subparser." @@ -3595,7 +3599,7 @@ msgstr "" ":meth:`~_SubParsersAction.add_parser` 也支援一個額外的 *deprecated* 引數,它" "允許棄用子剖析器。" -#: ../../library/argparse.rst:1831 +#: ../../library/argparse.rst:1833 msgid "" "One particularly effective way of handling subcommands is to combine the use " "of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so " @@ -3606,7 +3610,7 @@ msgstr "" "`set_defaults` 的呼叫結合,使每個子剖析器知道它應該執行哪個 Python 函式。例" "如: ::" -#: ../../library/argparse.rst:1836 +#: ../../library/argparse.rst:1838 msgid "" ">>> # subcommand functions\n" ">>> def foo(args):\n" @@ -3672,7 +3676,7 @@ msgstr "" ">>> args.func(args)\n" "((XYZYX))" -#: ../../library/argparse.rst:1868 +#: ../../library/argparse.rst:1870 msgid "" "This way, you can let :meth:`parse_args` do the job of calling the " "appropriate function after argument parsing is complete. Associating " @@ -3686,7 +3690,7 @@ msgstr "" "檢查被呼叫的子剖析器名稱,:meth:`add_subparsers` 呼叫的 ``dest`` 關鍵字引數可" "以達成此目的: ::" -#: ../../library/argparse.rst:1875 +#: ../../library/argparse.rst:1877 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -3706,21 +3710,21 @@ msgstr "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1884 +#: ../../library/argparse.rst:1886 msgid "New *required* keyword-only parameter." msgstr "新增 *required* 僅限關鍵字參數。" -#: ../../library/argparse.rst:1887 +#: ../../library/argparse.rst:1889 msgid "" "Subparser's *prog* is no longer affected by a custom usage message in the " "main parser." msgstr "子剖析器的 *prog* 不再受主剖析器中自訂用法訊息的影響。" -#: ../../library/argparse.rst:1893 +#: ../../library/argparse.rst:1895 msgid "FileType objects" msgstr "FileType 物件" -#: ../../library/argparse.rst:1897 +#: ../../library/argparse.rst:1899 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " "argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" @@ -3733,7 +3737,7 @@ msgstr "" "衝區大小、編碼和錯誤處理開啟命令列引數作為檔案(更多詳情請參閱 :func:`open` " "函式): ::" -#: ../../library/argparse.rst:1903 +#: ../../library/argparse.rst:1905 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -3751,7 +3755,7 @@ msgstr "" "Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " "raw=<_io.FileIO name='raw.dat' mode='wb'>)" -#: ../../library/argparse.rst:1909 +#: ../../library/argparse.rst:1911 msgid "" "FileType objects understand the pseudo-argument ``'-'`` and automatically " "convert this into :data:`sys.stdin` for readable :class:`FileType` objects " @@ -3761,7 +3765,7 @@ msgstr "" "件的 :data:`sys.stdin` 和可寫 :class:`FileType` 物件的 :data:`sys." "stdout`: ::" -#: ../../library/argparse.rst:1913 +#: ../../library/argparse.rst:1915 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" @@ -3773,7 +3777,7 @@ msgstr "" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1920 +#: ../../library/argparse.rst:1922 msgid "" "If one argument uses *FileType* and then a subsequent argument fails, an " "error is reported but the file is not automatically closed. This can also " @@ -3785,15 +3789,15 @@ msgstr "" "自動關閉。這也可能覆蓋輸出檔案。在這種情況下,最好等到剖析器執行完畢後,再使" "用 :keyword:`with` 陳述式來管理檔案。" -#: ../../library/argparse.rst:1926 +#: ../../library/argparse.rst:1928 msgid "Added the *encodings* and *errors* parameters." msgstr "新增了 *encodings* 和 *errors* 參數。" -#: ../../library/argparse.rst:1933 +#: ../../library/argparse.rst:1935 msgid "Argument groups" msgstr "引數群組" -#: ../../library/argparse.rst:1938 +#: ../../library/argparse.rst:1940 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " @@ -3805,7 +3809,7 @@ msgstr "" "引數」和「選項」兩組。當引數有比此預設分組更好的概念性分組時,可以使用 :meth:" "`!add_argument_group` 方法建立適當的群組: ::" -#: ../../library/argparse.rst:1944 +#: ../../library/argparse.rst:1946 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3829,7 +3833,7 @@ msgstr "" " bar bar help\n" " --foo FOO foo help" -#: ../../library/argparse.rst:1955 +#: ../../library/argparse.rst:1957 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" @@ -3845,7 +3849,7 @@ msgstr "" "引數。:meth:`!add_argument_group` 方法接受 *title* 和 *description* 引數,可" "以用來自訂此顯示: ::" -#: ../../library/argparse.rst:1963 +#: ../../library/argparse.rst:1965 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3883,7 +3887,7 @@ msgstr "" "\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1981 +#: ../../library/argparse.rst:1983 msgid "" "The optional, keyword-only parameters argument_default_ and " "conflict_handler_ allow for finer-grained control of the behavior of the " @@ -3895,7 +3899,7 @@ msgstr "" "的行為進行更精細的控制。這些參數的意義與 :class:`ArgumentParser` 建構函式中的" "相同,但專門適用於引數群組而非整個剖析器。" -#: ../../library/argparse.rst:1986 +#: ../../library/argparse.rst:1988 msgid "" "Note that any arguments not in your user-defined groups will end up back in " "the usual \"positional arguments\" and \"optional arguments\" sections." @@ -3903,7 +3907,7 @@ msgstr "" "請注意,任何不在使用者定義群組中的引數會歸入一般的「位置引數」和「可選引數」" "區段。" -#: ../../library/argparse.rst:1989 +#: ../../library/argparse.rst:1991 msgid "" "Calling :meth:`add_argument_group` on an argument group now raises an " "exception. This nesting was never supported, often failed to work correctly, " @@ -3912,15 +3916,15 @@ msgstr "" "在引數群組上呼叫 :meth:`add_argument_group` 現在會引發例外。這種巢狀用法從未" "被支援,通常無法正確運作,是因為繼承而無意間被公開出來的。" -#: ../../library/argparse.rst:1994 +#: ../../library/argparse.rst:1996 msgid "Passing prefix_chars_ to :meth:`add_argument_group` is now deprecated." msgstr "將 prefix_chars_ 傳給 :meth:`add_argument_group` 的用法現在已棄用。" -#: ../../library/argparse.rst:2000 +#: ../../library/argparse.rst:2002 msgid "Mutual exclusion" msgstr "互斥" -#: ../../library/argparse.rst:2004 +#: ../../library/argparse.rst:2006 msgid "" "Create a mutually exclusive group. :mod:`!argparse` will make sure that only " "one of the arguments in the mutually exclusive group was present on the " @@ -3929,7 +3933,7 @@ msgstr "" "建立一個互斥群組。:mod:`!argparse` 會確保互斥群組中只有一個引數出現在命令列" "上: ::" -#: ../../library/argparse.rst:2008 +#: ../../library/argparse.rst:2010 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -3955,7 +3959,7 @@ msgstr "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" -#: ../../library/argparse.rst:2020 +#: ../../library/argparse.rst:2022 msgid "" "The :meth:`add_mutually_exclusive_group` method also accepts a *required* " "argument, to indicate that at least one of the mutually exclusive arguments " @@ -3964,7 +3968,7 @@ msgstr "" ":meth:`add_mutually_exclusive_group` 方法也接受一個 *required* 引數,用來指示" "至少需要一個互斥引數: ::" -#: ../../library/argparse.rst:2024 +#: ../../library/argparse.rst:2026 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -3982,7 +3986,7 @@ msgstr "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:2032 +#: ../../library/argparse.rst:2034 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." @@ -3993,7 +3997,7 @@ msgstr "" "*title* 和 *description* 引數。然而互斥群組可以加入到具有標題和描述的引數群組" "中。例如: ::" -#: ../../library/argparse.rst:2038 +#: ../../library/argparse.rst:2040 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -4029,7 +4033,7 @@ msgstr "" " --foo FOO foo help\n" " --bar BAR bar help" -#: ../../library/argparse.rst:2055 +#: ../../library/argparse.rst:2057 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group now raises an exception. This nesting was " @@ -4040,11 +4044,11 @@ msgstr "" "`add_mutually_exclusive_group` 現在會引發例外。這種巢狀用法從未支援,通常無法" "正確運作,且是因為繼承而無意間被公開出來的。" -#: ../../library/argparse.rst:2063 +#: ../../library/argparse.rst:2065 msgid "Parser defaults" msgstr "剖析器預設值" -#: ../../library/argparse.rst:2067 +#: ../../library/argparse.rst:2069 msgid "" "Most of the time, the attributes of the object returned by :meth:" "`parse_args` will be fully determined by inspecting the command-line " @@ -4056,7 +4060,7 @@ msgstr "" "數 action 來決定。:meth:`set_defaults` 允許加入一些無需檢查命令列即可決定的額" "外屬性: ::" -#: ../../library/argparse.rst:2073 +#: ../../library/argparse.rst:2075 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -4070,7 +4074,7 @@ msgstr "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:2079 +#: ../../library/argparse.rst:2081 msgid "" "Note that defaults can be set at both the parser level using :meth:" "`set_defaults` and at the argument level using :meth:`add_argument`. If both " @@ -4081,7 +4085,7 @@ msgstr "" "級使用 :meth:`add_argument` 設定。如果兩者都為同一個引數呼叫,會使用最後設定" "的預設值: ::" -#: ../../library/argparse.rst:2083 +#: ../../library/argparse.rst:2085 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -4095,7 +4099,7 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" -#: ../../library/argparse.rst:2089 +#: ../../library/argparse.rst:2091 msgid "" "Parser-level defaults can be particularly useful when working with multiple " "parsers. See the :meth:`~ArgumentParser.add_subparsers` method for an " @@ -4104,7 +4108,7 @@ msgstr "" "在使用多個剖析器時,剖析器層級的預設值可能特別有用。請參閱 :meth:" "`~ArgumentParser.add_subparsers` 方法以了解這類範例。" -#: ../../library/argparse.rst:2095 +#: ../../library/argparse.rst:2097 msgid "" "Get the default value for a namespace attribute, as set by either :meth:" "`~ArgumentParser.add_argument` or by :meth:`~ArgumentParser.set_defaults`::" @@ -4112,7 +4116,7 @@ msgstr "" "取得命名空間屬性的預設值,由 :meth:`~ArgumentParser.add_argument` 或 :meth:" "`~ArgumentParser.set_defaults` 設定: ::" -#: ../../library/argparse.rst:2099 +#: ../../library/argparse.rst:2101 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" @@ -4124,11 +4128,11 @@ msgstr "" ">>> parser.get_default('foo')\n" "'badger'" -#: ../../library/argparse.rst:2106 +#: ../../library/argparse.rst:2108 msgid "Printing help" msgstr "印出幫助訊息" -#: ../../library/argparse.rst:2108 +#: ../../library/argparse.rst:2110 msgid "" "In most typical applications, :meth:`~ArgumentParser.parse_args` will take " "care of formatting and printing any usage or error messages. However, " @@ -4137,7 +4141,7 @@ msgstr "" "在大多數典型的應用程式中,:meth:`~ArgumentParser.parse_args` 會處理格式化和印" "出任何用法或錯誤訊息。然而,有幾個格式化方法可以使用:" -#: ../../library/argparse.rst:2114 +#: ../../library/argparse.rst:2116 msgid "" "Print a brief description of how the :class:`ArgumentParser` should be " "invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is " @@ -4146,7 +4150,7 @@ msgstr "" "印出 :class:`ArgumentParser` 在命令列上呼叫方式的簡短描述。如果 *file* 為 " "``None``,則假設為 :data:`sys.stdout`。" -#: ../../library/argparse.rst:2120 +#: ../../library/argparse.rst:2122 msgid "" "Print a help message, including the program usage and information about the " "arguments registered with the :class:`ArgumentParser`. If *file* is " @@ -4155,20 +4159,20 @@ msgstr "" "印出說明訊息,包括程式用法和在 :class:`ArgumentParser` 中註冊的引數相關資訊。" "如果 *file* 為 ``None``,假設為 :data:`sys.stdout`。" -#: ../../library/argparse.rst:2124 +#: ../../library/argparse.rst:2126 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "這些方法也有變體,它們只回傳字串而非印出它:" -#: ../../library/argparse.rst:2129 +#: ../../library/argparse.rst:2131 msgid "" "Return a string containing a brief description of how the :class:" "`ArgumentParser` should be invoked on the command line." msgstr "" "回傳一個字串,包含 :class:`ArgumentParser` 在命令列上的呼叫方式的簡短描述。" -#: ../../library/argparse.rst:2134 +#: ../../library/argparse.rst:2136 msgid "" "Return a string containing a help message, including the program usage and " "information about the arguments registered with the :class:`ArgumentParser`." @@ -4176,11 +4180,11 @@ msgstr "" "回傳一個字串,包含說明訊息,包括程式用法和在 :class:`ArgumentParser` 中註冊的" "引數相關資訊。" -#: ../../library/argparse.rst:2139 +#: ../../library/argparse.rst:2141 msgid "Partial parsing" msgstr "部分剖析" -#: ../../library/argparse.rst:2143 +#: ../../library/argparse.rst:2145 msgid "" "Sometimes a script only needs to handle a specific set of command-line " "arguments, leaving any unrecognized arguments for another script or program. " @@ -4191,7 +4195,7 @@ msgstr "" "本或程式。在這些情況下,:meth:`~ArgumentParser.parse_known_args` 方法可能很有" "用。" -#: ../../library/argparse.rst:2148 +#: ../../library/argparse.rst:2150 msgid "" "This method works similarly to :meth:`~ArgumentParser.parse_args`, but it " "does not raise an error for extra, unrecognized arguments. Instead, it " @@ -4202,7 +4206,7 @@ msgstr "" "辨識的引數引發錯誤,而是會只剖析已知的引數並回傳一個包含填充後的命名空間和任" "何未辨識引數串列的二元素元組。" -#: ../../library/argparse.rst:2155 +#: ../../library/argparse.rst:2157 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -4216,7 +4220,7 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2162 +#: ../../library/argparse.rst:2164 msgid "" ":ref:`Prefix matching ` rules apply to :meth:" "`~ArgumentParser.parse_known_args`. The parser may consume an option even if " @@ -4227,11 +4231,11 @@ msgstr "" "parse_known_args`。即使選項只是其已知選項之一的前綴,剖析器也可能消耗它,而非" "將其留在剩餘引數串列中。" -#: ../../library/argparse.rst:2169 +#: ../../library/argparse.rst:2171 msgid "Customizing file parsing" msgstr "自訂檔案剖析" -#: ../../library/argparse.rst:2173 +#: ../../library/argparse.rst:2175 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -4242,7 +4246,7 @@ msgstr "" "*fromfile_prefix_chars* 關鍵字引數)每行讀取一個引數。可以覆寫 :meth:" "`convert_arg_line_to_args` 以進行更精細的讀取。" -#: ../../library/argparse.rst:2178 +#: ../../library/argparse.rst:2180 msgid "" "This method takes a single argument *arg_line* which is a string read from " "the argument file. It returns a list of arguments parsed from this string. " @@ -4251,7 +4255,7 @@ msgstr "" "此方法接受單個引數 *arg_line*,它是從引數檔案讀取的字串。它回傳從此字串剖析出" "的引數串列。此方法對從引數檔案讀取的每一行依序呼叫一次。" -#: ../../library/argparse.rst:2182 +#: ../../library/argparse.rst:2184 msgid "" "A useful override of this method is one that treats each space-separated " "word as an argument. The following example demonstrates how to do this::" @@ -4259,7 +4263,7 @@ msgstr "" "此方法的一個有用覆寫是將每個以空格分隔的詞作為引數。以下範例示範了如何做到這" "一點: ::" -#: ../../library/argparse.rst:2185 +#: ../../library/argparse.rst:2187 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -4269,11 +4273,11 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2191 +#: ../../library/argparse.rst:2193 msgid "Exiting methods" msgstr "退出方法" -#: ../../library/argparse.rst:2195 +#: ../../library/argparse.rst:2197 msgid "" "This method terminates the program, exiting with the specified *status* and, " "if given, it prints a *message* to :data:`sys.stderr` before that. The user " @@ -4283,7 +4287,7 @@ msgstr "" "`sys.stderr` 印出一個 *message*。使用者可以覆寫此方法來以不同方式處理這些步" "驟: ::" -#: ../../library/argparse.rst:2199 +#: ../../library/argparse.rst:2201 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -4297,7 +4301,7 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2207 +#: ../../library/argparse.rst:2209 msgid "" "This method prints a usage message, including the *message*, to :data:`sys." "stderr` and terminates the program with a status code of 2." @@ -4305,11 +4309,11 @@ msgstr "" "此方法將用法訊息(包含 *message*)印出到 :data:`sys.stderr`,並以狀態碼 2 終" "止程式。" -#: ../../library/argparse.rst:2212 +#: ../../library/argparse.rst:2214 msgid "Intermixed parsing" msgstr "交錯剖析" -#: ../../library/argparse.rst:2217 +#: ../../library/argparse.rst:2219 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -4320,7 +4324,7 @@ msgstr "" "parse_intermixed_args` 和 :meth:`~ArgumentParser." "parse_known_intermixed_args` 方法支援此剖析風格。" -#: ../../library/argparse.rst:2222 +#: ../../library/argparse.rst:2224 msgid "" "These parsers do not support all the :mod:`!argparse` features, and will " "raise exceptions if unsupported features are used. In particular, " @@ -4330,7 +4334,7 @@ msgstr "" "這些剖析器不支援所有 :mod:`!argparse` 功能,如果使用了不支援的功能會引發例" "外。特別是不支援子剖析器,以及同時包含可選引數和位置引數的互斥群組。" -#: ../../library/argparse.rst:2227 +#: ../../library/argparse.rst:2229 msgid "" "The following example shows the difference between :meth:`~ArgumentParser." "parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " @@ -4341,7 +4345,7 @@ msgstr "" "`~ArgumentParser.parse_intermixed_args` 之間的差異:前者回傳 ``['2', '3']`` " "作為未剖析的引數,而後者將所有位置引數收集到 ``rest`` 中。 ::" -#: ../../library/argparse.rst:2233 +#: ../../library/argparse.rst:2235 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -4361,7 +4365,7 @@ msgstr "" ">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n" "Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])" -#: ../../library/argparse.rst:2242 +#: ../../library/argparse.rst:2244 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -4372,11 +4376,11 @@ msgstr "" "填充後的命名空間和剩餘引數字串的串列。:meth:`~ArgumentParser." "parse_intermixed_args` 在有任何剩餘未剖析的引數字串時會引發錯誤。" -#: ../../library/argparse.rst:2251 +#: ../../library/argparse.rst:2253 msgid "Registering custom types or actions" msgstr "註冊自訂型別或 action" -#: ../../library/argparse.rst:2255 +#: ../../library/argparse.rst:2257 msgid "" "Sometimes it's desirable to use a custom string in error messages to provide " "more user-friendly output. In these cases, :meth:`!register` can be used to " @@ -4387,7 +4391,7 @@ msgstr "" "用 :meth:`!register` 向剖析器註冊自訂 action 或型別,讓你可以透過註冊名稱而非" "可呼叫物件名稱來參照型別。" -#: ../../library/argparse.rst:2260 +#: ../../library/argparse.rst:2262 msgid "" "The :meth:`!register` method accepts three arguments - a *registry_name*, " "specifying the internal registry where the object will be stored (e.g., " @@ -4398,12 +4402,12 @@ msgstr "" "錄檔(例如 ``action``、``type``);*value*,用於註冊物件的鍵值;以及 object," "要註冊的可呼叫物件。" -#: ../../library/argparse.rst:2265 +#: ../../library/argparse.rst:2267 msgid "" "The following example shows how to register a custom type with a parser::" msgstr "以下範例展示如何向剖析器註冊自訂型別: ::" -#: ../../library/argparse.rst:2267 +#: ../../library/argparse.rst:2269 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -4431,42 +4435,42 @@ msgstr "" "usage: PROG [-h] [--foo FOO]\n" "PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" -#: ../../library/argparse.rst:2279 +#: ../../library/argparse.rst:2281 msgid "Exceptions" msgstr "例外" -#: ../../library/argparse.rst:2283 +#: ../../library/argparse.rst:2285 msgid "An error from creating or using an argument (optional or positional)." msgstr "建立或使用引數(可選或位置引數)時的錯誤。" -#: ../../library/argparse.rst:2285 +#: ../../library/argparse.rst:2287 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "此例外的字串值是訊息,附帶了導致錯誤的引數的相關資訊。" -#: ../../library/argparse.rst:2290 +#: ../../library/argparse.rst:2292 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "當將命令列字串轉換為型別時出錯時引發。" -#: ../../library/argparse.rst:2294 +#: ../../library/argparse.rst:2296 msgid "Guides and Tutorials" msgstr "指南與教學" -#: ../../library/argparse.rst:906 +#: ../../library/argparse.rst:908 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/argparse.rst:906 ../../library/argparse.rst:938 -#: ../../library/argparse.rst:952 +#: ../../library/argparse.rst:908 ../../library/argparse.rst:940 +#: ../../library/argparse.rst:954 msgid "in argparse module" msgstr "於 argparse 模組中" -#: ../../library/argparse.rst:938 +#: ../../library/argparse.rst:940 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/argparse.rst:952 +#: ../../library/argparse.rst:954 msgid "+ (plus)" msgstr "+ (加號)" diff --git a/library/stdtypes.po b/library/stdtypes.po index 1b5145c9cda..20057c4b4cb 100644 --- a/library/stdtypes.po +++ b/library/stdtypes.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-12 00:16+0000\n" +"POT-Creation-Date: 2026-03-16 00:22+0000\n" "PO-Revision-Date: 2022-06-12 15:22+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -140,7 +140,7 @@ msgstr "結果" #: ../../library/stdtypes.rst:88 ../../library/stdtypes.rst:292 #: ../../library/stdtypes.rst:432 ../../library/stdtypes.rst:1015 #: ../../library/stdtypes.rst:1237 ../../library/stdtypes.rst:3147 -#: ../../library/stdtypes.rst:4411 +#: ../../library/stdtypes.rst:4416 msgid "Notes" msgstr "註解" @@ -154,7 +154,7 @@ msgstr "假如 *x* 為真,則 *x*,否則 *y*" #: ../../library/stdtypes.rst:90 ../../library/stdtypes.rst:1017 #: ../../library/stdtypes.rst:1020 ../../library/stdtypes.rst:1252 -#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4417 +#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4422 msgid "\\(1)" msgstr "\\(1)" @@ -169,7 +169,7 @@ msgstr "假如 *x* 為假,則 *x*,否則 *y*" #: ../../library/stdtypes.rst:93 ../../library/stdtypes.rst:305 #: ../../library/stdtypes.rst:325 ../../library/stdtypes.rst:1263 #: ../../library/stdtypes.rst:3157 ../../library/stdtypes.rst:3159 -#: ../../library/stdtypes.rst:4421 ../../library/stdtypes.rst:4423 +#: ../../library/stdtypes.rst:4426 ../../library/stdtypes.rst:4428 msgid "\\(2)" msgstr "\\(2)" @@ -183,16 +183,16 @@ msgstr "假如 *x* 為假,則 ``True``,否則 ``False``" #: ../../library/stdtypes.rst:96 ../../library/stdtypes.rst:3161 #: ../../library/stdtypes.rst:3163 ../../library/stdtypes.rst:3165 -#: ../../library/stdtypes.rst:3167 ../../library/stdtypes.rst:4425 -#: ../../library/stdtypes.rst:4427 ../../library/stdtypes.rst:4429 -#: ../../library/stdtypes.rst:4431 +#: ../../library/stdtypes.rst:3167 ../../library/stdtypes.rst:4430 +#: ../../library/stdtypes.rst:4432 ../../library/stdtypes.rst:4434 +#: ../../library/stdtypes.rst:4436 msgid "\\(3)" msgstr "\\(3)" #: ../../library/stdtypes.rst:105 ../../library/stdtypes.rst:336 #: ../../library/stdtypes.rst:450 ../../library/stdtypes.rst:1059 #: ../../library/stdtypes.rst:1267 ../../library/stdtypes.rst:3197 -#: ../../library/stdtypes.rst:4461 +#: ../../library/stdtypes.rst:4466 msgid "Notes:" msgstr "註解:" @@ -240,8 +240,8 @@ msgid "This table summarizes the comparison operations:" msgstr "這個表格統整所有比較運算:" #: ../../library/stdtypes.rst:146 ../../library/stdtypes.rst:3124 -#: ../../library/stdtypes.rst:3147 ../../library/stdtypes.rst:4388 -#: ../../library/stdtypes.rst:4411 +#: ../../library/stdtypes.rst:3147 ../../library/stdtypes.rst:4393 +#: ../../library/stdtypes.rst:4416 msgid "Meaning" msgstr "含義" @@ -592,7 +592,7 @@ msgid "" msgstr "一個複數,其實部為 *re*,虛部為 *im*。*im* 預設為零。" #: ../../library/stdtypes.rst:318 ../../library/stdtypes.rst:3155 -#: ../../library/stdtypes.rst:4448 +#: ../../library/stdtypes.rst:4453 msgid "\\(6)" msgstr "\\(6)" @@ -630,8 +630,8 @@ msgstr "*x* 的 *y* 次方" #: ../../library/stdtypes.rst:327 ../../library/stdtypes.rst:329 #: ../../library/stdtypes.rst:3180 ../../library/stdtypes.rst:3183 -#: ../../library/stdtypes.rst:3186 ../../library/stdtypes.rst:4444 -#: ../../library/stdtypes.rst:4451 +#: ../../library/stdtypes.rst:3186 ../../library/stdtypes.rst:4449 +#: ../../library/stdtypes.rst:4456 msgid "\\(5)" msgstr "\\(5)" @@ -790,8 +790,8 @@ msgstr "*x* 及 *y* 的位元 :dfn:`或`" #: ../../library/stdtypes.rst:434 ../../library/stdtypes.rst:437 #: ../../library/stdtypes.rst:440 ../../library/stdtypes.rst:3169 -#: ../../library/stdtypes.rst:3173 ../../library/stdtypes.rst:4433 -#: ../../library/stdtypes.rst:4437 +#: ../../library/stdtypes.rst:3173 ../../library/stdtypes.rst:4438 +#: ../../library/stdtypes.rst:4442 msgid "\\(4)" msgstr "\\(4)" @@ -2098,10 +2098,11 @@ msgid "Mutable sequence types also support the following methods:" msgstr "可變序列型別也支援以下方法:" #: ../../library/stdtypes.rst:1289 +#, fuzzy msgid "" -"Append *value* to the end of the sequence This is equivalent to writing " +"Append *value* to the end of the sequence. This is equivalent to writing " "``seq[len(seq):len(seq)] = [value]``." -msgstr "" +msgstr "移除 *sequence* 中的所有項目,這和 ``del sequence[:]`` 相同。" #: ../../library/stdtypes.rst:1301 msgid "" @@ -3141,7 +3142,7 @@ msgstr "" msgid "Return the string encoded to :class:`bytes`." msgstr "" -#: ../../library/stdtypes.rst:1917 ../../library/stdtypes.rst:3587 +#: ../../library/stdtypes.rst:1917 ../../library/stdtypes.rst:3592 msgid "" "*encoding* defaults to ``'utf-8'``; see :ref:`standard-encodings` for " "possible values." @@ -3177,11 +3178,11 @@ msgstr "" ">>> encoded_str_to_bytes\n" "b'Python'" -#: ../../library/stdtypes.rst:1940 ../../library/stdtypes.rst:3606 +#: ../../library/stdtypes.rst:1940 ../../library/stdtypes.rst:3611 msgid "Added support for keyword arguments." msgstr "新增關鍵字引數的支援。" -#: ../../library/stdtypes.rst:1943 ../../library/stdtypes.rst:3609 +#: ../../library/stdtypes.rst:1943 ../../library/stdtypes.rst:3614 msgid "" "The value of the *errors* argument is now checked in :ref:`devmode` and in :" "ref:`debug mode `." @@ -4087,13 +4088,13 @@ msgstr "" #: ../../library/stdtypes.rst:2609 ../../library/stdtypes.rst:2627 #: ../../library/stdtypes.rst:2639 ../../library/stdtypes.rst:2693 #: ../../library/stdtypes.rst:2783 ../../library/stdtypes.rst:2952 -#: ../../library/stdtypes.rst:3922 ../../library/stdtypes.rst:3940 -#: ../../library/stdtypes.rst:4030 ../../library/stdtypes.rst:4046 -#: ../../library/stdtypes.rst:4071 ../../library/stdtypes.rst:4085 -#: ../../library/stdtypes.rst:4113 ../../library/stdtypes.rst:4127 -#: ../../library/stdtypes.rst:4145 ../../library/stdtypes.rst:4172 -#: ../../library/stdtypes.rst:4195 ../../library/stdtypes.rst:4222 -#: ../../library/stdtypes.rst:4264 ../../library/stdtypes.rst:4288 +#: ../../library/stdtypes.rst:3927 ../../library/stdtypes.rst:3945 +#: ../../library/stdtypes.rst:4035 ../../library/stdtypes.rst:4051 +#: ../../library/stdtypes.rst:4076 ../../library/stdtypes.rst:4090 +#: ../../library/stdtypes.rst:4118 ../../library/stdtypes.rst:4132 +#: ../../library/stdtypes.rst:4150 ../../library/stdtypes.rst:4177 +#: ../../library/stdtypes.rst:4200 ../../library/stdtypes.rst:4227 +#: ../../library/stdtypes.rst:4269 ../../library/stdtypes.rst:4293 msgid "For example::" msgstr "舉例來說: ::" @@ -4421,7 +4422,7 @@ msgstr "" ">>> 'Hello world'.title()\n" "'Hello World'" -#: ../../library/stdtypes.rst:2788 ../../library/stdtypes.rst:4232 +#: ../../library/stdtypes.rst:2788 ../../library/stdtypes.rst:4237 msgid "" "The algorithm uses a simple language-independent definition of a word as " "groups of consecutive letters. The definition works in many contexts but it " @@ -4837,36 +4838,36 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:3079 ../../library/stdtypes.rst:4343 +#: ../../library/stdtypes.rst:3079 ../../library/stdtypes.rst:4348 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: ../../library/stdtypes.rst:3082 ../../library/stdtypes.rst:4346 +#: ../../library/stdtypes.rst:3082 ../../library/stdtypes.rst:4351 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../library/stdtypes.rst:3084 ../../library/stdtypes.rst:4348 +#: ../../library/stdtypes.rst:3084 ../../library/stdtypes.rst:4353 msgid "" "Mapping key (optional), consisting of a parenthesised sequence of characters " "(for example, ``(somename)``)." msgstr "" -#: ../../library/stdtypes.rst:3087 ../../library/stdtypes.rst:4351 +#: ../../library/stdtypes.rst:3087 ../../library/stdtypes.rst:4356 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../library/stdtypes.rst:3090 ../../library/stdtypes.rst:4354 +#: ../../library/stdtypes.rst:3090 ../../library/stdtypes.rst:4359 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is read from the next element of the tuple in *values*, and the " "object to convert comes after the minimum field width and optional precision." msgstr "" -#: ../../library/stdtypes.rst:3094 ../../library/stdtypes.rst:4358 +#: ../../library/stdtypes.rst:3094 ../../library/stdtypes.rst:4363 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. " "If specified as ``'*'`` (an asterisk), the actual precision is read from the " @@ -4874,11 +4875,11 @@ msgid "" "the precision." msgstr "" -#: ../../library/stdtypes.rst:3099 ../../library/stdtypes.rst:4363 +#: ../../library/stdtypes.rst:3099 ../../library/stdtypes.rst:4368 msgid "Length modifier (optional)." msgstr "" -#: ../../library/stdtypes.rst:3101 ../../library/stdtypes.rst:4365 +#: ../../library/stdtypes.rst:3101 ../../library/stdtypes.rst:4370 msgid "Conversion type." msgstr "" @@ -4890,176 +4891,176 @@ msgid "" "selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:3112 ../../library/stdtypes.rst:4376 +#: ../../library/stdtypes.rst:3112 ../../library/stdtypes.rst:4381 msgid "" "In this case no ``*`` specifiers may occur in a format (since they require a " "sequential parameter list)." msgstr "" -#: ../../library/stdtypes.rst:3115 ../../library/stdtypes.rst:4379 +#: ../../library/stdtypes.rst:3115 ../../library/stdtypes.rst:4384 msgid "The conversion flag characters are:" msgstr "" -#: ../../library/stdtypes.rst:3124 ../../library/stdtypes.rst:4388 +#: ../../library/stdtypes.rst:3124 ../../library/stdtypes.rst:4393 msgid "Flag" msgstr "" -#: ../../library/stdtypes.rst:3126 ../../library/stdtypes.rst:4390 +#: ../../library/stdtypes.rst:3126 ../../library/stdtypes.rst:4395 msgid "``'#'``" msgstr "``'#'``" -#: ../../library/stdtypes.rst:3126 ../../library/stdtypes.rst:4390 +#: ../../library/stdtypes.rst:3126 ../../library/stdtypes.rst:4395 msgid "" "The value conversion will use the \"alternate form\" (where defined below)." msgstr "" -#: ../../library/stdtypes.rst:3129 ../../library/stdtypes.rst:4393 +#: ../../library/stdtypes.rst:3129 ../../library/stdtypes.rst:4398 msgid "``'0'``" msgstr "``'0'``" -#: ../../library/stdtypes.rst:3129 ../../library/stdtypes.rst:4393 +#: ../../library/stdtypes.rst:3129 ../../library/stdtypes.rst:4398 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../library/stdtypes.rst:3131 ../../library/stdtypes.rst:4395 +#: ../../library/stdtypes.rst:3131 ../../library/stdtypes.rst:4400 msgid "``'-'``" msgstr "``'-'``" -#: ../../library/stdtypes.rst:3131 ../../library/stdtypes.rst:4395 +#: ../../library/stdtypes.rst:3131 ../../library/stdtypes.rst:4400 msgid "" "The converted value is left adjusted (overrides the ``'0'`` conversion if " "both are given)." msgstr "" -#: ../../library/stdtypes.rst:3134 ../../library/stdtypes.rst:4398 +#: ../../library/stdtypes.rst:3134 ../../library/stdtypes.rst:4403 msgid "``' '``" msgstr "``' '``" -#: ../../library/stdtypes.rst:3134 ../../library/stdtypes.rst:4398 +#: ../../library/stdtypes.rst:3134 ../../library/stdtypes.rst:4403 msgid "" "(a space) A blank should be left before a positive number (or empty string) " "produced by a signed conversion." msgstr "" -#: ../../library/stdtypes.rst:3137 ../../library/stdtypes.rst:4401 +#: ../../library/stdtypes.rst:3137 ../../library/stdtypes.rst:4406 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/stdtypes.rst:3137 ../../library/stdtypes.rst:4401 +#: ../../library/stdtypes.rst:3137 ../../library/stdtypes.rst:4406 msgid "" "A sign character (``'+'`` or ``'-'``) will precede the conversion (overrides " "a \"space\" flag)." msgstr "" -#: ../../library/stdtypes.rst:3141 ../../library/stdtypes.rst:4405 +#: ../../library/stdtypes.rst:3141 ../../library/stdtypes.rst:4410 msgid "" "A length modifier (``h``, ``l``, or ``L``) may be present, but is ignored as " "it is not necessary for Python -- so e.g. ``%ld`` is identical to ``%d``." msgstr "" -#: ../../library/stdtypes.rst:3144 ../../library/stdtypes.rst:4408 +#: ../../library/stdtypes.rst:3144 ../../library/stdtypes.rst:4413 msgid "The conversion types are:" msgstr "" -#: ../../library/stdtypes.rst:3147 ../../library/stdtypes.rst:4411 +#: ../../library/stdtypes.rst:3147 ../../library/stdtypes.rst:4416 msgid "Conversion" msgstr "" -#: ../../library/stdtypes.rst:3149 ../../library/stdtypes.rst:4413 +#: ../../library/stdtypes.rst:3149 ../../library/stdtypes.rst:4418 msgid "``'d'``" msgstr "``'d'``" #: ../../library/stdtypes.rst:3149 ../../library/stdtypes.rst:3151 -#: ../../library/stdtypes.rst:4413 ../../library/stdtypes.rst:4415 +#: ../../library/stdtypes.rst:4418 ../../library/stdtypes.rst:4420 msgid "Signed integer decimal." msgstr "" -#: ../../library/stdtypes.rst:3151 ../../library/stdtypes.rst:4415 +#: ../../library/stdtypes.rst:3151 ../../library/stdtypes.rst:4420 msgid "``'i'``" msgstr "``'i'``" -#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4417 +#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4422 msgid "``'o'``" msgstr "``'o'``" -#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4417 +#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4422 msgid "Signed octal value." msgstr "" -#: ../../library/stdtypes.rst:3155 ../../library/stdtypes.rst:4419 +#: ../../library/stdtypes.rst:3155 ../../library/stdtypes.rst:4424 msgid "``'u'``" msgstr "``'u'``" -#: ../../library/stdtypes.rst:3155 ../../library/stdtypes.rst:4419 +#: ../../library/stdtypes.rst:3155 ../../library/stdtypes.rst:4424 msgid "Obsolete type -- it is identical to ``'d'``." msgstr "" -#: ../../library/stdtypes.rst:3157 ../../library/stdtypes.rst:4421 +#: ../../library/stdtypes.rst:3157 ../../library/stdtypes.rst:4426 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/stdtypes.rst:3157 ../../library/stdtypes.rst:4421 +#: ../../library/stdtypes.rst:3157 ../../library/stdtypes.rst:4426 msgid "Signed hexadecimal (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:3159 ../../library/stdtypes.rst:4423 +#: ../../library/stdtypes.rst:3159 ../../library/stdtypes.rst:4428 msgid "``'X'``" msgstr "``'X'``" -#: ../../library/stdtypes.rst:3159 ../../library/stdtypes.rst:4423 +#: ../../library/stdtypes.rst:3159 ../../library/stdtypes.rst:4428 msgid "Signed hexadecimal (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:3161 ../../library/stdtypes.rst:4425 +#: ../../library/stdtypes.rst:3161 ../../library/stdtypes.rst:4430 msgid "``'e'``" msgstr "``'e'``" -#: ../../library/stdtypes.rst:3161 ../../library/stdtypes.rst:4425 +#: ../../library/stdtypes.rst:3161 ../../library/stdtypes.rst:4430 msgid "Floating-point exponential format (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:3163 ../../library/stdtypes.rst:4427 +#: ../../library/stdtypes.rst:3163 ../../library/stdtypes.rst:4432 msgid "``'E'``" msgstr "``'E'``" -#: ../../library/stdtypes.rst:3163 ../../library/stdtypes.rst:4427 +#: ../../library/stdtypes.rst:3163 ../../library/stdtypes.rst:4432 msgid "Floating-point exponential format (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:3165 ../../library/stdtypes.rst:4429 +#: ../../library/stdtypes.rst:3165 ../../library/stdtypes.rst:4434 msgid "``'f'``" msgstr "``'f'``" #: ../../library/stdtypes.rst:3165 ../../library/stdtypes.rst:3167 -#: ../../library/stdtypes.rst:4429 ../../library/stdtypes.rst:4431 +#: ../../library/stdtypes.rst:4434 ../../library/stdtypes.rst:4436 msgid "Floating-point decimal format." msgstr "" -#: ../../library/stdtypes.rst:3167 ../../library/stdtypes.rst:4431 +#: ../../library/stdtypes.rst:3167 ../../library/stdtypes.rst:4436 msgid "``'F'``" msgstr "``'F'``" -#: ../../library/stdtypes.rst:3169 ../../library/stdtypes.rst:4433 +#: ../../library/stdtypes.rst:3169 ../../library/stdtypes.rst:4438 msgid "``'g'``" msgstr "``'g'``" -#: ../../library/stdtypes.rst:3169 ../../library/stdtypes.rst:4433 +#: ../../library/stdtypes.rst:3169 ../../library/stdtypes.rst:4438 msgid "" "Floating-point format. Uses lowercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:3173 ../../library/stdtypes.rst:4437 +#: ../../library/stdtypes.rst:3173 ../../library/stdtypes.rst:4442 msgid "``'G'``" msgstr "``'G'``" -#: ../../library/stdtypes.rst:3173 ../../library/stdtypes.rst:4437 +#: ../../library/stdtypes.rst:3173 ../../library/stdtypes.rst:4442 msgid "" "Floating-point format. Uses uppercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:3177 ../../library/stdtypes.rst:4441 +#: ../../library/stdtypes.rst:3177 ../../library/stdtypes.rst:4446 msgid "``'c'``" msgstr "``'c'``" @@ -5067,7 +5068,7 @@ msgstr "``'c'``" msgid "Single character (accepts integer or single character string)." msgstr "" -#: ../../library/stdtypes.rst:3180 ../../library/stdtypes.rst:4454 +#: ../../library/stdtypes.rst:3180 ../../library/stdtypes.rst:4459 msgid "``'r'``" msgstr "``'r'``" @@ -5075,7 +5076,7 @@ msgstr "``'r'``" msgid "String (converts any Python object using :func:`repr`)." msgstr "" -#: ../../library/stdtypes.rst:3183 ../../library/stdtypes.rst:4448 +#: ../../library/stdtypes.rst:3183 ../../library/stdtypes.rst:4453 msgid "``'s'``" msgstr "``'s'``" @@ -5083,7 +5084,7 @@ msgstr "``'s'``" msgid "String (converts any Python object using :func:`str`)." msgstr "" -#: ../../library/stdtypes.rst:3186 ../../library/stdtypes.rst:4451 +#: ../../library/stdtypes.rst:3186 ../../library/stdtypes.rst:4456 msgid "``'a'``" msgstr "``'a'``" @@ -5091,11 +5092,11 @@ msgstr "``'a'``" msgid "String (converts any Python object using :func:`ascii`)." msgstr "" -#: ../../library/stdtypes.rst:3189 ../../library/stdtypes.rst:4457 +#: ../../library/stdtypes.rst:3189 ../../library/stdtypes.rst:4462 msgid "``'%'``" msgstr "``'%'``" -#: ../../library/stdtypes.rst:3189 ../../library/stdtypes.rst:4457 +#: ../../library/stdtypes.rst:3189 ../../library/stdtypes.rst:4462 msgid "No argument is converted, results in a ``'%'`` character in the result." msgstr "" @@ -5106,48 +5107,48 @@ msgid "" "matches that of the :func:`round` builtin." msgstr "" -#: ../../library/stdtypes.rst:3200 ../../library/stdtypes.rst:4464 +#: ../../library/stdtypes.rst:3200 ../../library/stdtypes.rst:4469 msgid "" "The alternate form causes a leading octal specifier (``'0o'``) to be " "inserted before the first digit." msgstr "" -#: ../../library/stdtypes.rst:3204 ../../library/stdtypes.rst:4468 +#: ../../library/stdtypes.rst:3204 ../../library/stdtypes.rst:4473 msgid "" "The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on " "whether the ``'x'`` or ``'X'`` format was used) to be inserted before the " "first digit." msgstr "" -#: ../../library/stdtypes.rst:3208 ../../library/stdtypes.rst:4472 +#: ../../library/stdtypes.rst:3208 ../../library/stdtypes.rst:4477 msgid "" "The alternate form causes the result to always contain a decimal point, even " "if no digits follow it." msgstr "" -#: ../../library/stdtypes.rst:3211 ../../library/stdtypes.rst:4475 +#: ../../library/stdtypes.rst:3211 ../../library/stdtypes.rst:4480 msgid "" "The precision determines the number of digits after the decimal point and " "defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:3215 ../../library/stdtypes.rst:4479 +#: ../../library/stdtypes.rst:3215 ../../library/stdtypes.rst:4484 msgid "" "The alternate form causes the result to always contain a decimal point, and " "trailing zeroes are not removed as they would otherwise be." msgstr "" -#: ../../library/stdtypes.rst:3218 ../../library/stdtypes.rst:4482 +#: ../../library/stdtypes.rst:3218 ../../library/stdtypes.rst:4487 msgid "" "The precision determines the number of significant digits before and after " "the decimal point and defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:3222 ../../library/stdtypes.rst:4486 +#: ../../library/stdtypes.rst:3222 ../../library/stdtypes.rst:4491 msgid "If precision is ``N``, the output is truncated to ``N`` characters." msgstr "" -#: ../../library/stdtypes.rst:3225 ../../library/stdtypes.rst:4495 +#: ../../library/stdtypes.rst:3225 ../../library/stdtypes.rst:4500 msgid "See :pep:`237`." msgstr "參閱 :pep:`237`。" @@ -5457,11 +5458,17 @@ msgid "" "a list of integers using ``list(b)``." msgstr "" -#: ../../library/stdtypes.rst:3485 +#: ../../library/stdtypes.rst:3483 +msgid "" +"For detailed information on thread-safety guarantees for :class:`bytearray` " +"objects, see :ref:`thread-safety-bytearray`." +msgstr "" + +#: ../../library/stdtypes.rst:3490 msgid "Bytes and Bytearray Operations" msgstr "Bytes 和 Bytearray 的操作" -#: ../../library/stdtypes.rst:3490 +#: ../../library/stdtypes.rst:3495 msgid "" "Both bytes and bytearray objects support the :ref:`common ` " "sequence operations. They interoperate not just with operands of the same " @@ -5470,14 +5477,14 @@ msgid "" "return type of the result may depend on the order of operands." msgstr "" -#: ../../library/stdtypes.rst:3498 +#: ../../library/stdtypes.rst:3503 msgid "" "The methods on bytes and bytearray objects don't accept strings as their " "arguments, just as the methods on strings don't accept bytes as their " "arguments. For example, you have to write::" msgstr "" -#: ../../library/stdtypes.rst:3502 +#: ../../library/stdtypes.rst:3507 msgid "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" @@ -5485,11 +5492,11 @@ msgstr "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" -#: ../../library/stdtypes.rst:3505 +#: ../../library/stdtypes.rst:3510 msgid "and::" msgstr "和: ::" -#: ../../library/stdtypes.rst:3507 +#: ../../library/stdtypes.rst:3512 msgid "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" @@ -5497,60 +5504,60 @@ msgstr "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" -#: ../../library/stdtypes.rst:3510 +#: ../../library/stdtypes.rst:3515 msgid "" "Some bytes and bytearray operations assume the use of ASCII compatible " "binary formats, and hence should be avoided when working with arbitrary " "binary data. These restrictions are covered below." msgstr "" -#: ../../library/stdtypes.rst:3515 +#: ../../library/stdtypes.rst:3520 msgid "" "Using these ASCII based operations to manipulate binary data that is not " "stored in an ASCII based format may lead to data corruption." msgstr "" -#: ../../library/stdtypes.rst:3518 +#: ../../library/stdtypes.rst:3523 msgid "" "The following methods on bytes and bytearray objects can be used with " "arbitrary binary data." msgstr "" -#: ../../library/stdtypes.rst:3524 +#: ../../library/stdtypes.rst:3529 msgid "" "Return the number of non-overlapping occurrences of subsequence *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../library/stdtypes.rst:3528 ../../library/stdtypes.rst:3633 -#: ../../library/stdtypes.rst:3655 ../../library/stdtypes.rst:3721 -#: ../../library/stdtypes.rst:3734 +#: ../../library/stdtypes.rst:3533 ../../library/stdtypes.rst:3638 +#: ../../library/stdtypes.rst:3660 ../../library/stdtypes.rst:3726 +#: ../../library/stdtypes.rst:3739 msgid "" "The subsequence to search for may be any :term:`bytes-like object` or an " "integer in the range 0 to 255." msgstr "" -#: ../../library/stdtypes.rst:3531 +#: ../../library/stdtypes.rst:3536 msgid "" "If *sub* is empty, returns the number of empty slices between characters " "which is the length of the bytes object plus one." msgstr "" -#: ../../library/stdtypes.rst:3534 ../../library/stdtypes.rst:3645 -#: ../../library/stdtypes.rst:3658 ../../library/stdtypes.rst:3724 -#: ../../library/stdtypes.rst:3737 +#: ../../library/stdtypes.rst:3539 ../../library/stdtypes.rst:3650 +#: ../../library/stdtypes.rst:3663 ../../library/stdtypes.rst:3729 +#: ../../library/stdtypes.rst:3742 msgid "Also accept an integer in the range 0 to 255 as the subsequence." msgstr "" -#: ../../library/stdtypes.rst:3541 +#: ../../library/stdtypes.rst:3546 msgid "" "If the binary data starts with the *prefix* string, return " "``bytes[len(prefix):]``. Otherwise, return a copy of the original binary " "data::" msgstr "" -#: ../../library/stdtypes.rst:3545 +#: ../../library/stdtypes.rst:3550 msgid "" ">>> b'TestHook'.removeprefix(b'Test')\n" "b'Hook'\n" @@ -5562,32 +5569,32 @@ msgstr "" ">>> b'BaseTestCase'.removeprefix(b'Test')\n" "b'BaseTestCase'" -#: ../../library/stdtypes.rst:3550 +#: ../../library/stdtypes.rst:3555 msgid "The *prefix* may be any :term:`bytes-like object`." msgstr "*prefix* 可以是任何的 :term:`bytes-like object`。" -#: ../../library/stdtypes.rst:3554 ../../library/stdtypes.rst:3576 -#: ../../library/stdtypes.rst:3709 ../../library/stdtypes.rst:3802 -#: ../../library/stdtypes.rst:3816 ../../library/stdtypes.rst:3846 -#: ../../library/stdtypes.rst:3860 ../../library/stdtypes.rst:3901 -#: ../../library/stdtypes.rst:3971 ../../library/stdtypes.rst:3989 -#: ../../library/stdtypes.rst:4017 ../../library/stdtypes.rst:4156 -#: ../../library/stdtypes.rst:4211 ../../library/stdtypes.rst:4254 -#: ../../library/stdtypes.rst:4275 ../../library/stdtypes.rst:4297 -#: ../../library/stdtypes.rst:4499 +#: ../../library/stdtypes.rst:3559 ../../library/stdtypes.rst:3581 +#: ../../library/stdtypes.rst:3714 ../../library/stdtypes.rst:3807 +#: ../../library/stdtypes.rst:3821 ../../library/stdtypes.rst:3851 +#: ../../library/stdtypes.rst:3865 ../../library/stdtypes.rst:3906 +#: ../../library/stdtypes.rst:3976 ../../library/stdtypes.rst:3994 +#: ../../library/stdtypes.rst:4022 ../../library/stdtypes.rst:4161 +#: ../../library/stdtypes.rst:4216 ../../library/stdtypes.rst:4259 +#: ../../library/stdtypes.rst:4280 ../../library/stdtypes.rst:4302 +#: ../../library/stdtypes.rst:4504 msgid "" "The bytearray version of this method does *not* operate in place - it always " "produces a new object, even if no changes were made." msgstr "" -#: ../../library/stdtypes.rst:3563 +#: ../../library/stdtypes.rst:3568 msgid "" "If the binary data ends with the *suffix* string and that *suffix* is not " "empty, return ``bytes[:-len(suffix)]``. Otherwise, return a copy of the " "original binary data::" msgstr "" -#: ../../library/stdtypes.rst:3567 +#: ../../library/stdtypes.rst:3572 msgid "" ">>> b'MiscTests'.removesuffix(b'Tests')\n" "b'Misc'\n" @@ -5599,15 +5606,15 @@ msgstr "" ">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" "b'TmpDirMixin'" -#: ../../library/stdtypes.rst:3572 +#: ../../library/stdtypes.rst:3577 msgid "The *suffix* may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3585 +#: ../../library/stdtypes.rst:3590 msgid "Return the bytes decoded to a :class:`str`." msgstr "" -#: ../../library/stdtypes.rst:3590 +#: ../../library/stdtypes.rst:3595 msgid "" "*errors* controls how decoding errors are handled. If ``'strict'`` (the " "default), a :exc:`UnicodeError` exception is raised. Other possible values " @@ -5615,21 +5622,21 @@ msgid "" "`codecs.register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../library/stdtypes.rst:3596 +#: ../../library/stdtypes.rst:3601 msgid "" "For performance reasons, the value of *errors* is not checked for validity " "unless a decoding error actually occurs, :ref:`devmode` is enabled or a :ref:" "`debug build ` is used." msgstr "" -#: ../../library/stdtypes.rst:3602 +#: ../../library/stdtypes.rst:3607 msgid "" "Passing the *encoding* argument to :class:`str` allows decoding any :term:" "`bytes-like object` directly, without needing to make a temporary :class:`!" "bytes` or :class:`!bytearray` object." msgstr "" -#: ../../library/stdtypes.rst:3617 +#: ../../library/stdtypes.rst:3622 msgid "" "Return ``True`` if the binary data ends with the specified *suffix*, " "otherwise return ``False``. *suffix* can also be a tuple of suffixes to " @@ -5637,11 +5644,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:3622 +#: ../../library/stdtypes.rst:3627 msgid "The suffix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3628 +#: ../../library/stdtypes.rst:3633 msgid "" "Return the lowest index in the data where the subsequence *sub* is found, " "such that *sub* is contained in the slice ``s[start:end]``. Optional " @@ -5649,14 +5656,14 @@ msgid "" "``-1`` if *sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:3638 +#: ../../library/stdtypes.rst:3643 msgid "" "The :meth:`~bytes.find` method should be used only if you need to know the " "position of *sub*. To check if *sub* is a substring or not, use the :" "keyword:`in` operator::" msgstr "" -#: ../../library/stdtypes.rst:3642 +#: ../../library/stdtypes.rst:3647 msgid "" ">>> b'Py' in b'Python'\n" "True" @@ -5664,13 +5671,13 @@ msgstr "" ">>> b'Py' in b'Python'\n" "True" -#: ../../library/stdtypes.rst:3652 +#: ../../library/stdtypes.rst:3657 msgid "" "Like :meth:`~bytes.find`, but raise :exc:`ValueError` when the subsequence " "is not found." msgstr "" -#: ../../library/stdtypes.rst:3665 +#: ../../library/stdtypes.rst:3670 msgid "" "Return a bytes or bytearray object which is the concatenation of the binary " "data sequences in *iterable*. A :exc:`TypeError` will be raised if there " @@ -5680,7 +5687,7 @@ msgid "" "method." msgstr "" -#: ../../library/stdtypes.rst:3676 +#: ../../library/stdtypes.rst:3681 msgid "" "This static method returns a translation table usable for :meth:`bytes." "translate` that will map each character in *from* into the character at the " @@ -5688,7 +5695,7 @@ msgid "" "objects ` and have the same length." msgstr "" -#: ../../library/stdtypes.rst:3687 +#: ../../library/stdtypes.rst:3692 msgid "" "Split the sequence at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -5697,24 +5704,24 @@ msgid "" "by two empty bytes or bytearray objects." msgstr "" -#: ../../library/stdtypes.rst:3694 ../../library/stdtypes.rst:3751 +#: ../../library/stdtypes.rst:3699 ../../library/stdtypes.rst:3756 msgid "The separator to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3700 +#: ../../library/stdtypes.rst:3705 msgid "" "Return a copy of the sequence with all occurrences of subsequence *old* " "replaced by *new*. If the optional argument *count* is given, only the " "first *count* occurrences are replaced." msgstr "" -#: ../../library/stdtypes.rst:3704 +#: ../../library/stdtypes.rst:3709 msgid "" "The subsequence to search for and its replacement may be any :term:`bytes-" "like object`." msgstr "" -#: ../../library/stdtypes.rst:3716 +#: ../../library/stdtypes.rst:3721 msgid "" "Return the highest index in the sequence where the subsequence *sub* is " "found, such that *sub* is contained within ``s[start:end]``. Optional " @@ -5722,13 +5729,13 @@ msgid "" "``-1`` on failure." msgstr "" -#: ../../library/stdtypes.rst:3731 +#: ../../library/stdtypes.rst:3736 msgid "" "Like :meth:`~bytes.rfind` but raises :exc:`ValueError` when the subsequence " "*sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:3744 +#: ../../library/stdtypes.rst:3749 msgid "" "Split the sequence at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -5737,7 +5744,7 @@ msgid "" "followed by a copy of the original sequence." msgstr "" -#: ../../library/stdtypes.rst:3757 +#: ../../library/stdtypes.rst:3762 msgid "" "Return ``True`` if the binary data starts with the specified *prefix*, " "otherwise return ``False``. *prefix* can also be a tuple of prefixes to " @@ -5745,11 +5752,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:3762 +#: ../../library/stdtypes.rst:3767 msgid "The prefix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3768 +#: ../../library/stdtypes.rst:3773 msgid "" "Return a copy of the bytes or bytearray object where all bytes occurring in " "the optional argument *delete* are removed, and the remaining bytes have " @@ -5757,18 +5764,18 @@ msgid "" "object of length 256." msgstr "" -#: ../../library/stdtypes.rst:3773 +#: ../../library/stdtypes.rst:3778 msgid "" "You can use the :func:`bytes.maketrans` method to create a translation table." msgstr "" -#: ../../library/stdtypes.rst:3776 +#: ../../library/stdtypes.rst:3781 msgid "" "Set the *table* argument to ``None`` for translations that only delete " "characters::" msgstr "" -#: ../../library/stdtypes.rst:3779 +#: ../../library/stdtypes.rst:3784 msgid "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" @@ -5776,11 +5783,11 @@ msgstr "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" -#: ../../library/stdtypes.rst:3782 +#: ../../library/stdtypes.rst:3787 msgid "*delete* is now supported as a keyword argument." msgstr "支援 *delete* 關鍵字引數。" -#: ../../library/stdtypes.rst:3786 +#: ../../library/stdtypes.rst:3791 msgid "" "The following methods on bytes and bytearray objects have default behaviours " "that assume the use of ASCII compatible binary formats, but can still be " @@ -5789,7 +5796,7 @@ msgid "" "instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:3795 +#: ../../library/stdtypes.rst:3800 msgid "" "Return a copy of the object centered in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5797,7 +5804,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3809 +#: ../../library/stdtypes.rst:3814 msgid "" "Return a copy of the object left justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5805,7 +5812,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3823 +#: ../../library/stdtypes.rst:3828 msgid "" "Return a copy of the sequence with specified leading bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -5814,7 +5821,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3829 +#: ../../library/stdtypes.rst:3834 msgid "" ">>> b' spacious '.lstrip()\n" "b'spacious '\n" @@ -5826,14 +5833,14 @@ msgstr "" ">>> b'www.example.com'.lstrip(b'cmowz.')\n" "b'example.com'" -#: ../../library/stdtypes.rst:3834 +#: ../../library/stdtypes.rst:3839 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removeprefix` for a method that will remove a " "single prefix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3839 +#: ../../library/stdtypes.rst:3844 msgid "" ">>> b'Arthur: three!'.lstrip(b'Arthur: ')\n" "b'ee!'\n" @@ -5845,7 +5852,7 @@ msgstr "" ">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" "b'three!'" -#: ../../library/stdtypes.rst:3853 +#: ../../library/stdtypes.rst:3858 msgid "" "Return a copy of the object right justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5853,7 +5860,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3867 +#: ../../library/stdtypes.rst:3872 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are " @@ -5863,7 +5870,7 @@ msgid "" "described in detail below." msgstr "" -#: ../../library/stdtypes.rst:3878 +#: ../../library/stdtypes.rst:3883 msgid "" "Return a copy of the sequence with specified trailing bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -5872,7 +5879,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3884 +#: ../../library/stdtypes.rst:3889 msgid "" ">>> b' spacious '.rstrip()\n" "b' spacious'\n" @@ -5884,14 +5891,14 @@ msgstr "" ">>> b'mississippi'.rstrip(b'ipz')\n" "b'mississ'" -#: ../../library/stdtypes.rst:3889 +#: ../../library/stdtypes.rst:3894 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removesuffix` for a method that will remove a " "single suffix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3894 +#: ../../library/stdtypes.rst:3899 msgid "" ">>> b'Monty Python'.rstrip(b' Python')\n" "b'M'\n" @@ -5903,7 +5910,7 @@ msgstr "" ">>> b'Monty Python'.removesuffix(b' Python')\n" "b'Monty'" -#: ../../library/stdtypes.rst:3908 +#: ../../library/stdtypes.rst:3913 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given and non-negative, at most " @@ -5912,7 +5919,7 @@ msgid "" "limit on the number of splits (all possible splits are made)." msgstr "" -#: ../../library/stdtypes.rst:3914 +#: ../../library/stdtypes.rst:3919 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty subsequences (for example, ``b'1,,2'.split(b',')`` " @@ -5923,7 +5930,7 @@ msgid "" "like object`." msgstr "" -#: ../../library/stdtypes.rst:3924 +#: ../../library/stdtypes.rst:3929 msgid "" ">>> b'1,2,3'.split(b',')\n" "[b'1', b'2', b'3']\n" @@ -5943,7 +5950,7 @@ msgstr "" ">>> b'1<>2<>3<4'.split(b'<>')\n" "[b'1', b'2', b'3<4']" -#: ../../library/stdtypes.rst:3933 +#: ../../library/stdtypes.rst:3938 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive ASCII whitespace are regarded as a single " @@ -5953,7 +5960,7 @@ msgid "" "without a specified separator returns ``[]``." msgstr "" -#: ../../library/stdtypes.rst:3943 +#: ../../library/stdtypes.rst:3948 msgid "" ">>> b'1 2 3'.split()\n" "[b'1', b'2', b'3']\n" @@ -5969,7 +5976,7 @@ msgstr "" ">>> b' 1 2 3 '.split()\n" "[b'1', b'2', b'3']" -#: ../../library/stdtypes.rst:3954 +#: ../../library/stdtypes.rst:3959 msgid "" "Return a copy of the sequence with specified leading and trailing bytes " "removed. The *bytes* argument is a binary sequence specifying the set of " @@ -5978,7 +5985,7 @@ msgid "" "or suffix; rather, all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3961 +#: ../../library/stdtypes.rst:3966 msgid "" ">>> b' spacious '.strip()\n" "b'spacious'\n" @@ -5990,13 +5997,13 @@ msgstr "" ">>> b'www.example.com'.strip(b'cmowz.')\n" "b'example'" -#: ../../library/stdtypes.rst:3966 +#: ../../library/stdtypes.rst:3971 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`." msgstr "" -#: ../../library/stdtypes.rst:3975 +#: ../../library/stdtypes.rst:3980 msgid "" "The following methods on bytes and bytearray objects assume the use of ASCII " "compatible binary formats and should not be applied to arbitrary binary " @@ -6004,14 +6011,14 @@ msgid "" "operate in place, and instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:3983 +#: ../../library/stdtypes.rst:3988 msgid "" "Return a copy of the sequence with each byte interpreted as an ASCII " "character, and the first byte capitalized and the rest lowercased. Non-ASCII " "byte values are passed through unchanged." msgstr "" -#: ../../library/stdtypes.rst:3996 +#: ../../library/stdtypes.rst:4001 msgid "" "Return a copy of the sequence where all ASCII tab characters are replaced by " "one or more ASCII spaces, depending on the current column and the given tab " @@ -6027,7 +6034,7 @@ msgid "" "by one regardless of how the byte value is represented when printed::" msgstr "" -#: ../../library/stdtypes.rst:4010 +#: ../../library/stdtypes.rst:4015 msgid "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" "b'01 012 0123 01234'\n" @@ -6039,7 +6046,7 @@ msgstr "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" "b'01 012 0123 01234'" -#: ../../library/stdtypes.rst:4024 +#: ../../library/stdtypes.rst:4029 msgid "" "Return ``True`` if all bytes in the sequence are alphabetical ASCII " "characters or ASCII decimal digits and the sequence is not empty, ``False`` " @@ -6048,7 +6055,7 @@ msgid "" "digits are those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:4032 +#: ../../library/stdtypes.rst:4037 msgid "" ">>> b'ABCabc1'.isalnum()\n" "True\n" @@ -6060,7 +6067,7 @@ msgstr "" ">>> b'ABC abc1'.isalnum()\n" "False" -#: ../../library/stdtypes.rst:4041 +#: ../../library/stdtypes.rst:4046 msgid "" "Return ``True`` if all bytes in the sequence are alphabetic ASCII characters " "and the sequence is not empty, ``False`` otherwise. Alphabetic ASCII " @@ -6068,7 +6075,7 @@ msgid "" "``b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:4048 +#: ../../library/stdtypes.rst:4053 msgid "" ">>> b'ABCabc'.isalpha()\n" "True\n" @@ -6080,20 +6087,20 @@ msgstr "" ">>> b'ABCabc1'.isalpha()\n" "False" -#: ../../library/stdtypes.rst:4057 +#: ../../library/stdtypes.rst:4062 msgid "" "Return ``True`` if the sequence is empty or all bytes in the sequence are " "ASCII, ``False`` otherwise. ASCII bytes are in the range 0-0x7F." msgstr "" -#: ../../library/stdtypes.rst:4067 +#: ../../library/stdtypes.rst:4072 msgid "" "Return ``True`` if all bytes in the sequence are ASCII decimal digits and " "the sequence is not empty, ``False`` otherwise. ASCII decimal digits are " "those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:4073 +#: ../../library/stdtypes.rst:4078 msgid "" ">>> b'1234'.isdigit()\n" "True\n" @@ -6105,13 +6112,13 @@ msgstr "" ">>> b'1.23'.isdigit()\n" "False" -#: ../../library/stdtypes.rst:4082 +#: ../../library/stdtypes.rst:4087 msgid "" "Return ``True`` if there is at least one lowercase ASCII character in the " "sequence and no uppercase ASCII characters, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:4087 +#: ../../library/stdtypes.rst:4092 msgid "" ">>> b'hello world'.islower()\n" "True\n" @@ -6123,16 +6130,16 @@ msgstr "" ">>> b'Hello world'.islower()\n" "False" -#: ../../library/stdtypes.rst:4092 ../../library/stdtypes.rst:4134 -#: ../../library/stdtypes.rst:4150 ../../library/stdtypes.rst:4200 -#: ../../library/stdtypes.rst:4269 +#: ../../library/stdtypes.rst:4097 ../../library/stdtypes.rst:4139 +#: ../../library/stdtypes.rst:4155 ../../library/stdtypes.rst:4205 +#: ../../library/stdtypes.rst:4274 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " "values in the sequence ``b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:4100 +#: ../../library/stdtypes.rst:4105 msgid "" "Return ``True`` if all bytes in the sequence are ASCII whitespace and the " "sequence is not empty, ``False`` otherwise. ASCII whitespace characters are " @@ -6140,14 +6147,14 @@ msgid "" "newline, carriage return, vertical tab, form feed)." msgstr "" -#: ../../library/stdtypes.rst:4109 +#: ../../library/stdtypes.rst:4114 msgid "" "Return ``True`` if the sequence is ASCII titlecase and the sequence is not " "empty, ``False`` otherwise. See :meth:`bytes.title` for more details on the " "definition of \"titlecase\"." msgstr "" -#: ../../library/stdtypes.rst:4115 +#: ../../library/stdtypes.rst:4120 msgid "" ">>> b'Hello World'.istitle()\n" "True\n" @@ -6159,14 +6166,14 @@ msgstr "" ">>> b'Hello world'.istitle()\n" "False" -#: ../../library/stdtypes.rst:4124 +#: ../../library/stdtypes.rst:4129 msgid "" "Return ``True`` if there is at least one uppercase alphabetic ASCII " "character in the sequence and no lowercase ASCII characters, ``False`` " "otherwise." msgstr "" -#: ../../library/stdtypes.rst:4129 +#: ../../library/stdtypes.rst:4134 msgid "" ">>> b'HELLO WORLD'.isupper()\n" "True\n" @@ -6178,13 +6185,13 @@ msgstr "" ">>> b'Hello world'.isupper()\n" "False" -#: ../../library/stdtypes.rst:4142 +#: ../../library/stdtypes.rst:4147 msgid "" "Return a copy of the sequence with all the uppercase ASCII characters " "converted to their corresponding lowercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:4147 +#: ../../library/stdtypes.rst:4152 msgid "" ">>> b'Hello World'.lower()\n" "b'hello world'" @@ -6192,7 +6199,7 @@ msgstr "" ">>> b'Hello World'.lower()\n" "b'hello world'" -#: ../../library/stdtypes.rst:4167 +#: ../../library/stdtypes.rst:4172 msgid "" "Return a list of the lines in the binary sequence, breaking at ASCII line " "boundaries. This method uses the :term:`universal newlines` approach to " @@ -6200,7 +6207,7 @@ msgid "" "*keepends* is given and true." msgstr "" -#: ../../library/stdtypes.rst:4174 +#: ../../library/stdtypes.rst:4179 msgid "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "[b'ab c', b'', b'de fg', b'kl']\n" @@ -6212,14 +6219,14 @@ msgstr "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" -#: ../../library/stdtypes.rst:4179 +#: ../../library/stdtypes.rst:4184 msgid "" "Unlike :meth:`~bytes.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../library/stdtypes.rst:4183 +#: ../../library/stdtypes.rst:4188 msgid "" ">>> b\"\".split(b'\\n'), b\"Two lines\\n\".split(b'\\n')\n" "([b''], [b'Two lines', b''])\n" @@ -6231,13 +6238,13 @@ msgstr "" ">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" "([], [b'One line'])" -#: ../../library/stdtypes.rst:4192 +#: ../../library/stdtypes.rst:4197 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart and vice-versa." msgstr "" -#: ../../library/stdtypes.rst:4197 +#: ../../library/stdtypes.rst:4202 msgid "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" @@ -6245,7 +6252,7 @@ msgstr "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" -#: ../../library/stdtypes.rst:4204 +#: ../../library/stdtypes.rst:4209 msgid "" "Unlike :func:`str.swapcase`, it is always the case that ``bin.swapcase()." "swapcase() == bin`` for the binary versions. Case conversions are " @@ -6253,14 +6260,14 @@ msgid "" "Unicode code points." msgstr "" -#: ../../library/stdtypes.rst:4218 +#: ../../library/stdtypes.rst:4223 msgid "" "Return a titlecased version of the binary sequence where words start with an " "uppercase ASCII character and the remaining characters are lowercase. " "Uncased byte values are left unmodified." msgstr "" -#: ../../library/stdtypes.rst:4224 +#: ../../library/stdtypes.rst:4229 msgid "" ">>> b'Hello world'.title()\n" "b'Hello World'" @@ -6268,7 +6275,7 @@ msgstr "" ">>> b'Hello world'.title()\n" "b'Hello World'" -#: ../../library/stdtypes.rst:4227 +#: ../../library/stdtypes.rst:4232 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " @@ -6276,7 +6283,7 @@ msgid "" "values are uncased." msgstr "" -#: ../../library/stdtypes.rst:4237 +#: ../../library/stdtypes.rst:4242 msgid "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" @@ -6284,12 +6291,12 @@ msgstr "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" -#: ../../library/stdtypes.rst:4240 +#: ../../library/stdtypes.rst:4245 msgid "" "A workaround for apostrophes can be constructed using regular expressions::" msgstr "" -#: ../../library/stdtypes.rst:4242 +#: ../../library/stdtypes.rst:4247 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -6311,13 +6318,13 @@ msgstr "" ">>> titlecase(b\"they're bill's friends.\")\n" "b\"They're Bill's Friends.\"" -#: ../../library/stdtypes.rst:4261 +#: ../../library/stdtypes.rst:4266 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:4266 +#: ../../library/stdtypes.rst:4271 msgid "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" @@ -6325,7 +6332,7 @@ msgstr "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" -#: ../../library/stdtypes.rst:4282 +#: ../../library/stdtypes.rst:4287 msgid "" "Return a copy of the sequence left filled with ASCII ``b'0'`` digits to make " "a sequence of length *width*. A leading sign prefix (``b'+'``/ ``b'-'``) is " @@ -6334,7 +6341,7 @@ msgid "" "*width* is less than or equal to ``len(seq)``." msgstr "" -#: ../../library/stdtypes.rst:4290 +#: ../../library/stdtypes.rst:4295 msgid "" ">>> b\"42\".zfill(5)\n" "b'00042'\n" @@ -6346,11 +6353,11 @@ msgstr "" ">>> b\"-42\".zfill(5)\n" "b'-0042'" -#: ../../library/stdtypes.rst:4304 +#: ../../library/stdtypes.rst:4309 msgid "``printf``-style Bytes Formatting" msgstr "" -#: ../../library/stdtypes.rst:4321 +#: ../../library/stdtypes.rst:4326 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " @@ -6358,7 +6365,7 @@ msgid "" "dictionary, wrap it in a tuple." msgstr "" -#: ../../library/stdtypes.rst:4326 +#: ../../library/stdtypes.rst:4331 msgid "" "Bytes objects (``bytes``/``bytearray``) have one unique built-in operation: " "the ``%`` operator (modulo). This is also known as the bytes *formatting* or " @@ -6368,7 +6375,7 @@ msgid "" "func:`sprintf` in the C language." msgstr "" -#: ../../library/stdtypes.rst:4333 +#: ../../library/stdtypes.rst:4338 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -6376,7 +6383,7 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:4367 +#: ../../library/stdtypes.rst:4372 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the bytes object *must* include a parenthesised mapping key into " @@ -6384,77 +6391,77 @@ msgid "" "mapping key selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:4419 +#: ../../library/stdtypes.rst:4424 msgid "\\(8)" msgstr "\\(8)" -#: ../../library/stdtypes.rst:4441 +#: ../../library/stdtypes.rst:4446 msgid "Single byte (accepts integer or single byte objects)." msgstr "" -#: ../../library/stdtypes.rst:4444 +#: ../../library/stdtypes.rst:4449 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/stdtypes.rst:4444 +#: ../../library/stdtypes.rst:4449 msgid "" "Bytes (any object that follows the :ref:`buffer protocol ` or " "has :meth:`~object.__bytes__`)." msgstr "" -#: ../../library/stdtypes.rst:4448 +#: ../../library/stdtypes.rst:4453 msgid "" "``'s'`` is an alias for ``'b'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:4451 +#: ../../library/stdtypes.rst:4456 msgid "" "Bytes (converts any Python object using ``repr(obj).encode('ascii', " "'backslashreplace')``)." msgstr "" -#: ../../library/stdtypes.rst:4454 +#: ../../library/stdtypes.rst:4459 msgid "" "``'r'`` is an alias for ``'a'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:4454 +#: ../../library/stdtypes.rst:4459 msgid "\\(7)" msgstr "\\(7)" -#: ../../library/stdtypes.rst:4489 +#: ../../library/stdtypes.rst:4494 msgid "``b'%s'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%s'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../library/stdtypes.rst:4492 +#: ../../library/stdtypes.rst:4497 msgid "``b'%r'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%r'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../library/stdtypes.rst:4504 +#: ../../library/stdtypes.rst:4509 msgid ":pep:`461` - Adding % formatting to bytes and bytearray" msgstr "" -#: ../../library/stdtypes.rst:4511 +#: ../../library/stdtypes.rst:4516 msgid "Memory Views" msgstr "" -#: ../../library/stdtypes.rst:4513 +#: ../../library/stdtypes.rst:4518 msgid "" ":class:`memoryview` objects allow Python code to access the internal data of " "an object that supports the :ref:`buffer protocol ` without " "copying." msgstr "" -#: ../../library/stdtypes.rst:4519 +#: ../../library/stdtypes.rst:4524 msgid "" "Create a :class:`memoryview` that references *object*. *object* must " "support the buffer protocol. Built-in objects that support the buffer " "protocol include :class:`bytes` and :class:`bytearray`." msgstr "" -#: ../../library/stdtypes.rst:4523 +#: ../../library/stdtypes.rst:4528 msgid "" "A :class:`memoryview` has the notion of an *element*, which is the atomic " "memory unit handled by the originating *object*. For many simple types such " @@ -6462,32 +6469,32 @@ msgid "" "other types such as :class:`array.array` may have bigger elements." msgstr "" -#: ../../library/stdtypes.rst:4528 +#: ../../library/stdtypes.rst:4533 msgid "" "``len(view)`` is equal to the length of :class:`~memoryview.tolist`, which " "is the nested list representation of the view. If ``view.ndim = 1``, this is " "equal to the number of elements in the view." msgstr "" -#: ../../library/stdtypes.rst:4532 +#: ../../library/stdtypes.rst:4537 msgid "" "If ``view.ndim == 0``, ``len(view)`` now raises :exc:`TypeError` instead of " "returning 1." msgstr "" -#: ../../library/stdtypes.rst:4535 +#: ../../library/stdtypes.rst:4540 msgid "" "The :class:`~memoryview.itemsize` attribute will give you the number of " "bytes in a single element." msgstr "" -#: ../../library/stdtypes.rst:4538 +#: ../../library/stdtypes.rst:4543 msgid "" "A :class:`memoryview` supports slicing and indexing to expose its data. One-" "dimensional slicing will result in a subview::" msgstr "" -#: ../../library/stdtypes.rst:4541 +#: ../../library/stdtypes.rst:4546 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> v[1]\n" @@ -6509,7 +6516,7 @@ msgstr "" ">>> bytes(v[1:4])\n" "b'bce'" -#: ../../library/stdtypes.rst:4551 +#: ../../library/stdtypes.rst:4556 msgid "" "If :class:`~memoryview.format` is one of the native format specifiers from " "the :mod:`struct` module, indexing with an integer or a tuple of integers is " @@ -6520,11 +6527,11 @@ msgid "" "memoryviews can be indexed with the empty tuple." msgstr "" -#: ../../library/stdtypes.rst:4560 +#: ../../library/stdtypes.rst:4565 msgid "Here is an example with a non-byte format::" msgstr "" -#: ../../library/stdtypes.rst:4562 +#: ../../library/stdtypes.rst:4567 msgid "" ">>> import array\n" ">>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])\n" @@ -6546,13 +6553,13 @@ msgstr "" ">>> m[::2].tolist()\n" "[-11111111, -33333333]" -#: ../../library/stdtypes.rst:4572 +#: ../../library/stdtypes.rst:4577 msgid "" "If the underlying object is writable, the memoryview supports one-" "dimensional slice assignment. Resizing is not allowed::" msgstr "" -#: ../../library/stdtypes.rst:4575 +#: ../../library/stdtypes.rst:4580 msgid "" ">>> data = bytearray(b'abcefg')\n" ">>> v = memoryview(data)\n" @@ -6592,14 +6599,14 @@ msgstr "" ">>> data\n" "bytearray(b'z1spam')" -#: ../../library/stdtypes.rst:4593 +#: ../../library/stdtypes.rst:4598 msgid "" "One-dimensional memoryviews of :term:`hashable` (read-only) types with " "formats 'B', 'b' or 'c' are also hashable. The hash is defined as ``hash(m) " "== hash(m.tobytes())``::" msgstr "" -#: ../../library/stdtypes.rst:4597 +#: ../../library/stdtypes.rst:4602 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> hash(v) == hash(b'abcefg')\n" @@ -6617,44 +6624,44 @@ msgstr "" ">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" "True" -#: ../../library/stdtypes.rst:4605 +#: ../../library/stdtypes.rst:4610 msgid "" "One-dimensional memoryviews can now be sliced. One-dimensional memoryviews " "with formats 'B', 'b' or 'c' are now :term:`hashable`." msgstr "" -#: ../../library/stdtypes.rst:4609 +#: ../../library/stdtypes.rst:4614 msgid "" "memoryview is now registered automatically with :class:`collections.abc." "Sequence`" msgstr "" -#: ../../library/stdtypes.rst:4613 +#: ../../library/stdtypes.rst:4618 msgid "memoryviews can now be indexed with tuple of integers." msgstr "" -#: ../../library/stdtypes.rst:4616 +#: ../../library/stdtypes.rst:4621 msgid "memoryview is now a :term:`generic type`." msgstr "" -#: ../../library/stdtypes.rst:4619 +#: ../../library/stdtypes.rst:4624 msgid ":class:`memoryview` has several methods:" msgstr ":class:`memoryview` 有幾個方法:" -#: ../../library/stdtypes.rst:4623 +#: ../../library/stdtypes.rst:4628 msgid "" "A memoryview and a :pep:`3118` exporter are equal if their shapes are " "equivalent and if all corresponding values are equal when the operands' " "respective format codes are interpreted using :mod:`struct` syntax." msgstr "" -#: ../../library/stdtypes.rst:4627 +#: ../../library/stdtypes.rst:4632 msgid "" "For the subset of :mod:`struct` format strings currently supported by :meth:" "`tolist`, ``v`` and ``w`` are equal if ``v.tolist() == w.tolist()``::" msgstr "" -#: ../../library/stdtypes.rst:4630 +#: ../../library/stdtypes.rst:4635 msgid "" ">>> import array\n" ">>> a = array.array('I', [1, 2, 3, 4, 5])\n" @@ -6688,14 +6695,14 @@ msgstr "" ">>> z.tolist() == c.tolist()\n" "True" -#: ../../library/stdtypes.rst:4646 +#: ../../library/stdtypes.rst:4651 msgid "" "If either format string is not supported by the :mod:`struct` module, then " "the objects will always compare as unequal (even if the format strings and " "buffer contents are identical)::" msgstr "" -#: ../../library/stdtypes.rst:4650 +#: ../../library/stdtypes.rst:4655 msgid "" ">>> from ctypes import BigEndianStructure, c_long\n" ">>> class BEPoint(BigEndianStructure):\n" @@ -6721,25 +6728,25 @@ msgstr "" ">>> a == b\n" "False" -#: ../../library/stdtypes.rst:4662 +#: ../../library/stdtypes.rst:4667 msgid "" "Note that, as with floating-point numbers, ``v is w`` does *not* imply ``v " "== w`` for memoryview objects." msgstr "" -#: ../../library/stdtypes.rst:4665 +#: ../../library/stdtypes.rst:4670 msgid "" "Previous versions compared the raw memory disregarding the item format and " "the logical array structure." msgstr "" -#: ../../library/stdtypes.rst:4671 +#: ../../library/stdtypes.rst:4676 msgid "" "Return the data in the buffer as a bytestring. This is equivalent to " "calling the :class:`bytes` constructor on the memoryview. ::" msgstr "" -#: ../../library/stdtypes.rst:4674 +#: ../../library/stdtypes.rst:4679 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.tobytes()\n" @@ -6753,7 +6760,7 @@ msgstr "" ">>> bytes(m)\n" "b'abc'" -#: ../../library/stdtypes.rst:4680 +#: ../../library/stdtypes.rst:4685 msgid "" "For non-contiguous arrays the result is equal to the flattened list " "representation with all elements converted to bytes. :meth:`tobytes` " @@ -6761,7 +6768,7 @@ msgid "" "module syntax." msgstr "" -#: ../../library/stdtypes.rst:4685 +#: ../../library/stdtypes.rst:4690 msgid "" "*order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data of the " "original array is converted to C or Fortran order. For contiguous views, 'A' " @@ -6770,13 +6777,13 @@ msgid "" "to C first. *order=None* is the same as *order='C'*." msgstr "" -#: ../../library/stdtypes.rst:4695 +#: ../../library/stdtypes.rst:4700 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the buffer. ::" msgstr "" -#: ../../library/stdtypes.rst:4698 +#: ../../library/stdtypes.rst:4703 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.hex()\n" @@ -6786,18 +6793,18 @@ msgstr "" ">>> m.hex()\n" "'616263'" -#: ../../library/stdtypes.rst:4704 +#: ../../library/stdtypes.rst:4709 msgid "" "Similar to :meth:`bytes.hex`, :meth:`memoryview.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../library/stdtypes.rst:4711 +#: ../../library/stdtypes.rst:4716 msgid "Return the data in the buffer as a list of elements. ::" msgstr "" -#: ../../library/stdtypes.rst:4713 +#: ../../library/stdtypes.rst:4718 msgid "" ">>> memoryview(b'abc').tolist()\n" "[97, 98, 99]\n" @@ -6815,19 +6822,19 @@ msgstr "" ">>> m.tolist()\n" "[1.1, 2.2, 3.3]" -#: ../../library/stdtypes.rst:4721 +#: ../../library/stdtypes.rst:4726 msgid "" ":meth:`tolist` now supports all single character native formats in :mod:" "`struct` module syntax as well as multi-dimensional representations." msgstr "" -#: ../../library/stdtypes.rst:4728 +#: ../../library/stdtypes.rst:4733 msgid "" "Return a readonly version of the memoryview object. The original memoryview " "object is unchanged. ::" msgstr "" -#: ../../library/stdtypes.rst:4731 +#: ../../library/stdtypes.rst:4736 msgid "" ">>> m = memoryview(bytearray(b'abc'))\n" ">>> mm = m.toreadonly()\n" @@ -6853,7 +6860,7 @@ msgstr "" ">>> mm.tolist()\n" "[43, 98, 99]" -#: ../../library/stdtypes.rst:4747 +#: ../../library/stdtypes.rst:4752 msgid "" "Release the underlying buffer exposed by the memoryview object. Many " "objects take special actions when a view is held on them (for example, a :" @@ -6862,14 +6869,14 @@ msgid "" "resources) as soon as possible." msgstr "" -#: ../../library/stdtypes.rst:4753 +#: ../../library/stdtypes.rst:4758 msgid "" "After this method has been called, any further operation on the view raises " "a :class:`ValueError` (except :meth:`release` itself which can be called " "multiple times)::" msgstr "" -#: ../../library/stdtypes.rst:4757 +#: ../../library/stdtypes.rst:4762 msgid "" ">>> m = memoryview(b'abc')\n" ">>> m.release()\n" @@ -6885,13 +6892,13 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../library/stdtypes.rst:4764 +#: ../../library/stdtypes.rst:4769 msgid "" "The context management protocol can be used for a similar effect, using the " "``with`` statement::" msgstr "" -#: ../../library/stdtypes.rst:4767 +#: ../../library/stdtypes.rst:4772 msgid "" ">>> with memoryview(b'abc') as m:\n" "... m[0]\n" @@ -6911,7 +6918,7 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../library/stdtypes.rst:4781 +#: ../../library/stdtypes.rst:4786 msgid "" "Cast a memoryview to a new format or shape. *shape* defaults to " "``[byte_length//new_itemsize]``, which means that the result view will be " @@ -6920,7 +6927,7 @@ msgid "" "contiguous -> 1D." msgstr "" -#: ../../library/stdtypes.rst:4787 +#: ../../library/stdtypes.rst:4792 msgid "" "The destination format is restricted to a single element native format in :" "mod:`struct` syntax. One of the formats must be a byte format ('B', 'b' or " @@ -6928,11 +6935,11 @@ msgid "" "Note that all byte lengths may depend on the operating system." msgstr "" -#: ../../library/stdtypes.rst:4793 +#: ../../library/stdtypes.rst:4798 msgid "Cast 1D/long to 1D/unsigned bytes::" msgstr "" -#: ../../library/stdtypes.rst:4795 +#: ../../library/stdtypes.rst:4800 msgid "" ">>> import array\n" ">>> a = array.array('l', [1,2,3])\n" @@ -6976,11 +6983,11 @@ msgstr "" ">>> y.nbytes\n" "24" -#: ../../library/stdtypes.rst:4816 +#: ../../library/stdtypes.rst:4821 msgid "Cast 1D/unsigned bytes to 1D/char::" msgstr "" -#: ../../library/stdtypes.rst:4818 +#: ../../library/stdtypes.rst:4823 msgid "" ">>> b = bytearray(b'zyz')\n" ">>> x = memoryview(b)\n" @@ -7004,11 +7011,11 @@ msgstr "" ">>> b\n" "bytearray(b'ayz')" -#: ../../library/stdtypes.rst:4829 +#: ../../library/stdtypes.rst:4834 msgid "Cast 1D/bytes to 3D/ints to 1D/signed char::" msgstr "" -#: ../../library/stdtypes.rst:4831 +#: ../../library/stdtypes.rst:4836 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"i\"*12, *list(range(12)))\n" @@ -7058,11 +7065,11 @@ msgstr "" ">>> z.nbytes\n" "48" -#: ../../library/stdtypes.rst:4855 +#: ../../library/stdtypes.rst:4860 msgid "Cast 1D/unsigned long to 2D/unsigned long::" msgstr "" -#: ../../library/stdtypes.rst:4857 +#: ../../library/stdtypes.rst:4862 msgid "" ">>> buf = struct.pack(\"L\"*6, *list(range(6)))\n" ">>> x = memoryview(buf)\n" @@ -7084,33 +7091,33 @@ msgstr "" ">>> y.tolist()\n" "[[0, 1, 2], [3, 4, 5]]" -#: ../../library/stdtypes.rst:4869 +#: ../../library/stdtypes.rst:4874 msgid "The source format is no longer restricted when casting to a byte view." msgstr "" -#: ../../library/stdtypes.rst:4874 +#: ../../library/stdtypes.rst:4879 msgid "Count the number of occurrences of *value*." msgstr "計算 *value* 的出現次數" -#: ../../library/stdtypes.rst:4880 +#: ../../library/stdtypes.rst:4885 msgid "" "Return the index of the first occurrence of *value* (at or after index " "*start* and before index *stop*)." msgstr "" -#: ../../library/stdtypes.rst:4883 +#: ../../library/stdtypes.rst:4888 msgid "Raises a :exc:`ValueError` if *value* cannot be found." msgstr "在找不到 *value* 時引發 :exc:`ValueError`。" -#: ../../library/stdtypes.rst:4887 +#: ../../library/stdtypes.rst:4892 msgid "There are also several readonly attributes available:" msgstr "" -#: ../../library/stdtypes.rst:4891 +#: ../../library/stdtypes.rst:4896 msgid "The underlying object of the memoryview::" msgstr "memoryview 的底層物件: ::" -#: ../../library/stdtypes.rst:4893 +#: ../../library/stdtypes.rst:4898 msgid "" ">>> b = bytearray(b'xyz')\n" ">>> m = memoryview(b)\n" @@ -7122,14 +7129,14 @@ msgstr "" ">>> m.obj is b\n" "True" -#: ../../library/stdtypes.rst:4902 +#: ../../library/stdtypes.rst:4907 msgid "" "``nbytes == product(shape) * itemsize == len(m.tobytes())``. This is the " "amount of space in bytes that the array would use in a contiguous " "representation. It is not necessarily equal to ``len(m)``::" msgstr "" -#: ../../library/stdtypes.rst:4906 +#: ../../library/stdtypes.rst:4911 msgid "" ">>> import array\n" ">>> a = array.array('i', [1,2,3,4,5])\n" @@ -7161,11 +7168,11 @@ msgstr "" ">>> len(y.tobytes())\n" "12" -#: ../../library/stdtypes.rst:4921 +#: ../../library/stdtypes.rst:4926 msgid "Multi-dimensional arrays::" msgstr "" -#: ../../library/stdtypes.rst:4923 +#: ../../library/stdtypes.rst:4928 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"d\"*12, *[1.5*x for x in range(12)])\n" @@ -7189,11 +7196,11 @@ msgstr "" ">>> y.nbytes\n" "96" -#: ../../library/stdtypes.rst:4938 +#: ../../library/stdtypes.rst:4943 msgid "A bool indicating whether the memory is read only." msgstr "" -#: ../../library/stdtypes.rst:4942 +#: ../../library/stdtypes.rst:4947 msgid "" "A string containing the format (in :mod:`struct` module style) for each " "element in the view. A memoryview can be created from exporters with " @@ -7201,17 +7208,17 @@ msgid "" "restricted to native single element formats." msgstr "" -#: ../../library/stdtypes.rst:4947 +#: ../../library/stdtypes.rst:4952 msgid "" "format ``'B'`` is now handled according to the struct module syntax. This " "means that ``memoryview(b'abc')[0] == b'abc'[0] == 97``." msgstr "" -#: ../../library/stdtypes.rst:4953 +#: ../../library/stdtypes.rst:4958 msgid "The size in bytes of each element of the memoryview::" msgstr "" -#: ../../library/stdtypes.rst:4955 +#: ../../library/stdtypes.rst:4960 msgid "" ">>> import array, struct\n" ">>> m = memoryview(array.array('H', [32000, 32001, 32002]))\n" @@ -7231,49 +7238,49 @@ msgstr "" ">>> struct.calcsize('H') == m.itemsize\n" "True" -#: ../../library/stdtypes.rst:4966 +#: ../../library/stdtypes.rst:4971 msgid "" "An integer indicating how many dimensions of a multi-dimensional array the " "memory represents." msgstr "" -#: ../../library/stdtypes.rst:4971 +#: ../../library/stdtypes.rst:4976 msgid "" "A tuple of integers the length of :attr:`ndim` giving the shape of the " "memory as an N-dimensional array." msgstr "" -#: ../../library/stdtypes.rst:4974 ../../library/stdtypes.rst:4982 +#: ../../library/stdtypes.rst:4979 ../../library/stdtypes.rst:4987 msgid "An empty tuple instead of ``None`` when ndim = 0." msgstr "" -#: ../../library/stdtypes.rst:4979 +#: ../../library/stdtypes.rst:4984 msgid "" "A tuple of integers the length of :attr:`ndim` giving the size in bytes to " "access each element for each dimension of the array." msgstr "" -#: ../../library/stdtypes.rst:4987 +#: ../../library/stdtypes.rst:4992 msgid "Used internally for PIL-style arrays. The value is informational only." msgstr "" -#: ../../library/stdtypes.rst:4991 +#: ../../library/stdtypes.rst:4996 msgid "A bool indicating whether the memory is C-:term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4997 +#: ../../library/stdtypes.rst:5002 msgid "A bool indicating whether the memory is Fortran :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:5003 +#: ../../library/stdtypes.rst:5008 msgid "A bool indicating whether the memory is :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:5011 +#: ../../library/stdtypes.rst:5016 msgid "Set Types --- :class:`set`, :class:`frozenset`" msgstr "" -#: ../../library/stdtypes.rst:5015 +#: ../../library/stdtypes.rst:5020 msgid "" "A :dfn:`set` object is an unordered collection of distinct :term:`hashable` " "objects. Common uses include membership testing, removing duplicates from a " @@ -7283,7 +7290,7 @@ msgid "" "`collections` module.)" msgstr "" -#: ../../library/stdtypes.rst:5022 +#: ../../library/stdtypes.rst:5027 msgid "" "Like other collections, sets support ``x in set``, ``len(set)``, and ``for x " "in set``. Being an unordered collection, sets do not record element " @@ -7291,7 +7298,7 @@ msgid "" "slicing, or other sequence-like behavior." msgstr "" -#: ../../library/stdtypes.rst:5027 +#: ../../library/stdtypes.rst:5032 msgid "" "There are currently two built-in set types, :class:`set` and :class:" "`frozenset`. The :class:`set` type is mutable --- the contents can be " @@ -7303,18 +7310,18 @@ msgid "" "of another set." msgstr "" -#: ../../library/stdtypes.rst:5036 +#: ../../library/stdtypes.rst:5041 msgid "" "Non-empty sets (not frozensets) can be created by placing a comma-separated " "list of elements within braces, for example: ``{'jack', 'sjoerd'}``, in " "addition to the :class:`set` constructor." msgstr "" -#: ../../library/stdtypes.rst:5040 +#: ../../library/stdtypes.rst:5045 msgid "The constructors for both classes work the same:" msgstr "" -#: ../../library/stdtypes.rst:5045 +#: ../../library/stdtypes.rst:5050 msgid "" "Return a new set or frozenset object whose elements are taken from " "*iterable*. The elements of a set must be :term:`hashable`. To represent " @@ -7322,92 +7329,92 @@ msgid "" "*iterable* is not specified, a new empty set is returned." msgstr "" -#: ../../library/stdtypes.rst:5051 +#: ../../library/stdtypes.rst:5056 msgid "Sets can be created by several means:" msgstr "集合可以以多種方式建立:" -#: ../../library/stdtypes.rst:5053 +#: ../../library/stdtypes.rst:5058 msgid "" "Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:5054 +#: ../../library/stdtypes.rst:5059 msgid "" "Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}``" msgstr "" -#: ../../library/stdtypes.rst:5055 +#: ../../library/stdtypes.rst:5060 msgid "" "Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', " "'foo'])``" msgstr "" -#: ../../library/stdtypes.rst:5057 +#: ../../library/stdtypes.rst:5062 msgid "" "Instances of :class:`set` and :class:`frozenset` provide the following " "operations:" msgstr "" -#: ../../library/stdtypes.rst:5062 +#: ../../library/stdtypes.rst:5067 msgid "Return the number of elements in set *s* (cardinality of *s*)." msgstr "" -#: ../../library/stdtypes.rst:5066 +#: ../../library/stdtypes.rst:5071 msgid "Test *x* for membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:5070 +#: ../../library/stdtypes.rst:5075 msgid "Test *x* for non-membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:5075 +#: ../../library/stdtypes.rst:5080 msgid "" "Return ``True`` if the set has no elements in common with *other*. Sets are " "disjoint if and only if their intersection is the empty set." msgstr "" -#: ../../library/stdtypes.rst:5082 +#: ../../library/stdtypes.rst:5087 msgid "Test whether every element in the set is in *other*." msgstr "" -#: ../../library/stdtypes.rst:5086 +#: ../../library/stdtypes.rst:5091 msgid "" "Test whether the set is a proper subset of *other*, that is, ``set <= other " "and set != other``." msgstr "" -#: ../../library/stdtypes.rst:5093 +#: ../../library/stdtypes.rst:5098 msgid "Test whether every element in *other* is in the set." msgstr "" -#: ../../library/stdtypes.rst:5097 +#: ../../library/stdtypes.rst:5102 msgid "" "Test whether the set is a proper superset of *other*, that is, ``set >= " "other and set != other``." msgstr "" -#: ../../library/stdtypes.rst:5104 +#: ../../library/stdtypes.rst:5109 msgid "Return a new set with elements from the set and all others." msgstr "" -#: ../../library/stdtypes.rst:5110 +#: ../../library/stdtypes.rst:5115 msgid "Return a new set with elements common to the set and all others." msgstr "" -#: ../../library/stdtypes.rst:5116 +#: ../../library/stdtypes.rst:5121 msgid "Return a new set with elements in the set that are not in the others." msgstr "" -#: ../../library/stdtypes.rst:5122 +#: ../../library/stdtypes.rst:5127 msgid "" "Return a new set with elements in either the set or *other* but not both." msgstr "" -#: ../../library/stdtypes.rst:5127 +#: ../../library/stdtypes.rst:5132 msgid "Return a shallow copy of the set." msgstr "" -#: ../../library/stdtypes.rst:5130 +#: ../../library/stdtypes.rst:5135 msgid "" "Note, the non-operator versions of :meth:`~frozenset.union`, :meth:" "`~frozenset.intersection`, :meth:`~frozenset.difference`, :meth:`~frozenset." @@ -7418,7 +7425,7 @@ msgid "" "the more readable ``set('abc').intersection('cbs')``." msgstr "" -#: ../../library/stdtypes.rst:5137 +#: ../../library/stdtypes.rst:5142 msgid "" "Both :class:`set` and :class:`frozenset` support set to set comparisons. Two " "sets are equal if and only if every element of each set is contained in the " @@ -7428,14 +7435,14 @@ msgid "" "set is a proper superset of the second set (is a superset, but is not equal)." msgstr "" -#: ../../library/stdtypes.rst:5144 +#: ../../library/stdtypes.rst:5149 msgid "" "Instances of :class:`set` are compared to instances of :class:`frozenset` " "based on their members. For example, ``set('abc') == frozenset('abc')`` " "returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``." msgstr "" -#: ../../library/stdtypes.rst:5148 +#: ../../library/stdtypes.rst:5153 msgid "" "The subset and equality comparisons do not generalize to a total ordering " "function. For example, any two nonempty disjoint sets are not equal and are " @@ -7443,78 +7450,78 @@ msgid "" "``ab``." msgstr "" -#: ../../library/stdtypes.rst:5153 +#: ../../library/stdtypes.rst:5158 msgid "" "Since sets only define partial ordering (subset relationships), the output " "of the :meth:`list.sort` method is undefined for lists of sets." msgstr "" -#: ../../library/stdtypes.rst:5156 +#: ../../library/stdtypes.rst:5161 msgid "Set elements, like dictionary keys, must be :term:`hashable`." msgstr "" -#: ../../library/stdtypes.rst:5158 +#: ../../library/stdtypes.rst:5163 msgid "" "Binary operations that mix :class:`set` instances with :class:`frozenset` " "return the type of the first operand. For example: ``frozenset('ab') | " "set('bc')`` returns an instance of :class:`frozenset`." msgstr "" -#: ../../library/stdtypes.rst:5162 +#: ../../library/stdtypes.rst:5167 msgid "" "The following table lists operations available for :class:`set` that do not " "apply to immutable instances of :class:`frozenset`:" msgstr "" -#: ../../library/stdtypes.rst:5168 +#: ../../library/stdtypes.rst:5173 msgid "Update the set, adding elements from all others." msgstr "" -#: ../../library/stdtypes.rst:5173 +#: ../../library/stdtypes.rst:5178 msgid "Update the set, keeping only elements found in it and all others." msgstr "" -#: ../../library/stdtypes.rst:5178 +#: ../../library/stdtypes.rst:5183 msgid "Update the set, removing elements found in others." msgstr "" -#: ../../library/stdtypes.rst:5183 +#: ../../library/stdtypes.rst:5188 msgid "" "Update the set, keeping only elements found in either set, but not in both." msgstr "" -#: ../../library/stdtypes.rst:5187 +#: ../../library/stdtypes.rst:5192 msgid "Add element *elem* to the set." msgstr "將元素 *elem* 加入集合。" -#: ../../library/stdtypes.rst:5191 +#: ../../library/stdtypes.rst:5196 msgid "" "Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is not " "contained in the set." msgstr "" -#: ../../library/stdtypes.rst:5196 +#: ../../library/stdtypes.rst:5201 msgid "Remove element *elem* from the set if it is present." msgstr "如果 *elem* 存在於集合中則將其移除。" -#: ../../library/stdtypes.rst:5200 +#: ../../library/stdtypes.rst:5205 msgid "" "Remove and return an arbitrary element from the set. Raises :exc:`KeyError` " "if the set is empty." msgstr "" -#: ../../library/stdtypes.rst:5205 +#: ../../library/stdtypes.rst:5210 msgid "Remove all elements from the set." msgstr "從集合中移除所有元素。" -#: ../../library/stdtypes.rst:5208 +#: ../../library/stdtypes.rst:5213 msgid "" "Note, the non-operator versions of the :meth:`~set.update`, :meth:`~set." "intersection_update`, :meth:`~set.difference_update`, and :meth:`~set." "symmetric_difference_update` methods will accept any iterable as an argument." msgstr "" -#: ../../library/stdtypes.rst:5213 +#: ../../library/stdtypes.rst:5218 msgid "" "Note, the *elem* argument to the :meth:`~object.__contains__`, :meth:`~set." "remove`, and :meth:`~set.discard` methods may be a set. To support " @@ -7522,11 +7529,17 @@ msgid "" "*elem*." msgstr "" -#: ../../library/stdtypes.rst:5222 -msgid "Mapping Types --- :class:`dict`" +#: ../../library/stdtypes.rst:5225 +msgid "" +"For detailed information on thread-safety guarantees for :class:`set` " +"objects, see :ref:`thread-safety-set`." msgstr "" #: ../../library/stdtypes.rst:5232 +msgid "Mapping Types --- :class:`dict`" +msgstr "" + +#: ../../library/stdtypes.rst:5242 msgid "" "A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. " "Mappings are mutable objects. There is currently only one standard mapping " @@ -7535,7 +7548,7 @@ msgid "" "module.)" msgstr "" -#: ../../library/stdtypes.rst:5238 +#: ../../library/stdtypes.rst:5248 msgid "" "A dictionary's keys are *almost* arbitrary values. Values that are not :" "term:`hashable`, that is, values containing lists, dictionaries or other " @@ -7544,33 +7557,33 @@ msgid "" "and ``True``) can be used interchangeably to index the same dictionary entry." msgstr "" -#: ../../library/stdtypes.rst:5249 +#: ../../library/stdtypes.rst:5259 msgid "" "Return a new dictionary initialized from an optional positional argument and " "a possibly empty set of keyword arguments." msgstr "" -#: ../../library/stdtypes.rst:5252 +#: ../../library/stdtypes.rst:5262 msgid "Dictionaries can be created by several means:" msgstr "字典可以用數種方式建立:" -#: ../../library/stdtypes.rst:5254 +#: ../../library/stdtypes.rst:5264 msgid "" "Use a comma-separated list of ``key: value`` pairs within braces: ``{'jack': " "4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:5256 +#: ../../library/stdtypes.rst:5266 msgid "Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``" msgstr "" -#: ../../library/stdtypes.rst:5257 +#: ../../library/stdtypes.rst:5267 msgid "" "Use the type constructor: ``dict()``, ``dict([('foo', 100), ('bar', " "200)])``, ``dict(foo=100, bar=200)``" msgstr "" -#: ../../library/stdtypes.rst:5260 +#: ../../library/stdtypes.rst:5270 msgid "" "If no positional argument is given, an empty dictionary is created. If a " "positional argument is given and it defines a ``keys()`` method, a " @@ -7583,7 +7596,7 @@ msgid "" "that key becomes the corresponding value in the new dictionary." msgstr "" -#: ../../library/stdtypes.rst:5270 +#: ../../library/stdtypes.rst:5280 msgid "" "If keyword arguments are given, the keyword arguments and their values are " "added to the dictionary created from the positional argument. If a key " @@ -7591,7 +7604,7 @@ msgid "" "the value from the positional argument." msgstr "" -#: ../../library/stdtypes.rst:5275 +#: ../../library/stdtypes.rst:5285 msgid "" "Dictionaries compare equal if and only if they have the same ``(key, " "value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', " @@ -7600,7 +7613,7 @@ msgid "" "``{\"one\": 1, \"two\": 2, \"three\": 3}``::" msgstr "" -#: ../../library/stdtypes.rst:5281 +#: ../../library/stdtypes.rst:5291 msgid "" ">>> a = dict(one=1, two=2, three=3)\n" ">>> b = {'one': 1, 'two': 2, 'three': 3}\n" @@ -7620,19 +7633,19 @@ msgstr "" ">>> a == b == c == d == e == f\n" "True" -#: ../../library/stdtypes.rst:5290 +#: ../../library/stdtypes.rst:5300 msgid "" "Providing keyword arguments as in the first example only works for keys that " "are valid Python identifiers. Otherwise, any valid keys can be used." msgstr "" -#: ../../library/stdtypes.rst:5293 +#: ../../library/stdtypes.rst:5303 msgid "" "Dictionaries preserve insertion order. Note that updating a key does not " "affect the order. Keys added after deletion are inserted at the end. ::" msgstr "" -#: ../../library/stdtypes.rst:5296 +#: ../../library/stdtypes.rst:5306 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -7664,33 +7677,33 @@ msgstr "" ">>> d\n" "{'one': 42, 'three': 3, 'four': 4, 'two': None}" -#: ../../library/stdtypes.rst:5311 +#: ../../library/stdtypes.rst:5321 msgid "" "Dictionary order is guaranteed to be insertion order. This behavior was an " "implementation detail of CPython from 3.6." msgstr "" -#: ../../library/stdtypes.rst:5315 +#: ../../library/stdtypes.rst:5325 msgid "" "These are the operations that dictionaries support (and therefore, custom " "mapping types should support too):" msgstr "" -#: ../../library/stdtypes.rst:5320 +#: ../../library/stdtypes.rst:5330 msgid "Return a list of all the keys used in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:5324 +#: ../../library/stdtypes.rst:5334 msgid "Return the number of items in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:5328 +#: ../../library/stdtypes.rst:5338 msgid "" "Return the item of *d* with key *key*. Raises a :exc:`KeyError` if *key* is " "not in the map." msgstr "" -#: ../../library/stdtypes.rst:5333 +#: ../../library/stdtypes.rst:5343 msgid "" "If a subclass of dict defines a method :meth:`~object.__missing__` and *key* " "is not present, the ``d[key]`` operation calls that method with the key " @@ -7701,7 +7714,7 @@ msgid "" "__missing__` must be a method; it cannot be an instance variable::" msgstr "" -#: ../../library/stdtypes.rst:5341 +#: ../../library/stdtypes.rst:5351 msgid "" ">>> class Counter(dict):\n" "... def __missing__(self, key):\n" @@ -7725,51 +7738,51 @@ msgstr "" ">>> c['red']\n" "1" -#: ../../library/stdtypes.rst:5352 +#: ../../library/stdtypes.rst:5362 msgid "" "The example above shows part of the implementation of :class:`collections." "Counter`. A different :meth:`!__missing__` method is used by :class:" "`collections.defaultdict`." msgstr "" -#: ../../library/stdtypes.rst:5359 +#: ../../library/stdtypes.rst:5369 msgid "Set ``d[key]`` to *value*." msgstr "將 ``d[key]`` 設為 *value*。" -#: ../../library/stdtypes.rst:5363 +#: ../../library/stdtypes.rst:5373 msgid "" "Remove ``d[key]`` from *d*. Raises a :exc:`KeyError` if *key* is not in the " "map." msgstr "從 *d* 中移除 ``d[key]``。若 *key* 不在對映中則引發 :exc:`KeyError`。" -#: ../../library/stdtypes.rst:5368 +#: ../../library/stdtypes.rst:5378 msgid "Return ``True`` if *d* has a key *key*, else ``False``." msgstr "若 *d* 有鍵 *key* 則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/stdtypes.rst:5372 +#: ../../library/stdtypes.rst:5382 msgid "Equivalent to ``not key in d``." msgstr "等價於 ``not key in d``。" -#: ../../library/stdtypes.rst:5376 +#: ../../library/stdtypes.rst:5386 msgid "" "Return an iterator over the keys of the dictionary. This is a shortcut for " "``iter(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:5381 +#: ../../library/stdtypes.rst:5391 msgid "Remove all items from the dictionary." msgstr "從字典中移除所有項目。" -#: ../../library/stdtypes.rst:5385 +#: ../../library/stdtypes.rst:5395 msgid "Return a shallow copy of the dictionary." msgstr "" -#: ../../library/stdtypes.rst:5389 +#: ../../library/stdtypes.rst:5399 msgid "" "Create a new dictionary with keys from *iterable* and values set to *value*." msgstr "" -#: ../../library/stdtypes.rst:5391 +#: ../../library/stdtypes.rst:5401 msgid "" ":meth:`fromkeys` is a class method that returns a new dictionary. *value* " "defaults to ``None``. All of the values refer to just a single instance, so " @@ -7778,70 +7791,70 @@ msgid "" "` instead." msgstr "" -#: ../../library/stdtypes.rst:5399 +#: ../../library/stdtypes.rst:5409 msgid "" "Return the value for *key* if *key* is in the dictionary, else *default*. If " "*default* is not given, it defaults to ``None``, so that this method never " "raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:5405 +#: ../../library/stdtypes.rst:5415 msgid "" "Return a new view of the dictionary's items (``(key, value)`` pairs). See " "the :ref:`documentation of view objects `." msgstr "" -#: ../../library/stdtypes.rst:5410 +#: ../../library/stdtypes.rst:5420 msgid "" "Return a new view of the dictionary's keys. See the :ref:`documentation of " "view objects `." msgstr "" -#: ../../library/stdtypes.rst:5416 +#: ../../library/stdtypes.rst:5426 msgid "" "If *key* is in the dictionary, remove it and return its value, else return " "*default*. If *default* is not given and *key* is not in the dictionary, a :" "exc:`KeyError` is raised." msgstr "" -#: ../../library/stdtypes.rst:5422 +#: ../../library/stdtypes.rst:5432 msgid "" "Remove and return a ``(key, value)`` pair from the dictionary. Pairs are " "returned in :abbr:`LIFO (last-in, first-out)` order." msgstr "" -#: ../../library/stdtypes.rst:5425 +#: ../../library/stdtypes.rst:5435 msgid "" ":meth:`popitem` is useful to destructively iterate over a dictionary, as " "often used in set algorithms. If the dictionary is empty, calling :meth:" "`popitem` raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:5429 +#: ../../library/stdtypes.rst:5439 msgid "" "LIFO order is now guaranteed. In prior versions, :meth:`popitem` would " "return an arbitrary key/value pair." msgstr "" -#: ../../library/stdtypes.rst:5435 +#: ../../library/stdtypes.rst:5445 msgid "" "Return a reverse iterator over the keys of the dictionary. This is a " "shortcut for ``reversed(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:5442 +#: ../../library/stdtypes.rst:5452 msgid "" "If *key* is in the dictionary, return its value. If not, insert *key* with " "a value of *default* and return *default*. *default* defaults to ``None``." msgstr "" -#: ../../library/stdtypes.rst:5450 +#: ../../library/stdtypes.rst:5460 msgid "" "Update the dictionary with the key/value pairs from *mapping* or *iterable* " "and *kwargs*, overwriting existing keys. Return ``None``." msgstr "" -#: ../../library/stdtypes.rst:5453 +#: ../../library/stdtypes.rst:5463 msgid "" ":meth:`update` accepts either another object with a ``keys()`` method (in " "which case :meth:`~object.__getitem__` is called with every key returned " @@ -7850,20 +7863,20 @@ msgid "" "is then updated with those key/value pairs: ``d.update(red=1, blue=2)``." msgstr "" -#: ../../library/stdtypes.rst:5461 +#: ../../library/stdtypes.rst:5471 msgid "" "Return a new view of the dictionary's values. See the :ref:`documentation " "of view objects `." msgstr "" -#: ../../library/stdtypes.rst:5464 +#: ../../library/stdtypes.rst:5474 msgid "" "An equality comparison between one ``dict.values()`` view and another will " "always return ``False``. This also applies when comparing ``dict.values()`` " "to itself::" msgstr "" -#: ../../library/stdtypes.rst:5468 +#: ../../library/stdtypes.rst:5478 msgid "" ">>> d = {'a': 1}\n" ">>> d.values() == d.values()\n" @@ -7873,25 +7886,25 @@ msgstr "" ">>> d.values() == d.values()\n" "False" -#: ../../library/stdtypes.rst:5474 +#: ../../library/stdtypes.rst:5484 msgid "" "Create a new dictionary with the merged keys and values of *d* and *other*, " "which must both be dictionaries. The values of *other* take priority when " "*d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:5482 +#: ../../library/stdtypes.rst:5492 msgid "" "Update the dictionary *d* with keys and values from *other*, which may be " "either a :term:`mapping` or an :term:`iterable` of key/value pairs. The " "values of *other* take priority when *d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:5488 +#: ../../library/stdtypes.rst:5498 msgid "Dictionaries and dictionary views are reversible. ::" msgstr "" -#: ../../library/stdtypes.rst:5490 +#: ../../library/stdtypes.rst:5500 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -7913,27 +7926,27 @@ msgstr "" ">>> list(reversed(d.items()))\n" "[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" -#: ../../library/stdtypes.rst:5500 +#: ../../library/stdtypes.rst:5510 msgid "Dictionaries are now reversible." msgstr "" -#: ../../library/stdtypes.rst:5505 +#: ../../library/stdtypes.rst:5515 msgid "" ":class:`types.MappingProxyType` can be used to create a read-only view of a :" "class:`dict`." msgstr "" -#: ../../library/stdtypes.rst:5511 +#: ../../library/stdtypes.rst:5521 msgid "" "For detailed information on thread-safety guarantees for :class:`dict` " "objects, see :ref:`thread-safety-dict`." msgstr "" -#: ../../library/stdtypes.rst:5518 +#: ../../library/stdtypes.rst:5528 msgid "Dictionary view objects" msgstr "字典視圖物件" -#: ../../library/stdtypes.rst:5520 +#: ../../library/stdtypes.rst:5530 msgid "" "The objects returned by :meth:`dict.keys`, :meth:`dict.values` and :meth:" "`dict.items` are *view objects*. They provide a dynamic view on the " @@ -7941,23 +7954,23 @@ msgid "" "reflects these changes." msgstr "" -#: ../../library/stdtypes.rst:5525 +#: ../../library/stdtypes.rst:5535 msgid "" "Dictionary views can be iterated over to yield their respective data, and " "support membership tests:" msgstr "" -#: ../../library/stdtypes.rst:5530 +#: ../../library/stdtypes.rst:5540 msgid "Return the number of entries in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:5534 +#: ../../library/stdtypes.rst:5544 msgid "" "Return an iterator over the keys, values or items (represented as tuples of " "``(key, value)``) in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:5537 +#: ../../library/stdtypes.rst:5547 msgid "" "Keys and values are iterated over in insertion order. This allows the " "creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = zip(d." @@ -7965,39 +7978,39 @@ msgid "" "[(v, k) for (k, v) in d.items()]``." msgstr "" -#: ../../library/stdtypes.rst:5542 +#: ../../library/stdtypes.rst:5552 msgid "" "Iterating views while adding or deleting entries in the dictionary may raise " "a :exc:`RuntimeError` or fail to iterate over all entries." msgstr "" -#: ../../library/stdtypes.rst:5545 +#: ../../library/stdtypes.rst:5555 msgid "Dictionary order is guaranteed to be insertion order." msgstr "" -#: ../../library/stdtypes.rst:5550 +#: ../../library/stdtypes.rst:5560 msgid "" "Return ``True`` if *x* is in the underlying dictionary's keys, values or " "items (in the latter case, *x* should be a ``(key, value)`` tuple)." msgstr "" -#: ../../library/stdtypes.rst:5555 +#: ../../library/stdtypes.rst:5565 msgid "" "Return a reverse iterator over the keys, values or items of the dictionary. " "The view will be iterated in reverse order of the insertion." msgstr "" -#: ../../library/stdtypes.rst:5558 +#: ../../library/stdtypes.rst:5568 msgid "Dictionary views are now reversible." msgstr "" -#: ../../library/stdtypes.rst:5563 +#: ../../library/stdtypes.rst:5573 msgid "" "Return a :class:`types.MappingProxyType` that wraps the original dictionary " "to which the view refers." msgstr "" -#: ../../library/stdtypes.rst:5568 +#: ../../library/stdtypes.rst:5578 msgid "" "Keys views are set-like since their entries are unique and :term:`hashable`. " "Items views also have set-like operations since the (key, value) pairs are " @@ -8011,11 +8024,11 @@ msgid "" "input." msgstr "" -#: ../../library/stdtypes.rst:5580 +#: ../../library/stdtypes.rst:5590 msgid "An example of dictionary view usage::" msgstr "" -#: ../../library/stdtypes.rst:5582 +#: ../../library/stdtypes.rst:5592 msgid "" ">>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}\n" ">>> keys = dishes.keys()\n" @@ -8056,11 +8069,11 @@ msgid "" "500" msgstr "" -#: ../../library/stdtypes.rst:5624 +#: ../../library/stdtypes.rst:5634 msgid "Context Manager Types" msgstr "情境管理器型別" -#: ../../library/stdtypes.rst:5631 +#: ../../library/stdtypes.rst:5641 msgid "" "Python's :keyword:`with` statement supports the concept of a runtime context " "defined by a context manager. This is implemented using a pair of methods " @@ -8071,7 +8084,7 @@ msgstr "" "要使用兩個方法來實作,該方法讓使用者定義類別能夠去定義 runtime 情境,且該情境" "在執行陳述式主體 (statement body) 之前進入、在陳述式結束時退出:" -#: ../../library/stdtypes.rst:5639 +#: ../../library/stdtypes.rst:5649 msgid "" "Enter the runtime context and return either this object or another object " "related to the runtime context. The value returned by this method is bound " @@ -8082,7 +8095,7 @@ msgstr "" "的值有被綁定到使用此情境管理器的 :keyword:`with` 陳述式的 :keyword:`!as` 子句" "中的識別字。" -#: ../../library/stdtypes.rst:5644 +#: ../../library/stdtypes.rst:5654 msgid "" "An example of a context manager that returns itself is a :term:`file " "object`. File objects return themselves from __enter__() to allow :func:" @@ -8091,7 +8104,7 @@ msgstr "" "一個會回傳自己的情境管理器範例是 :term:`file object`。檔案物件從 __enter__() " "回傳自己,以允許將 :func:`open` 用作 :keyword:`with` 陳述式中的情境運算式。" -#: ../../library/stdtypes.rst:5648 +#: ../../library/stdtypes.rst:5658 msgid "" "An example of a context manager that returns a related object is the one " "returned by :func:`decimal.localcontext`. These managers set the active " @@ -8105,7 +8118,7 @@ msgstr "" "本。這允許對 :keyword:`with` 陳述式主體中的目前十進位情境進行更改,而不會影" "響 :keyword:`!with` 陳述式外部的程式碼。" -#: ../../library/stdtypes.rst:5658 +#: ../../library/stdtypes.rst:5668 msgid "" "Exit the runtime context and return a Boolean flag indicating if any " "exception that occurred should be suppressed. If an exception occurred while " @@ -8117,7 +8130,7 @@ msgstr "" "keyword:`with` 陳述式主體時發生例外,則引數包含例外型別、值和回溯 " "(traceback) 資訊。否則,所有三個引數都是 ``None``。" -#: ../../library/stdtypes.rst:5663 +#: ../../library/stdtypes.rst:5673 msgid "" "Returning a true value from this method will cause the :keyword:`with` " "statement to suppress the exception and continue execution with the " @@ -8128,14 +8141,14 @@ msgstr "" "keyword:`!with` 陳述式之後的陳述式。否則,該例外將在該方法執行完畢後繼續傳播 " "(propagate)。" -#: ../../library/stdtypes.rst:5668 +#: ../../library/stdtypes.rst:5678 msgid "" "If this method raises an exception while handling an earlier exception from " "the :keyword:`with` block, the new exception is raised, and the original " "exception is stored in its :attr:`~BaseException.__context__` attribute." msgstr "" -#: ../../library/stdtypes.rst:5672 +#: ../../library/stdtypes.rst:5682 msgid "" "The exception passed in should never be reraised explicitly - instead, this " "method should return a false value to indicate that the method completed " @@ -8147,7 +8160,7 @@ msgstr "" "已成功完成且不希望抑制引發的例外。這讓情境管理程式碼能輕鬆檢測 :meth:" "`~object.__exit__` 方法是否曾實際失敗過。" -#: ../../library/stdtypes.rst:5678 +#: ../../library/stdtypes.rst:5688 msgid "" "Python defines several context managers to support easy thread " "synchronisation, prompt closure of files or other objects, and simpler " @@ -8159,7 +8172,7 @@ msgstr "" "及對有效十進位算術情境的更簡單操作。除了情境管理協定的實作之外,不會對特定型" "別進行特殊處理。更多範例請參閱 :mod:`contextlib` 模組。" -#: ../../library/stdtypes.rst:5684 +#: ../../library/stdtypes.rst:5694 msgid "" "Python's :term:`generator`\\s and the :class:`contextlib.contextmanager` " "decorator provide a convenient way to implement these protocols. If a " @@ -8174,7 +8187,7 @@ msgstr "" "`~contextmanager.__enter__` 和 :meth:`~contextmanager.__exit__` 方法的情境管" "理器,而不是由未裝飾產生器函式產生的疊代器。" -#: ../../library/stdtypes.rst:5691 +#: ../../library/stdtypes.rst:5701 msgid "" "Note that there is no specific slot for any of these methods in the type " "structure for Python objects in the Python/C API. Extension types wanting to " @@ -8186,7 +8199,7 @@ msgstr "" "定義這些方法的擴充型別必須將它們作為普通的 Python 可存取方法提供。與設定 " "runtime 情境的開銷相比,單一類別字典查找的開銷可以忽略不計。" -#: ../../library/stdtypes.rst:5699 +#: ../../library/stdtypes.rst:5709 msgid "" "Type Annotation Types --- :ref:`Generic Alias `, :ref:" "`Union `" @@ -8194,7 +8207,7 @@ msgstr "" "型別註釋的型別 --- :ref:`泛型別名 (Generic Alias) `、:" "ref:`聯合 (Union) `" -#: ../../library/stdtypes.rst:5704 +#: ../../library/stdtypes.rst:5714 msgid "" "The core built-in types for :term:`type annotations ` are :ref:" "`Generic Alias ` and :ref:`Union `." @@ -8202,11 +8215,11 @@ msgstr "" ":term:`型別註釋 ` 的核心內建型別是\\ :ref:`泛型別名 `\\ 和\\ :ref:`聯合 `。" -#: ../../library/stdtypes.rst:5711 +#: ../../library/stdtypes.rst:5721 msgid "Generic Alias Type" msgstr "泛型別名型別" -#: ../../library/stdtypes.rst:5717 +#: ../../library/stdtypes.rst:5727 msgid "" "``GenericAlias`` objects are generally created by :ref:`subscripting " "` a class. They are most often used with :ref:`container " @@ -8222,7 +8235,7 @@ msgstr "" "立的。``GenericAlias`` 物件主要會與\\ :term:`型別註釋 ` 一起使" "用。" -#: ../../library/stdtypes.rst:5727 +#: ../../library/stdtypes.rst:5737 msgid "" "It is generally only possible to subscript a class if the class implements " "the special method :meth:`~object.__class_getitem__`." @@ -8230,7 +8243,7 @@ msgstr "" "通常只有當類別有實作特殊方法 :meth:`~object.__class_getitem__` 時才可以去下標" "該類別。" -#: ../../library/stdtypes.rst:5730 +#: ../../library/stdtypes.rst:5740 msgid "" "A ``GenericAlias`` object acts as a proxy for a :term:`generic type`, " "implementing *parameterized generics*." @@ -8238,7 +8251,7 @@ msgstr "" "將一個 ``GenericAlias`` 物件用作 :term:`generic type` 的代理,實作\\ *參數化" "泛型 (parameterized generics)*。" -#: ../../library/stdtypes.rst:5733 +#: ../../library/stdtypes.rst:5743 msgid "" "For a container class, the argument(s) supplied to a :ref:`subscription " "` of the class may indicate the type(s) of the elements an " @@ -8250,7 +8263,7 @@ msgstr "" "物件所包含元素的型別。例如 ``set[bytes]`` 可以用於型別註釋來表示一個 :class:" "`set`,其中所有元素的型別都是 :class:`bytes`。" -#: ../../library/stdtypes.rst:5739 +#: ../../library/stdtypes.rst:5749 msgid "" "For a class which defines :meth:`~object.__class_getitem__` but is not a " "container, the argument(s) supplied to a subscription of the class will " @@ -8262,7 +8275,7 @@ msgstr "" "標引數通常會指示物件上有定義的一個或多個方法的回傳型別。例如\\ :mod:`正規表示" "式 `\\ 可以用於 :class:`str` 和 :class:`bytes` 資料型別:" -#: ../../library/stdtypes.rst:5745 +#: ../../library/stdtypes.rst:5755 msgid "" "If ``x = re.search('foo', 'foo')``, ``x`` will be a :ref:`re.Match ` object where the return values of ``x.group(0)`` and ``x[0]`` will " @@ -8274,7 +8287,7 @@ msgstr "" "別。我們就可以用 ``GenericAlias`` ``re.Match[str]`` 在型別註釋中表示這種物" "件。" -#: ../../library/stdtypes.rst:5751 +#: ../../library/stdtypes.rst:5761 msgid "" "If ``y = re.search(b'bar', b'bar')``, (note the ``b`` for :class:`bytes`), " "``y`` will also be an instance of ``re.Match``, but the return values of ``y." @@ -8287,7 +8300,7 @@ msgstr "" "別都是 :class:`bytes`。在型別註釋中,我們將用 ``re.Match[bytes]`` 來表示各" "種 :ref:`re.Match ` 物件。" -#: ../../library/stdtypes.rst:5757 +#: ../../library/stdtypes.rst:5767 msgid "" "``GenericAlias`` objects are instances of the class :class:`types." "GenericAlias`, which can also be used to create ``GenericAlias`` objects " @@ -8296,7 +8309,7 @@ msgstr "" "``GenericAlias`` 物件是 :class:`types.GenericAlias` 類別的實例,也可以用來直" "接建立 ``GenericAlias`` 物件。" -#: ../../library/stdtypes.rst:5763 +#: ../../library/stdtypes.rst:5773 msgid "" "Creates a ``GenericAlias`` representing a type ``T`` parameterized by types " "*X*, *Y*, and more depending on the ``T`` used. For example, a function " @@ -8306,7 +8319,7 @@ msgstr "" "所使用的 ``T``)來參數化。例如,一個函式需要一個包含 :class:`float` 元素的 :" "class:`list`: ::" -#: ../../library/stdtypes.rst:5768 +#: ../../library/stdtypes.rst:5778 msgid "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" @@ -8314,7 +8327,7 @@ msgstr "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" -#: ../../library/stdtypes.rst:5771 +#: ../../library/stdtypes.rst:5781 msgid "" "Another example for :term:`mapping` objects, using a :class:`dict`, which is " "a generic type expecting two type parameters representing the key type and " @@ -8325,7 +8338,7 @@ msgstr "" "別,需要兩個型別參數,分別表示鍵型別和值型別。在此範例中,函式需要一個 " "``dict``,其帶有 :class:`str` 型別的鍵和 :class:`int` 型別的值: ::" -#: ../../library/stdtypes.rst:5776 +#: ../../library/stdtypes.rst:5786 msgid "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." @@ -8333,7 +8346,7 @@ msgstr "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." -#: ../../library/stdtypes.rst:5779 +#: ../../library/stdtypes.rst:5789 msgid "" "The builtin functions :func:`isinstance` and :func:`issubclass` do not " "accept ``GenericAlias`` types for their second argument::" @@ -8341,7 +8354,7 @@ msgstr "" "內建函式 :func:`isinstance` 和 :func:`issubclass` 不接受 ``GenericAlias`` 型" "別作為第二個引數: ::" -#: ../../library/stdtypes.rst:5782 +#: ../../library/stdtypes.rst:5792 msgid "" ">>> isinstance([1, 2], list[str])\n" "Traceback (most recent call last):\n" @@ -8353,7 +8366,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" -#: ../../library/stdtypes.rst:5787 +#: ../../library/stdtypes.rst:5797 msgid "" "The Python runtime does not enforce :term:`type annotations `. " "This extends to generic types and their type parameters. When creating a " @@ -8365,7 +8378,7 @@ msgstr "" "及其型別參數。當從 ``GenericAlias`` 建立容器物件時,不會檢查容器中元素的型" "別。例如,不鼓勵使用以下程式碼,但 runtime 不會出現錯誤: ::" -#: ../../library/stdtypes.rst:5793 +#: ../../library/stdtypes.rst:5803 msgid "" ">>> t = list[str]\n" ">>> t([1, 2, 3])\n" @@ -8375,13 +8388,13 @@ msgstr "" ">>> t([1, 2, 3])\n" "[1, 2, 3]" -#: ../../library/stdtypes.rst:5797 +#: ../../library/stdtypes.rst:5807 msgid "" "Furthermore, parameterized generics erase type parameters during object " "creation::" msgstr "此外,參數化泛型在物件建立期間會擦除 (erase) 型別參數: ::" -#: ../../library/stdtypes.rst:5800 +#: ../../library/stdtypes.rst:5810 msgid "" ">>> t = list[str]\n" ">>> type(t)\n" @@ -8399,13 +8412,13 @@ msgstr "" ">>> type(l)\n" "" -#: ../../library/stdtypes.rst:5808 +#: ../../library/stdtypes.rst:5818 msgid "" "Calling :func:`repr` or :func:`str` on a generic shows the parameterized " "type::" msgstr "在泛型上呼叫 :func:`repr` 或 :func:`str` 會顯示參數化型別: ::" -#: ../../library/stdtypes.rst:5810 +#: ../../library/stdtypes.rst:5820 msgid "" ">>> repr(list[int])\n" "'list[int]'\n" @@ -8419,7 +8432,7 @@ msgstr "" ">>> str(list[int])\n" "'list[int]'" -#: ../../library/stdtypes.rst:5816 +#: ../../library/stdtypes.rst:5826 msgid "" "The :meth:`~object.__getitem__` method of generic containers will raise an " "exception to disallow mistakes like ``dict[str][str]``::" @@ -8427,7 +8440,7 @@ msgstr "" "為防止像是 ``dict[str][str]`` 的錯誤出現,泛型容器的 :meth:`~object." "__getitem__` 方法會在這種情況下引發例外: ::" -#: ../../library/stdtypes.rst:5819 +#: ../../library/stdtypes.rst:5829 msgid "" ">>> dict[str][str]\n" "Traceback (most recent call last):\n" @@ -8439,7 +8452,7 @@ msgstr "" " ...\n" "TypeError: dict[str] is not a generic class" -#: ../../library/stdtypes.rst:5824 +#: ../../library/stdtypes.rst:5834 msgid "" "However, such expressions are valid when :ref:`type variables ` " "are used. The index must have as many elements as there are type variable " @@ -8449,7 +8462,7 @@ msgstr "" "的。索引的元素數量必須與 ``GenericAlias`` 物件的 :attr:`~genericalias." "__args__` 中的型別變數項目一樣多: ::" -#: ../../library/stdtypes.rst:5828 +#: ../../library/stdtypes.rst:5838 msgid "" ">>> from typing import TypeVar\n" ">>> Y = TypeVar('Y')\n" @@ -8461,253 +8474,253 @@ msgstr "" ">>> dict[str, Y][int]\n" "dict[str, int]" -#: ../../library/stdtypes.rst:5835 +#: ../../library/stdtypes.rst:5845 msgid "Standard Generic Classes" msgstr "標準泛型類別" -#: ../../library/stdtypes.rst:5837 +#: ../../library/stdtypes.rst:5847 msgid "" "The following standard library classes support parameterized generics. This " "list is non-exhaustive." msgstr "以下標準函式庫類別有支援參數化泛型。此列表並非詳盡無遺。" -#: ../../library/stdtypes.rst:5840 +#: ../../library/stdtypes.rst:5850 msgid ":class:`tuple`" msgstr ":class:`tuple`" -#: ../../library/stdtypes.rst:5841 +#: ../../library/stdtypes.rst:5851 msgid ":class:`list`" msgstr ":class:`list`" -#: ../../library/stdtypes.rst:5842 +#: ../../library/stdtypes.rst:5852 msgid ":class:`dict`" msgstr ":class:`dict`" -#: ../../library/stdtypes.rst:5843 +#: ../../library/stdtypes.rst:5853 msgid ":class:`set`" msgstr ":class:`set`" -#: ../../library/stdtypes.rst:5844 +#: ../../library/stdtypes.rst:5854 msgid ":class:`frozenset`" msgstr ":class:`frozenset`" -#: ../../library/stdtypes.rst:5845 +#: ../../library/stdtypes.rst:5855 msgid ":class:`type`" msgstr ":class:`type`" -#: ../../library/stdtypes.rst:5846 +#: ../../library/stdtypes.rst:5856 msgid ":class:`asyncio.Future`" msgstr ":class:`asyncio.Future`" -#: ../../library/stdtypes.rst:5847 +#: ../../library/stdtypes.rst:5857 msgid ":class:`asyncio.Task`" msgstr ":class:`asyncio.Task`" -#: ../../library/stdtypes.rst:5848 +#: ../../library/stdtypes.rst:5858 msgid ":class:`collections.deque`" msgstr ":class:`collections.deque`" -#: ../../library/stdtypes.rst:5849 +#: ../../library/stdtypes.rst:5859 msgid ":class:`collections.defaultdict`" msgstr ":class:`collections.defaultdict`" -#: ../../library/stdtypes.rst:5850 +#: ../../library/stdtypes.rst:5860 msgid ":class:`collections.OrderedDict`" msgstr ":class:`collections.OrderedDict`" -#: ../../library/stdtypes.rst:5851 +#: ../../library/stdtypes.rst:5861 msgid ":class:`collections.Counter`" msgstr ":class:`collections.Counter`" -#: ../../library/stdtypes.rst:5852 +#: ../../library/stdtypes.rst:5862 msgid ":class:`collections.ChainMap`" msgstr ":class:`collections.ChainMap`" -#: ../../library/stdtypes.rst:5853 +#: ../../library/stdtypes.rst:5863 msgid ":class:`collections.abc.Awaitable`" msgstr ":class:`collections.abc.Awaitable`" -#: ../../library/stdtypes.rst:5854 +#: ../../library/stdtypes.rst:5864 msgid ":class:`collections.abc.Coroutine`" msgstr ":class:`collections.abc.Coroutine`" -#: ../../library/stdtypes.rst:5855 +#: ../../library/stdtypes.rst:5865 msgid ":class:`collections.abc.AsyncIterable`" msgstr ":class:`collections.abc.AsyncIterable`" -#: ../../library/stdtypes.rst:5856 +#: ../../library/stdtypes.rst:5866 msgid ":class:`collections.abc.AsyncIterator`" msgstr ":class:`collections.abc.AsyncIterator`" -#: ../../library/stdtypes.rst:5857 +#: ../../library/stdtypes.rst:5867 msgid ":class:`collections.abc.AsyncGenerator`" msgstr ":class:`collections.abc.AsyncGenerator`" -#: ../../library/stdtypes.rst:5858 +#: ../../library/stdtypes.rst:5868 msgid ":class:`collections.abc.Iterable`" msgstr ":class:`collections.abc.Iterable`" -#: ../../library/stdtypes.rst:5859 +#: ../../library/stdtypes.rst:5869 msgid ":class:`collections.abc.Iterator`" msgstr ":class:`collections.abc.Iterator`" -#: ../../library/stdtypes.rst:5860 +#: ../../library/stdtypes.rst:5870 msgid ":class:`collections.abc.Generator`" msgstr ":class:`collections.abc.Generator`" -#: ../../library/stdtypes.rst:5861 +#: ../../library/stdtypes.rst:5871 msgid ":class:`collections.abc.Reversible`" msgstr ":class:`collections.abc.Reversible`" -#: ../../library/stdtypes.rst:5862 +#: ../../library/stdtypes.rst:5872 msgid ":class:`collections.abc.Container`" msgstr ":class:`collections.abc.Container`" -#: ../../library/stdtypes.rst:5863 +#: ../../library/stdtypes.rst:5873 msgid ":class:`collections.abc.Collection`" msgstr ":class:`collections.abc.Collection`" -#: ../../library/stdtypes.rst:5864 +#: ../../library/stdtypes.rst:5874 msgid ":class:`collections.abc.Callable`" msgstr ":class:`collections.abc.Callable`" -#: ../../library/stdtypes.rst:5865 +#: ../../library/stdtypes.rst:5875 msgid ":class:`collections.abc.Set`" msgstr ":class:`collections.abc.Set`" -#: ../../library/stdtypes.rst:5866 +#: ../../library/stdtypes.rst:5876 msgid ":class:`collections.abc.MutableSet`" msgstr ":class:`collections.abc.MutableSet`" -#: ../../library/stdtypes.rst:5867 +#: ../../library/stdtypes.rst:5877 msgid ":class:`collections.abc.Mapping`" msgstr ":class:`collections.abc.Mapping`" -#: ../../library/stdtypes.rst:5868 +#: ../../library/stdtypes.rst:5878 msgid ":class:`collections.abc.MutableMapping`" msgstr ":class:`collections.abc.MutableMapping`" -#: ../../library/stdtypes.rst:5869 +#: ../../library/stdtypes.rst:5879 msgid ":class:`collections.abc.Sequence`" msgstr ":class:`collections.abc.Sequence`" -#: ../../library/stdtypes.rst:5870 +#: ../../library/stdtypes.rst:5880 msgid ":class:`collections.abc.MutableSequence`" msgstr ":class:`collections.abc.MutableSequence`" -#: ../../library/stdtypes.rst:5871 +#: ../../library/stdtypes.rst:5881 msgid ":class:`collections.abc.ByteString`" msgstr ":class:`collections.abc.ByteString`" -#: ../../library/stdtypes.rst:5872 +#: ../../library/stdtypes.rst:5882 msgid ":class:`collections.abc.MappingView`" msgstr ":class:`collections.abc.MappingView`" -#: ../../library/stdtypes.rst:5873 +#: ../../library/stdtypes.rst:5883 msgid ":class:`collections.abc.KeysView`" msgstr ":class:`collections.abc.KeysView`" -#: ../../library/stdtypes.rst:5874 +#: ../../library/stdtypes.rst:5884 msgid ":class:`collections.abc.ItemsView`" msgstr ":class:`collections.abc.ItemsView`" -#: ../../library/stdtypes.rst:5875 +#: ../../library/stdtypes.rst:5885 msgid ":class:`collections.abc.ValuesView`" msgstr ":class:`collections.abc.ValuesView`" -#: ../../library/stdtypes.rst:5876 +#: ../../library/stdtypes.rst:5886 msgid ":class:`contextlib.AbstractContextManager`" msgstr ":class:`contextlib.AbstractContextManager`" -#: ../../library/stdtypes.rst:5877 +#: ../../library/stdtypes.rst:5887 msgid ":class:`contextlib.AbstractAsyncContextManager`" msgstr ":class:`contextlib.AbstractAsyncContextManager`" -#: ../../library/stdtypes.rst:5878 +#: ../../library/stdtypes.rst:5888 msgid ":class:`dataclasses.Field`" msgstr ":class:`dataclasses.Field`" -#: ../../library/stdtypes.rst:5879 +#: ../../library/stdtypes.rst:5889 msgid ":class:`functools.cached_property`" msgstr ":class:`functools.cached_property`" -#: ../../library/stdtypes.rst:5880 +#: ../../library/stdtypes.rst:5890 msgid ":class:`functools.partialmethod`" msgstr ":class:`functools.partialmethod`" -#: ../../library/stdtypes.rst:5881 +#: ../../library/stdtypes.rst:5891 msgid ":class:`os.PathLike`" msgstr ":class:`os.PathLike`" -#: ../../library/stdtypes.rst:5882 +#: ../../library/stdtypes.rst:5892 msgid ":class:`queue.LifoQueue`" msgstr ":class:`queue.LifoQueue`" -#: ../../library/stdtypes.rst:5883 +#: ../../library/stdtypes.rst:5893 msgid ":class:`queue.Queue`" msgstr ":class:`queue.Queue`" -#: ../../library/stdtypes.rst:5884 +#: ../../library/stdtypes.rst:5894 msgid ":class:`queue.PriorityQueue`" msgstr ":class:`queue.PriorityQueue`" -#: ../../library/stdtypes.rst:5885 +#: ../../library/stdtypes.rst:5895 msgid ":class:`queue.SimpleQueue`" msgstr ":class:`queue.SimpleQueue`" -#: ../../library/stdtypes.rst:5886 +#: ../../library/stdtypes.rst:5896 msgid ":ref:`re.Pattern `" msgstr ":ref:`re.Pattern `" -#: ../../library/stdtypes.rst:5887 +#: ../../library/stdtypes.rst:5897 msgid ":ref:`re.Match `" msgstr ":ref:`re.Match `" -#: ../../library/stdtypes.rst:5888 +#: ../../library/stdtypes.rst:5898 msgid ":class:`shelve.BsdDbShelf`" msgstr ":class:`shelve.BsdDbShelf`" -#: ../../library/stdtypes.rst:5889 +#: ../../library/stdtypes.rst:5899 msgid ":class:`shelve.DbfilenameShelf`" msgstr ":class:`shelve.DbfilenameShelf`" -#: ../../library/stdtypes.rst:5890 +#: ../../library/stdtypes.rst:5900 msgid ":class:`shelve.Shelf`" msgstr ":class:`shelve.Shelf`" -#: ../../library/stdtypes.rst:5891 +#: ../../library/stdtypes.rst:5901 msgid ":class:`types.MappingProxyType`" msgstr ":class:`types.MappingProxyType`" -#: ../../library/stdtypes.rst:5892 +#: ../../library/stdtypes.rst:5902 msgid ":class:`weakref.WeakKeyDictionary`" msgstr ":class:`weakref.WeakKeyDictionary`" -#: ../../library/stdtypes.rst:5893 +#: ../../library/stdtypes.rst:5903 msgid ":class:`weakref.WeakMethod`" msgstr ":class:`weakref.WeakMethod`" -#: ../../library/stdtypes.rst:5894 +#: ../../library/stdtypes.rst:5904 msgid ":class:`weakref.WeakSet`" msgstr ":class:`weakref.WeakSet`" -#: ../../library/stdtypes.rst:5895 +#: ../../library/stdtypes.rst:5905 msgid ":class:`weakref.WeakValueDictionary`" msgstr ":class:`weakref.WeakValueDictionary`" -#: ../../library/stdtypes.rst:5900 +#: ../../library/stdtypes.rst:5910 msgid "Special Attributes of ``GenericAlias`` objects" msgstr "``GenericAlias`` 物件的特殊屬性" -#: ../../library/stdtypes.rst:5902 +#: ../../library/stdtypes.rst:5912 msgid "All parameterized generics implement special read-only attributes." msgstr "所有參數化泛型都有實作特殊的唯讀屬性。" -#: ../../library/stdtypes.rst:5906 +#: ../../library/stdtypes.rst:5916 msgid "This attribute points at the non-parameterized generic class::" msgstr "此屬性指向非參數化泛型類別: ::" -#: ../../library/stdtypes.rst:5908 +#: ../../library/stdtypes.rst:5918 msgid "" ">>> list[int].__origin__\n" "" @@ -8715,7 +8728,7 @@ msgstr "" ">>> list[int].__origin__\n" "" -#: ../../library/stdtypes.rst:5914 +#: ../../library/stdtypes.rst:5924 msgid "" "This attribute is a :class:`tuple` (possibly of length 1) of generic types " "passed to the original :meth:`~object.__class_getitem__` of the generic " @@ -8724,7 +8737,7 @@ msgstr "" "此屬性是傳遞給泛型類別之原始 :meth:`~object.__class_getitem__` 的泛型型別 :" "class:`tuple`\\ (長度可以為 1): ::" -#: ../../library/stdtypes.rst:5918 +#: ../../library/stdtypes.rst:5928 msgid "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" @@ -8732,7 +8745,7 @@ msgstr "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" -#: ../../library/stdtypes.rst:5924 +#: ../../library/stdtypes.rst:5934 msgid "" "This attribute is a lazily computed tuple (possibly empty) of unique type " "variables found in ``__args__``::" @@ -8740,7 +8753,7 @@ msgstr "" "此屬性是個會被延遲計算 (lazily computed) 的元組(可能為空),包含了在 " "``__args__`` 中找得到的不重複型別變數: ::" -#: ../../library/stdtypes.rst:5927 +#: ../../library/stdtypes.rst:5937 msgid "" ">>> from typing import TypeVar\n" "\n" @@ -8754,7 +8767,7 @@ msgstr "" ">>> list[T].__parameters__\n" "(~T,)" -#: ../../library/stdtypes.rst:5935 +#: ../../library/stdtypes.rst:5945 msgid "" "A ``GenericAlias`` object with :class:`typing.ParamSpec` parameters may not " "have correct ``__parameters__`` after substitution because :class:`typing." @@ -8764,7 +8777,7 @@ msgstr "" "有正確的 ``__parameters__``,因為 :class:`typing.ParamSpec` 主要用於靜態型別" "檢查。" -#: ../../library/stdtypes.rst:5942 +#: ../../library/stdtypes.rst:5952 msgid "" "A boolean that is true if the alias has been unpacked using the ``*`` " "operator (see :data:`~typing.TypeVarTuple`)." @@ -8772,19 +8785,19 @@ msgstr "" "如果別名已使用 ``*`` 運算子解包 (unpack) 則為 true 的布林值(請參閱 :data:" "`~typing.TypeVarTuple`\\ )。" -#: ../../library/stdtypes.rst:5950 +#: ../../library/stdtypes.rst:5960 msgid ":pep:`484` - Type Hints" msgstr ":pep:`484` - 型別提示" -#: ../../library/stdtypes.rst:5951 +#: ../../library/stdtypes.rst:5961 msgid "Introducing Python's framework for type annotations." msgstr "引入 Python 的型別註釋框架。" -#: ../../library/stdtypes.rst:5953 +#: ../../library/stdtypes.rst:5963 msgid ":pep:`585` - Type Hinting Generics In Standard Collections" msgstr ":pep:`585` - 標準集合 (Standard Collections) 中的型別提示泛型" -#: ../../library/stdtypes.rst:5954 +#: ../../library/stdtypes.rst:5964 msgid "" "Introducing the ability to natively parameterize standard-library classes, " "provided they implement the special class method :meth:`~object." @@ -8793,7 +8806,7 @@ msgstr "" "引入原生參數化標準函式庫類別的能力,前提是它們有實作特殊的類別方法 :meth:" "`~object.__class_getitem__`。" -#: ../../library/stdtypes.rst:5958 +#: ../../library/stdtypes.rst:5968 msgid "" ":ref:`Generics`, :ref:`user-defined generics ` and :" "class:`typing.Generic`" @@ -8801,18 +8814,18 @@ msgstr "" ":ref:`Generics`、:ref:`使用者定義泛型 `\\ 和 :class:" "`typing.Generic`" -#: ../../library/stdtypes.rst:5959 +#: ../../library/stdtypes.rst:5969 msgid "" "Documentation on how to implement generic classes that can be parameterized " "at runtime and understood by static type-checkers." msgstr "" "有關如何實作可以在 runtime 參數化並能被靜態型別檢查器理解的泛型類別的文件。" -#: ../../library/stdtypes.rst:5968 +#: ../../library/stdtypes.rst:5978 msgid "Union Type" msgstr "聯合型別 (Union Type)" -#: ../../library/stdtypes.rst:5974 +#: ../../library/stdtypes.rst:5984 msgid "" "A union object holds the value of the ``|`` (bitwise or) operation on " "multiple :ref:`type objects `. These types are intended " @@ -8825,7 +8838,7 @@ msgstr "" "釋 (type annotation) `。與下標 :data:`typing.Union` 相比,聯合型" "別運算式可以讓型別提示語法更清晰簡潔。" -#: ../../library/stdtypes.rst:5981 +#: ../../library/stdtypes.rst:5991 msgid "" "Defines a union object which holds types *X*, *Y*, and so forth. ``X | Y`` " "means either X or Y. It is equivalent to ``typing.Union[X, Y]``. For " @@ -8836,7 +8849,7 @@ msgstr "" "``typing.Union[X, Y]``。舉例來說,下列函式需要一個型別為 :class:`int` 或 :" "class:`float` 的引數: ::" -#: ../../library/stdtypes.rst:5986 +#: ../../library/stdtypes.rst:5996 msgid "" "def square(number: int | float) -> int | float:\n" " return number ** 2" @@ -8844,7 +8857,7 @@ msgstr "" "def square(number: int | float) -> int | float:\n" " return number ** 2" -#: ../../library/stdtypes.rst:5991 +#: ../../library/stdtypes.rst:6001 msgid "" "The ``|`` operand cannot be used at runtime to define unions where one or " "more members is a forward reference. For example, ``int | \"Foo\"``, where " @@ -8857,40 +8870,40 @@ msgstr "" "義類別的參照,將在 runtime 失敗。對於包含向前參照的聯合,請將整個運算式以字串" "呈現,例如 ``\"int | Foo\"``。" -#: ../../library/stdtypes.rst:5999 +#: ../../library/stdtypes.rst:6009 msgid "" "Union objects can be tested for equality with other union objects. Details:" msgstr "聯合物件可以與其他聯合物件一起進行相等性測試。細節如下:" -#: ../../library/stdtypes.rst:6001 +#: ../../library/stdtypes.rst:6011 msgid "Unions of unions are flattened::" msgstr "聯合的聯合會被扁平化: ::" -#: ../../library/stdtypes.rst:6003 +#: ../../library/stdtypes.rst:6013 msgid "(int | str) | float == int | str | float" msgstr "(int | str) | float == int | str | float" -#: ../../library/stdtypes.rst:6005 +#: ../../library/stdtypes.rst:6015 msgid "Redundant types are removed::" msgstr "冗餘型別會被刪除: ::" -#: ../../library/stdtypes.rst:6007 +#: ../../library/stdtypes.rst:6017 msgid "int | str | int == int | str" msgstr "int | str | int == int | str" -#: ../../library/stdtypes.rst:6009 +#: ../../library/stdtypes.rst:6019 msgid "When comparing unions, the order is ignored::" msgstr "比較聯合時,順序會被忽略: ::" -#: ../../library/stdtypes.rst:6011 +#: ../../library/stdtypes.rst:6021 msgid "int | str == str | int" msgstr "int | str == str | int" -#: ../../library/stdtypes.rst:6013 +#: ../../library/stdtypes.rst:6023 msgid "It creates instances of :class:`typing.Union`::" msgstr "它會建立 :class:`typing.Union` 的實例: ::" -#: ../../library/stdtypes.rst:6015 +#: ../../library/stdtypes.rst:6025 msgid "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" @@ -8898,21 +8911,21 @@ msgstr "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" -#: ../../library/stdtypes.rst:6018 +#: ../../library/stdtypes.rst:6028 msgid "Optional types can be spelled as a union with ``None``::" msgstr "可選型別可以表示為與 ``None`` 的聯合: ::" -#: ../../library/stdtypes.rst:6020 +#: ../../library/stdtypes.rst:6030 msgid "str | None == typing.Optional[str]" msgstr "str | None == typing.Optional[str]" -#: ../../library/stdtypes.rst:6025 +#: ../../library/stdtypes.rst:6035 msgid "" "Calls to :func:`isinstance` and :func:`issubclass` are also supported with a " "union object::" msgstr "聯合物件也支援 :func:`isinstance` 和 :func:`issubclass` 的呼叫: ::" -#: ../../library/stdtypes.rst:6028 +#: ../../library/stdtypes.rst:6038 msgid "" ">>> isinstance(\"\", int | str)\n" "True" @@ -8920,14 +8933,14 @@ msgstr "" ">>> isinstance(\"\", int | str)\n" "True" -#: ../../library/stdtypes.rst:6031 +#: ../../library/stdtypes.rst:6041 msgid "" "However, :ref:`parameterized generics ` in union objects " "cannot be checked::" msgstr "" "然而聯合物件中的\\ :ref:`參數化泛型 `\\ 則無法被檢查: ::" -#: ../../library/stdtypes.rst:6034 +#: ../../library/stdtypes.rst:6044 msgid "" ">>> isinstance(1, int | list[int]) # short-circuit evaluation\n" "True\n" @@ -8937,7 +8950,7 @@ msgid "" "TypeError: isinstance() argument 2 cannot be a parameterized generic" msgstr "" -#: ../../library/stdtypes.rst:6041 +#: ../../library/stdtypes.rst:6051 msgid "" "The user-exposed type for the union object can be accessed from :class:" "`typing.Union` and used for :func:`isinstance` checks::" @@ -8945,7 +8958,7 @@ msgstr "" "構成聯合物件的對使用者公開型別 (user-exposed type) 可以透過 :data:`typing." "Union` 存取並用於 :func:`isinstance` 檢查: ::" -#: ../../library/stdtypes.rst:6044 +#: ../../library/stdtypes.rst:6054 msgid "" ">>> import typing\n" ">>> isinstance(int | str, typing.Union)\n" @@ -8963,7 +8976,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: cannot create 'typing.Union' instances" -#: ../../library/stdtypes.rst:6053 +#: ../../library/stdtypes.rst:6063 msgid "" "The :meth:`!__or__` method for type objects was added to support the syntax " "``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may " @@ -8972,7 +8985,7 @@ msgstr "" "新增了型別物件的 :meth:`!__or__` 方法來支援 ``X | Y`` 語法。如果元類別有實" "作 :meth:`!__or__`,則 Union 可以覆寫 (override) 它: ::" -#: ../../library/stdtypes.rst:6057 +#: ../../library/stdtypes.rst:6067 msgid "" ">>> class M(type):\n" "... def __or__(self, other):\n" @@ -8998,32 +9011,32 @@ msgstr "" ">>> int | C\n" "int | C" -#: ../../library/stdtypes.rst:6073 +#: ../../library/stdtypes.rst:6083 msgid ":pep:`604` -- PEP proposing the ``X | Y`` syntax and the Union type." msgstr ":pep:`604` -- PEP 提出 ``X | Y`` 語法和聯合型別。" -#: ../../library/stdtypes.rst:6079 +#: ../../library/stdtypes.rst:6089 msgid "" "Union objects are now instances of :class:`typing.Union`. Previously, they " "were instances of :class:`types.UnionType`, which remains an alias for :" "class:`typing.Union`." msgstr "" -#: ../../library/stdtypes.rst:6086 +#: ../../library/stdtypes.rst:6096 msgid "Other Built-in Types" msgstr "其他內建型別" -#: ../../library/stdtypes.rst:6088 +#: ../../library/stdtypes.rst:6098 msgid "" "The interpreter supports several other kinds of objects. Most of these " "support only one or two operations." msgstr "" -#: ../../library/stdtypes.rst:6095 +#: ../../library/stdtypes.rst:6105 msgid "Modules" msgstr "模組" -#: ../../library/stdtypes.rst:6097 +#: ../../library/stdtypes.rst:6107 msgid "" "The only special operation on a module is attribute access: ``m.name``, " "where *m* is a module and *name* accesses a name defined in *m*'s symbol " @@ -9034,7 +9047,7 @@ msgid "" "*foo* somewhere.)" msgstr "" -#: ../../library/stdtypes.rst:6104 +#: ../../library/stdtypes.rst:6114 msgid "" "A special attribute of every module is :attr:`~object.__dict__`. This is the " "dictionary containing the module's symbol table. Modifying this dictionary " @@ -9045,32 +9058,32 @@ msgid "" "recommended." msgstr "" -#: ../../library/stdtypes.rst:6112 +#: ../../library/stdtypes.rst:6122 msgid "" "Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ````." msgstr "" -#: ../../library/stdtypes.rst:6120 +#: ../../library/stdtypes.rst:6130 msgid "Classes and Class Instances" msgstr "類別與類別實例" -#: ../../library/stdtypes.rst:6122 +#: ../../library/stdtypes.rst:6132 msgid "See :ref:`objects` and :ref:`class` for these." msgstr "請見 :ref:`objects` 和 :ref:`class`。" -#: ../../library/stdtypes.rst:6128 +#: ../../library/stdtypes.rst:6138 msgid "Functions" msgstr "函式" -#: ../../library/stdtypes.rst:6130 +#: ../../library/stdtypes.rst:6140 msgid "" "Function objects are created by function definitions. The only operation on " "a function object is to call it: ``func(argument-list)``." msgstr "" -#: ../../library/stdtypes.rst:6133 +#: ../../library/stdtypes.rst:6143 msgid "" "There are really two flavors of function objects: built-in functions and " "user-defined functions. Both support the same operation (to call the " @@ -9078,15 +9091,15 @@ msgid "" "types." msgstr "" -#: ../../library/stdtypes.rst:6137 +#: ../../library/stdtypes.rst:6147 msgid "See :ref:`function` for more information." msgstr "更多資訊請見 :ref:`function`。" -#: ../../library/stdtypes.rst:6143 +#: ../../library/stdtypes.rst:6153 msgid "Methods" msgstr "方法" -#: ../../library/stdtypes.rst:6147 +#: ../../library/stdtypes.rst:6157 msgid "" "Methods are functions that are called using the attribute notation. There " "are two flavors: :ref:`built-in methods ` (such as :meth:" @@ -9094,7 +9107,7 @@ msgid "" "methods>`. Built-in methods are described with the types that support them." msgstr "" -#: ../../library/stdtypes.rst:6153 +#: ../../library/stdtypes.rst:6163 msgid "" "If you access a method (a function defined in a class namespace) through an " "instance, you get a special object: a :dfn:`bound method` (also called :ref:" @@ -9107,7 +9120,7 @@ msgid "" "arg-2, ..., arg-n)``." msgstr "" -#: ../../library/stdtypes.rst:6164 +#: ../../library/stdtypes.rst:6174 msgid "" "Like :ref:`function objects `, bound method objects " "support getting arbitrary attributes. However, since method attributes are " @@ -9118,7 +9131,7 @@ msgid "" "underlying function object:" msgstr "" -#: ../../library/stdtypes.rst:6172 +#: ../../library/stdtypes.rst:6182 msgid "" ">>> class C:\n" "... def method(self):\n" @@ -9146,15 +9159,15 @@ msgstr "" ">>> c.method.whoami\n" "'my name is method'" -#: ../../library/stdtypes.rst:6187 +#: ../../library/stdtypes.rst:6197 msgid "See :ref:`instance-methods` for more information." msgstr "更多資訊請見 :ref:`instance-methods`。" -#: ../../library/stdtypes.rst:6195 +#: ../../library/stdtypes.rst:6205 msgid "Code Objects" msgstr "程式碼物件" -#: ../../library/stdtypes.rst:6201 +#: ../../library/stdtypes.rst:6211 msgid "" "Code objects are used by the implementation to represent \"pseudo-compiled\" " "executable Python code such as a function body. They differ from function " @@ -9164,7 +9177,7 @@ msgid "" "`~function.__code__` attribute. See also the :mod:`code` module." msgstr "" -#: ../../library/stdtypes.rst:6208 +#: ../../library/stdtypes.rst:6218 msgid "" "Accessing :attr:`~function.__code__` raises an :ref:`auditing event " "` ``object.__getattr__`` with arguments ``obj`` and " @@ -9173,21 +9186,21 @@ msgstr "" "存取 :attr:`~function.__code__` 會引發一個附帶引數 ``obj`` 與 " "``\"__code__\"`` 的\\ :ref:`稽核事件 ` ``object.__getattr__``。" -#: ../../library/stdtypes.rst:6215 +#: ../../library/stdtypes.rst:6225 msgid "" "A code object can be executed or evaluated by passing it (instead of a " "source string) to the :func:`exec` or :func:`eval` built-in functions." msgstr "" -#: ../../library/stdtypes.rst:6218 +#: ../../library/stdtypes.rst:6228 msgid "See :ref:`types` for more information." msgstr "更多資訊請見 :ref:`types`。" -#: ../../library/stdtypes.rst:6224 +#: ../../library/stdtypes.rst:6234 msgid "Type Objects" msgstr "" -#: ../../library/stdtypes.rst:6230 +#: ../../library/stdtypes.rst:6240 msgid "" "Type objects represent the various object types. An object's type is " "accessed by the built-in function :func:`type`. There are no special " @@ -9195,30 +9208,30 @@ msgid "" "standard built-in types." msgstr "" -#: ../../library/stdtypes.rst:6235 +#: ../../library/stdtypes.rst:6245 msgid "Types are written like this: ````." msgstr "" -#: ../../library/stdtypes.rst:6241 +#: ../../library/stdtypes.rst:6251 msgid "The Null Object" msgstr "Null 物件" -#: ../../library/stdtypes.rst:6243 +#: ../../library/stdtypes.rst:6253 msgid "" "This object is returned by functions that don't explicitly return a value. " "It supports no special operations. There is exactly one null object, named " "``None`` (a built-in name). ``type(None)()`` produces the same singleton." msgstr "" -#: ../../library/stdtypes.rst:6247 +#: ../../library/stdtypes.rst:6257 msgid "It is written as ``None``." msgstr "它被寫為 ``None``。" -#: ../../library/stdtypes.rst:6254 +#: ../../library/stdtypes.rst:6264 msgid "The Ellipsis Object" msgstr "Ellipsis 物件" -#: ../../library/stdtypes.rst:6256 +#: ../../library/stdtypes.rst:6266 msgid "" "This object is commonly used to indicate that something is omitted. It " "supports no special operations. There is exactly one ellipsis object, " @@ -9226,63 +9239,63 @@ msgid "" "the :const:`Ellipsis` singleton." msgstr "" -#: ../../library/stdtypes.rst:6261 +#: ../../library/stdtypes.rst:6271 msgid "It is written as ``Ellipsis`` or ``...``." msgstr "它被寫為 ``Ellipsis`` 或 ``...``。" -#: ../../library/stdtypes.rst:6263 +#: ../../library/stdtypes.rst:6273 msgid "" "In typical use, ``...`` as the ``Ellipsis`` object appears in a few " "different places, for instance:" msgstr "" -#: ../../library/stdtypes.rst:6266 +#: ../../library/stdtypes.rst:6276 msgid "" "In type annotations, such as :ref:`callable arguments ` or :ref:`tuple elements `." msgstr "" -#: ../../library/stdtypes.rst:6269 +#: ../../library/stdtypes.rst:6279 msgid "" "As the body of a function instead of a :ref:`pass statement `." msgstr "" -#: ../../library/stdtypes.rst:6271 +#: ../../library/stdtypes.rst:6281 msgid "" "In third-party libraries, such as `Numpy's slicing and striding `_." msgstr "" -#: ../../library/stdtypes.rst:6274 +#: ../../library/stdtypes.rst:6284 msgid "" "Python also uses three dots in ways that are not ``Ellipsis`` objects, for " "instance:" msgstr "" -#: ../../library/stdtypes.rst:6276 +#: ../../library/stdtypes.rst:6286 msgid "" "Doctest's :const:`ELLIPSIS `, as a pattern for missing " "content." msgstr "" -#: ../../library/stdtypes.rst:6278 +#: ../../library/stdtypes.rst:6288 msgid "" "The default Python prompt of the :term:`interactive` shell when partial " "input is incomplete." msgstr "" -#: ../../library/stdtypes.rst:6280 +#: ../../library/stdtypes.rst:6290 msgid "" "Lastly, the Python documentation often uses three dots in conventional " "English usage to mean omitted content, even in code examples that also use " "them as the ``Ellipsis``." msgstr "" -#: ../../library/stdtypes.rst:6288 +#: ../../library/stdtypes.rst:6298 msgid "The NotImplemented Object" msgstr "NotImplemented 物件" -#: ../../library/stdtypes.rst:6290 +#: ../../library/stdtypes.rst:6300 msgid "" "This object is returned from comparisons and binary operations when they are " "asked to operate on types they don't support. See :ref:`comparisons` for " @@ -9290,64 +9303,64 @@ msgid "" "`type(NotImplemented)()` produces the singleton instance." msgstr "" -#: ../../library/stdtypes.rst:6295 +#: ../../library/stdtypes.rst:6305 msgid "It is written as :code:`NotImplemented`." msgstr "它被寫為 :code:`NotImplemented`。" -#: ../../library/stdtypes.rst:6301 +#: ../../library/stdtypes.rst:6311 msgid "Internal Objects" msgstr "內部物件" -#: ../../library/stdtypes.rst:6303 +#: ../../library/stdtypes.rst:6313 msgid "" "See :ref:`types` for this information. It describes :ref:`stack frame " "objects `, :ref:`traceback objects `, and " "slice objects." msgstr "" -#: ../../library/stdtypes.rst:6311 +#: ../../library/stdtypes.rst:6321 msgid "Special Attributes" msgstr "特殊屬性" -#: ../../library/stdtypes.rst:6313 +#: ../../library/stdtypes.rst:6323 msgid "" "The implementation adds a few special read-only attributes to several object " "types, where they are relevant. Some of these are not reported by the :func:" "`dir` built-in function." msgstr "" -#: ../../library/stdtypes.rst:6320 +#: ../../library/stdtypes.rst:6330 msgid "" "The name of the class, function, method, descriptor, or generator instance." msgstr "" -#: ../../library/stdtypes.rst:6326 +#: ../../library/stdtypes.rst:6336 msgid "" "The :term:`qualified name` of the class, function, method, descriptor, or " "generator instance." msgstr "" -#: ../../library/stdtypes.rst:6334 +#: ../../library/stdtypes.rst:6344 msgid "The name of the module in which a class or function was defined." msgstr "" -#: ../../library/stdtypes.rst:6339 +#: ../../library/stdtypes.rst:6349 msgid "" "The documentation string of a class or function, or ``None`` if undefined." msgstr "" -#: ../../library/stdtypes.rst:6344 +#: ../../library/stdtypes.rst:6354 msgid "" "The :ref:`type parameters ` of generic classes, functions, and :" "ref:`type aliases `. For classes and functions that are not " "generic, this will be an empty tuple." msgstr "" -#: ../../library/stdtypes.rst:6354 +#: ../../library/stdtypes.rst:6364 msgid "Integer string conversion length limitation" msgstr "整數字串轉換長度限制" -#: ../../library/stdtypes.rst:6356 +#: ../../library/stdtypes.rst:6366 msgid "" "CPython has a global limit for converting between :class:`int` and :class:" "`str` to mitigate denial of service attacks. This limit *only* applies to " @@ -9359,7 +9372,7 @@ msgstr "" "進位的數值。十六進位、八進位,還有二進位的轉換則沒有長度限制。此限制值可以被" "調整。" -#: ../../library/stdtypes.rst:6361 +#: ../../library/stdtypes.rst:6371 msgid "" "The :class:`int` type in CPython is an arbitrary length number stored in " "binary form (commonly known as a \"bignum\"). There exists no algorithm that " @@ -9369,24 +9382,24 @@ msgid "" "value such as ``int('1' * 500_000)`` can take over a second on a fast CPU." msgstr "" -#: ../../library/stdtypes.rst:6368 +#: ../../library/stdtypes.rst:6378 msgid "" "Limiting conversion size offers a practical way to avoid :cve:`2020-10735`." msgstr "" -#: ../../library/stdtypes.rst:6370 +#: ../../library/stdtypes.rst:6380 msgid "" "The limit is applied to the number of digit characters in the input or " "output string when a non-linear conversion algorithm would be involved. " "Underscores and the sign are not counted towards the limit." msgstr "" -#: ../../library/stdtypes.rst:6374 +#: ../../library/stdtypes.rst:6384 msgid "" "When an operation would exceed the limit, a :exc:`ValueError` is raised:" msgstr "" -#: ../../library/stdtypes.rst:6376 +#: ../../library/stdtypes.rst:6386 msgid "" ">>> import sys\n" ">>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default.\n" @@ -9410,7 +9423,7 @@ msgid "" ">>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited." msgstr "" -#: ../../library/stdtypes.rst:6396 +#: ../../library/stdtypes.rst:6406 msgid "" "The default limit is 4300 digits as provided in :data:`sys.int_info." "default_max_str_digits `. The lowest limit that can be " @@ -9418,11 +9431,11 @@ msgid "" "str_digits_check_threshold `." msgstr "" -#: ../../library/stdtypes.rst:6401 +#: ../../library/stdtypes.rst:6411 msgid "Verification:" msgstr "" -#: ../../library/stdtypes.rst:6403 +#: ../../library/stdtypes.rst:6413 msgid "" ">>> import sys\n" ">>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info\n" @@ -9440,11 +9453,11 @@ msgstr "" "... '571186405732').to_bytes(53, 'big')\n" "..." -#: ../../library/stdtypes.rst:6416 +#: ../../library/stdtypes.rst:6426 msgid "Affected APIs" msgstr "受影響的 API" -#: ../../library/stdtypes.rst:6418 +#: ../../library/stdtypes.rst:6428 msgid "" "The limitation only applies to potentially slow conversions between :class:" "`int` and :class:`str` or :class:`bytes`:" @@ -9452,74 +9465,74 @@ msgstr "" "此限制僅適用於 :class:`int` 與 :class:`str` 或 :class:`bytes` 之間可能較慢的" "轉換:" -#: ../../library/stdtypes.rst:6421 +#: ../../library/stdtypes.rst:6431 msgid "``int(string)`` with default base 10." msgstr "``int(string)`` 以預設的 10 為底。" -#: ../../library/stdtypes.rst:6422 +#: ../../library/stdtypes.rst:6432 msgid "``int(string, base)`` for all bases that are not a power of 2." msgstr "``int(string, base)`` 用於所有非 2 冪次方的底。" -#: ../../library/stdtypes.rst:6423 +#: ../../library/stdtypes.rst:6433 msgid "``str(integer)``." msgstr "``str(integer)``。" -#: ../../library/stdtypes.rst:6424 +#: ../../library/stdtypes.rst:6434 msgid "``repr(integer)``." msgstr "``repr(integer)``。" -#: ../../library/stdtypes.rst:6425 +#: ../../library/stdtypes.rst:6435 msgid "" "any other string conversion to base 10, for example ``f\"{integer}\"``, " "``\"{}\".format(integer)``, or ``b\"%d\" % integer``." msgstr "" -#: ../../library/stdtypes.rst:6428 +#: ../../library/stdtypes.rst:6438 msgid "The limitations do not apply to functions with a linear algorithm:" msgstr "" -#: ../../library/stdtypes.rst:6430 +#: ../../library/stdtypes.rst:6440 msgid "``int(string, base)`` with base 2, 4, 8, 16, or 32." msgstr "``int(string, base)`` 以 2、4、8、16 或 32 為底。" -#: ../../library/stdtypes.rst:6431 +#: ../../library/stdtypes.rst:6441 msgid ":func:`int.from_bytes` and :func:`int.to_bytes`." msgstr ":func:`int.from_bytes` 和 :func:`int.to_bytes`。" -#: ../../library/stdtypes.rst:6432 +#: ../../library/stdtypes.rst:6442 msgid ":func:`hex`, :func:`oct`, :func:`bin`." msgstr ":func:`hex`、:func:`oct`、:func:`bin`。" -#: ../../library/stdtypes.rst:6433 +#: ../../library/stdtypes.rst:6443 msgid ":ref:`formatspec` for hex, octal, and binary numbers." msgstr ":ref:`formatspec` 用於十六進位、八進位和二進位數字。" -#: ../../library/stdtypes.rst:6434 +#: ../../library/stdtypes.rst:6444 msgid ":class:`str` to :class:`float`." msgstr ":class:`str` 轉換為 :class:`float`。" -#: ../../library/stdtypes.rst:6435 +#: ../../library/stdtypes.rst:6445 msgid ":class:`str` to :class:`decimal.Decimal`." msgstr ":class:`str` 轉換為 :class:`decimal.Decimal`。" -#: ../../library/stdtypes.rst:6438 +#: ../../library/stdtypes.rst:6448 msgid "Configuring the limit" msgstr "設定限制" -#: ../../library/stdtypes.rst:6440 +#: ../../library/stdtypes.rst:6450 msgid "" "Before Python starts up you can use an environment variable or an " "interpreter command line flag to configure the limit:" msgstr "" -#: ../../library/stdtypes.rst:6443 +#: ../../library/stdtypes.rst:6453 msgid "" ":envvar:`PYTHONINTMAXSTRDIGITS`, e.g. ``PYTHONINTMAXSTRDIGITS=640 python3`` " "to set the limit to 640 or ``PYTHONINTMAXSTRDIGITS=0 python3`` to disable " "the limitation." msgstr "" -#: ../../library/stdtypes.rst:6446 +#: ../../library/stdtypes.rst:6456 msgid "" ":option:`-X int_max_str_digits <-X>`, e.g. ``python3 -X " "int_max_str_digits=640``" @@ -9527,7 +9540,7 @@ msgstr "" ":option:`-X int_max_str_digits <-X>`,例如 ``python3 -X " "int_max_str_digits=640``" -#: ../../library/stdtypes.rst:6448 +#: ../../library/stdtypes.rst:6458 msgid "" ":data:`sys.flags.int_max_str_digits` contains the value of :envvar:" "`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`. If both the " @@ -9536,38 +9549,38 @@ msgid "" "int_info.default_max_str_digits` was used during initialization." msgstr "" -#: ../../library/stdtypes.rst:6454 +#: ../../library/stdtypes.rst:6464 msgid "" "From code, you can inspect the current limit and set a new one using these :" "mod:`sys` APIs:" msgstr "" -#: ../../library/stdtypes.rst:6457 +#: ../../library/stdtypes.rst:6467 msgid "" ":func:`sys.get_int_max_str_digits` and :func:`sys.set_int_max_str_digits` " "are a getter and setter for the interpreter-wide limit. Subinterpreters have " "their own limit." msgstr "" -#: ../../library/stdtypes.rst:6461 +#: ../../library/stdtypes.rst:6471 msgid "" "Information about the default and minimum can be found in :data:`sys." "int_info`:" msgstr "" -#: ../../library/stdtypes.rst:6463 +#: ../../library/stdtypes.rst:6473 msgid "" ":data:`sys.int_info.default_max_str_digits ` is the compiled-" "in default limit." msgstr "" -#: ../../library/stdtypes.rst:6465 +#: ../../library/stdtypes.rst:6475 msgid "" ":data:`sys.int_info.str_digits_check_threshold ` is the lowest " "accepted value for the limit (other than 0 which disables it)." msgstr "" -#: ../../library/stdtypes.rst:6472 +#: ../../library/stdtypes.rst:6482 msgid "" "Setting a low limit *can* lead to problems. While rare, code exists that " "contains integer constants in decimal in their source that exceed the " @@ -9579,7 +9592,7 @@ msgid "" "constants is to convert them to ``0x`` hexadecimal form as it has no limit." msgstr "" -#: ../../library/stdtypes.rst:6481 +#: ../../library/stdtypes.rst:6491 msgid "" "Test your application thoroughly if you use a low limit. Ensure your tests " "run with the limit set early via the environment or flag so that it applies " @@ -9587,11 +9600,11 @@ msgid "" "to precompile ``.py`` sources to ``.pyc`` files." msgstr "" -#: ../../library/stdtypes.rst:6487 +#: ../../library/stdtypes.rst:6497 msgid "Recommended configuration" msgstr "建議的配置" -#: ../../library/stdtypes.rst:6489 +#: ../../library/stdtypes.rst:6499 msgid "" "The default :data:`sys.int_info.default_max_str_digits` is expected to be " "reasonable for most applications. If your application requires a different " @@ -9599,11 +9612,11 @@ msgid "" "as these APIs were added in security patch releases in versions before 3.12." msgstr "" -#: ../../library/stdtypes.rst:6494 +#: ../../library/stdtypes.rst:6504 msgid "Example::" msgstr "範例: ::" -#: ../../library/stdtypes.rst:6496 +#: ../../library/stdtypes.rst:6506 msgid "" ">>> import sys\n" ">>> if hasattr(sys, \"set_int_max_str_digits\"):\n" @@ -9625,38 +9638,38 @@ msgstr "" "... elif current_limit < lower_bound:\n" "... sys.set_int_max_str_digits(lower_bound)" -#: ../../library/stdtypes.rst:6506 +#: ../../library/stdtypes.rst:6516 msgid "If you need to disable it entirely, set it to ``0``." msgstr "" -#: ../../library/stdtypes.rst:6510 +#: ../../library/stdtypes.rst:6520 msgid "Footnotes" msgstr "註腳" -#: ../../library/stdtypes.rst:6511 +#: ../../library/stdtypes.rst:6521 msgid "" "Additional information on these special methods may be found in the Python " "Reference Manual (:ref:`customization`)." msgstr "" -#: ../../library/stdtypes.rst:6514 +#: ../../library/stdtypes.rst:6524 msgid "" "As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, " "and similarly for tuples." msgstr "" -#: ../../library/stdtypes.rst:6517 +#: ../../library/stdtypes.rst:6527 msgid "They must have since the parser can't tell the type of the operands." msgstr "" -#: ../../library/stdtypes.rst:6519 +#: ../../library/stdtypes.rst:6529 msgid "" "Cased characters are those with general category property being one of " "\"Lu\" (Letter, uppercase), \"Ll\" (Letter, lowercase), or \"Lt\" (Letter, " "titlecase)." msgstr "" -#: ../../library/stdtypes.rst:6522 +#: ../../library/stdtypes.rst:6532 msgid "" "To format only a tuple you should therefore provide a singleton tuple whose " "only element is the tuple to be formatted." @@ -9669,13 +9682,13 @@ msgstr "built-in(內建)" #: ../../library/stdtypes.rst:13 ../../library/stdtypes.rst:332 #: ../../library/stdtypes.rst:409 ../../library/stdtypes.rst:1002 #: ../../library/stdtypes.rst:1192 ../../library/stdtypes.rst:1214 -#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:5224 -#: ../../library/stdtypes.rst:6226 +#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:5234 +#: ../../library/stdtypes.rst:6236 msgid "types" msgstr "type(型別)" #: ../../library/stdtypes.rst:34 ../../library/stdtypes.rst:1229 -#: ../../library/stdtypes.rst:5224 +#: ../../library/stdtypes.rst:5234 msgid "statement" msgstr "statement(陳述式)" @@ -9798,10 +9811,10 @@ msgstr "is not" #: ../../library/stdtypes.rst:1463 ../../library/stdtypes.rst:1507 #: ../../library/stdtypes.rst:1628 ../../library/stdtypes.rst:1758 #: ../../library/stdtypes.rst:3245 ../../library/stdtypes.rst:3264 -#: ../../library/stdtypes.rst:3377 ../../library/stdtypes.rst:5013 -#: ../../library/stdtypes.rst:5224 ../../library/stdtypes.rst:5713 -#: ../../library/stdtypes.rst:5970 ../../library/stdtypes.rst:6145 -#: ../../library/stdtypes.rst:6190 +#: ../../library/stdtypes.rst:3377 ../../library/stdtypes.rst:5018 +#: ../../library/stdtypes.rst:5234 ../../library/stdtypes.rst:5723 +#: ../../library/stdtypes.rst:5980 ../../library/stdtypes.rst:6155 +#: ../../library/stdtypes.rst:6200 msgid "object" msgstr "object(物件)" @@ -9893,9 +9906,9 @@ msgid "arithmetic" msgstr "arithmetic(算術)" #: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:1002 -#: ../../library/stdtypes.rst:1192 ../../library/stdtypes.rst:5224 -#: ../../library/stdtypes.rst:6197 ../../library/stdtypes.rst:6211 -#: ../../library/stdtypes.rst:6226 +#: ../../library/stdtypes.rst:1192 ../../library/stdtypes.rst:5234 +#: ../../library/stdtypes.rst:6207 ../../library/stdtypes.rst:6221 +#: ../../library/stdtypes.rst:6236 msgid "built-in function" msgstr "built-in function(內建函式)" @@ -9912,7 +9925,7 @@ msgid "complex" msgstr "complex(複數)" #: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3117 -#: ../../library/stdtypes.rst:4381 +#: ../../library/stdtypes.rst:4386 msgid "+ (plus)" msgstr "+ (加號)" @@ -9925,12 +9938,12 @@ msgid "binary operator" msgstr "binary operator(二元運算子)" #: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3117 -#: ../../library/stdtypes.rst:4381 +#: ../../library/stdtypes.rst:4386 msgid "- (minus)" msgstr "- (減號)" #: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3074 -#: ../../library/stdtypes.rst:4338 +#: ../../library/stdtypes.rst:4343 msgid "* (asterisk)" msgstr "* (星號)" @@ -9943,7 +9956,7 @@ msgid "//" msgstr "//" #: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3037 -#: ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:4311 msgid "% (percent)" msgstr "% (百分號)" @@ -9953,7 +9966,7 @@ msgstr "**" #: ../../library/stdtypes.rst:332 ../../library/stdtypes.rst:409 #: ../../library/stdtypes.rst:1002 ../../library/stdtypes.rst:1229 -#: ../../library/stdtypes.rst:5224 +#: ../../library/stdtypes.rst:5234 msgid "operations on" msgstr "operations on(操作於)" @@ -9962,7 +9975,7 @@ msgid "conjugate() (complex number method)" msgstr "conjugate()(複數方法)" #: ../../library/stdtypes.rst:351 ../../library/stdtypes.rst:1826 -#: ../../library/stdtypes.rst:3245 ../../library/stdtypes.rst:6226 +#: ../../library/stdtypes.rst:3245 ../../library/stdtypes.rst:6236 msgid "module" msgstr "模組" @@ -10030,7 +10043,7 @@ msgstr "values" msgid "iterator protocol" msgstr "iterator protocol(疊代器協定)" -#: ../../library/stdtypes.rst:899 ../../library/stdtypes.rst:5626 +#: ../../library/stdtypes.rst:899 ../../library/stdtypes.rst:5636 msgid "protocol" msgstr "protocol(協定)" @@ -10056,7 +10069,7 @@ msgstr "container(容器)" msgid "iteration over" msgstr "iteration over(疊代於)" -#: ../../library/stdtypes.rst:1002 ../../library/stdtypes.rst:5224 +#: ../../library/stdtypes.rst:1002 ../../library/stdtypes.rst:5234 msgid "len" msgstr "len" @@ -10126,13 +10139,13 @@ msgid "list" msgstr "list(串列)" #: ../../library/stdtypes.rst:1214 ../../library/stdtypes.rst:3245 -#: ../../library/stdtypes.rst:3377 ../../library/stdtypes.rst:3487 -#: ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:3377 ../../library/stdtypes.rst:3492 +#: ../../library/stdtypes.rst:4311 msgid "bytearray" msgstr "bytearray(位元組陣列)" -#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:5224 -#: ../../library/stdtypes.rst:5970 ../../library/stdtypes.rst:6226 +#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:5234 +#: ../../library/stdtypes.rst:5980 ../../library/stdtypes.rst:6236 msgid "type" msgstr "type(型別)" @@ -10140,7 +10153,7 @@ msgstr "type(型別)" msgid "assignment" msgstr "assignment(賦值)" -#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:5224 +#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:5234 msgid "del" msgstr "del" @@ -10176,12 +10189,12 @@ msgid "buffer protocol" msgstr "buffer protocol(緩衝區協定)" #: ../../library/stdtypes.rst:1791 ../../library/stdtypes.rst:3245 -#: ../../library/stdtypes.rst:3264 ../../library/stdtypes.rst:3487 -#: ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:3264 ../../library/stdtypes.rst:3492 +#: ../../library/stdtypes.rst:4311 msgid "bytes" msgstr "bytes(位元組)" -#: ../../library/stdtypes.rst:1818 ../../library/stdtypes.rst:3487 +#: ../../library/stdtypes.rst:1818 ../../library/stdtypes.rst:3492 msgid "methods" msgstr "methods(方法)" @@ -10189,7 +10202,7 @@ msgstr "methods(方法)" msgid "re" msgstr "re" -#: ../../library/stdtypes.rst:2651 ../../library/stdtypes.rst:4160 +#: ../../library/stdtypes.rst:2651 ../../library/stdtypes.rst:4165 msgid "universal newlines" msgstr "universal newlines" @@ -10269,32 +10282,32 @@ msgstr "formatting(格式化)、printf" msgid "interpolation, printf" msgstr "interpolation(插值)、printf" -#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:4311 msgid "printf-style formatting" msgstr "printf 風格格式化" -#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:4311 msgid "sprintf-style formatting" msgstr "sprintf 風格格式化" -#: ../../library/stdtypes.rst:3074 ../../library/stdtypes.rst:4338 +#: ../../library/stdtypes.rst:3074 ../../library/stdtypes.rst:4343 msgid "() (parentheses)" msgstr "() (圓括號)" #: ../../library/stdtypes.rst:3074 ../../library/stdtypes.rst:3117 -#: ../../library/stdtypes.rst:4338 ../../library/stdtypes.rst:4381 +#: ../../library/stdtypes.rst:4343 ../../library/stdtypes.rst:4386 msgid "in printf-style formatting" msgstr "於 printf 風格格式化" -#: ../../library/stdtypes.rst:3074 ../../library/stdtypes.rst:4338 +#: ../../library/stdtypes.rst:3074 ../../library/stdtypes.rst:4343 msgid ". (dot)" msgstr ". (點)" -#: ../../library/stdtypes.rst:3117 ../../library/stdtypes.rst:4381 +#: ../../library/stdtypes.rst:3117 ../../library/stdtypes.rst:4386 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/stdtypes.rst:3117 ../../library/stdtypes.rst:4381 +#: ../../library/stdtypes.rst:3117 ../../library/stdtypes.rst:4386 msgid "space" msgstr "space(空白)" @@ -10310,118 +10323,118 @@ msgstr "memoryview(記憶體視圖)" msgid "array" msgstr "array(陣列)" -#: ../../library/stdtypes.rst:4160 +#: ../../library/stdtypes.rst:4165 msgid "bytes.splitlines method" msgstr "bytes.splitlines 方法" -#: ../../library/stdtypes.rst:4160 +#: ../../library/stdtypes.rst:4165 msgid "bytearray.splitlines method" msgstr "bytearray.splitlines 方法" -#: ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:4311 msgid "formatting" msgstr "formatting(格式化)" -#: ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:4311 msgid "bytes (%)" msgstr "bytes (%)" -#: ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:4311 msgid "bytearray (%)" msgstr "bytearray (%)" -#: ../../library/stdtypes.rst:4306 +#: ../../library/stdtypes.rst:4311 msgid "interpolation" msgstr "interpolation(插值)" -#: ../../library/stdtypes.rst:5013 +#: ../../library/stdtypes.rst:5018 msgid "set" msgstr "set(集合)" -#: ../../library/stdtypes.rst:5224 +#: ../../library/stdtypes.rst:5234 msgid "mapping" msgstr "mapping(對映)" -#: ../../library/stdtypes.rst:5224 +#: ../../library/stdtypes.rst:5234 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../library/stdtypes.rst:5331 +#: ../../library/stdtypes.rst:5341 msgid "__missing__()" msgstr "__missing__()" -#: ../../library/stdtypes.rst:5626 +#: ../../library/stdtypes.rst:5636 msgid "context manager" msgstr "context manager(情境管理器)" -#: ../../library/stdtypes.rst:5626 +#: ../../library/stdtypes.rst:5636 msgid "context management protocol" msgstr "context management protocol(情境管理協定)" -#: ../../library/stdtypes.rst:5626 +#: ../../library/stdtypes.rst:5636 msgid "context management" msgstr "context management(情境管理)" -#: ../../library/stdtypes.rst:5701 +#: ../../library/stdtypes.rst:5711 msgid "annotation" msgstr "annotation(註記)" -#: ../../library/stdtypes.rst:5701 +#: ../../library/stdtypes.rst:5711 msgid "type annotation; type hint" msgstr "type annotation(型別註記);type hint(型別提示)" -#: ../../library/stdtypes.rst:5713 +#: ../../library/stdtypes.rst:5723 msgid "GenericAlias" msgstr "GenericAlias(泛型別名)" -#: ../../library/stdtypes.rst:5713 +#: ../../library/stdtypes.rst:5723 msgid "Generic" msgstr "Generic(泛型)" -#: ../../library/stdtypes.rst:5713 +#: ../../library/stdtypes.rst:5723 msgid "Alias" msgstr "Alias(別名)" -#: ../../library/stdtypes.rst:5970 +#: ../../library/stdtypes.rst:5980 msgid "Union" msgstr "Union(聯合)" -#: ../../library/stdtypes.rst:5970 +#: ../../library/stdtypes.rst:5980 msgid "union" msgstr "union(聯集)" -#: ../../library/stdtypes.rst:6145 +#: ../../library/stdtypes.rst:6155 msgid "method" msgstr "method(方法)" -#: ../../library/stdtypes.rst:6190 +#: ../../library/stdtypes.rst:6200 msgid "code" msgstr "code(程式碼)" -#: ../../library/stdtypes.rst:6190 +#: ../../library/stdtypes.rst:6200 msgid "code object" msgstr "code object(程式碼物件)" -#: ../../library/stdtypes.rst:6197 +#: ../../library/stdtypes.rst:6207 msgid "compile" msgstr "compile(編譯)" -#: ../../library/stdtypes.rst:6197 +#: ../../library/stdtypes.rst:6207 msgid "__code__ (function object attribute)" msgstr "__code__(函式物件屬性)" -#: ../../library/stdtypes.rst:6211 +#: ../../library/stdtypes.rst:6221 msgid "exec" msgstr "exec" -#: ../../library/stdtypes.rst:6211 +#: ../../library/stdtypes.rst:6221 msgid "eval" msgstr "eval" -#: ../../library/stdtypes.rst:6250 +#: ../../library/stdtypes.rst:6260 msgid "..." msgstr "..." -#: ../../library/stdtypes.rst:6250 +#: ../../library/stdtypes.rst:6260 msgid "ellipsis literal" msgstr "ellipsis literal(刪節號字面值)" diff --git a/library/threadsafety.po b/library/threadsafety.po index 8b6b8bdd9d0..87958080f86 100644 --- a/library/threadsafety.po +++ b/library/threadsafety.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-13 00:19+0000\n" +"POT-Creation-Date: 2026-03-16 00:22+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -419,7 +419,8 @@ msgid "" "result locked" msgstr "" -#: ../../library/threadsafety.rst:301 +#: ../../library/threadsafety.rst:301 ../../library/threadsafety.rst:434 +#: ../../library/threadsafety.rst:525 msgid "" "Operations that involve multiple accesses, as well as iteration, are never " "atomic:" @@ -475,3 +476,282 @@ msgid "" "Consider external synchronization when sharing :class:`dict` instances " "across threads." msgstr "" + +#: ../../library/threadsafety.rst:350 +#, fuzzy +msgid "Thread safety for set objects" +msgstr "執行緒安全等級" + +#: ../../library/threadsafety.rst:352 ../../library/threadsafety.rst:457 +msgid "" +"The :func:`len` function is lock-free and :term:`atomic `." +msgstr "" + +#: ../../library/threadsafety.rst:354 +msgid "" +"The following read operation is lock-free. It does not block concurrent " +"modifications and may observe intermediate states from operations that hold " +"the per-object lock:" +msgstr "" + +#: ../../library/threadsafety.rst:358 +msgid "elem in s # set.__contains__" +msgstr "" + +#: ../../library/threadsafety.rst:363 +msgid "" +"This operation may compare elements using :meth:`~object.__eq__`, which can " +"execute arbitrary Python code. During such comparisons, the set may be " +"modified by another thread. For built-in types like :class:`str`, :class:" +"`int`, and :class:`float`, :meth:`!__eq__` does not release the underlying " +"lock during comparisons and this is not a concern." +msgstr "" + +#: ../../library/threadsafety.rst:369 ../../library/threadsafety.rst:470 +msgid "All other operations from here on hold the per-object lock." +msgstr "" + +#: ../../library/threadsafety.rst:371 +msgid "" +"Adding or removing a single element is safe to call from multiple threads " +"and will not corrupt the set:" +msgstr "" + +#: ../../library/threadsafety.rst:374 +msgid "" +"s.add(elem) # add element\n" +"s.remove(elem) # remove element, raise if missing\n" +"s.discard(elem) # remove element if present\n" +"s.pop() # remove and return arbitrary element" +msgstr "" + +#: ../../library/threadsafety.rst:382 +msgid "" +"These operations also compare elements, so the same :meth:`~object.__eq__` " +"considerations as above apply." +msgstr "" + +#: ../../library/threadsafety.rst:385 +msgid "" +"The :meth:`~set.copy` method returns a new object and holds the per-object " +"lock for the duration so that it is always atomic." +msgstr "" + +#: ../../library/threadsafety.rst:388 +msgid "" +"The :meth:`~set.clear` method holds the lock for its duration. Other threads " +"cannot observe elements being removed." +msgstr "" + +#: ../../library/threadsafety.rst:391 +msgid "" +"The following operations only accept :class:`set` or :class:`frozenset` as " +"operands and always lock both objects:" +msgstr "" + +#: ../../library/threadsafety.rst:394 +msgid "" +"s |= other # other must be set/frozenset\n" +"s &= other # other must be set/frozenset\n" +"s -= other # other must be set/frozenset\n" +"s ^= other # other must be set/frozenset\n" +"s & other # other must be set/frozenset\n" +"s | other # other must be set/frozenset\n" +"s - other # other must be set/frozenset\n" +"s ^ other # other must be set/frozenset" +msgstr "" + +#: ../../library/threadsafety.rst:406 +msgid "" +":meth:`set.update`, :meth:`set.union`, :meth:`set.intersection` and :meth:" +"`set.difference` can take multiple iterables as arguments. They all iterate " +"through all the passed iterables and do the following:" +msgstr "" + +#: ../../library/threadsafety.rst:410 +msgid ":meth:`set.update` and :meth:`set.union` lock both objects only when" +msgstr "" + +#: ../../library/threadsafety.rst:411 +msgid "" +"the other operand is a :class:`set`, :class:`frozenset`, or :class:`dict`." +msgstr "" + +#: ../../library/threadsafety.rst:412 +msgid ":meth:`set.intersection` and :meth:`set.difference` always try to lock" +msgstr "" + +#: ../../library/threadsafety.rst:413 +msgid "all objects." +msgstr "" + +#: ../../library/threadsafety.rst:415 +msgid ":meth:`set.symmetric_difference` tries to lock both objects." +msgstr "" + +#: ../../library/threadsafety.rst:417 +msgid "" +"The update variants of the above methods also have some differences between " +"them:" +msgstr "" + +#: ../../library/threadsafety.rst:420 +msgid ":meth:`set.difference_update` and :meth:`set.intersection_update` try" +msgstr "" + +#: ../../library/threadsafety.rst:421 +msgid "to lock all objects one-by-one." +msgstr "" + +#: ../../library/threadsafety.rst:422 +msgid "" +":meth:`set.symmetric_difference_update` only locks the arguments if it is" +msgstr "" + +#: ../../library/threadsafety.rst:423 +msgid "of type :class:`set`, :class:`frozenset`, or :class:`dict`." +msgstr "" + +#: ../../library/threadsafety.rst:425 +msgid "The following methods always try to lock both objects:" +msgstr "" + +#: ../../library/threadsafety.rst:427 +msgid "" +"s.isdisjoint(other) # both locked\n" +"s.issubset(other) # both locked\n" +"s.issuperset(other) # both locked" +msgstr "" + +#: ../../library/threadsafety.rst:437 +msgid "" +"# NOT atomic: check-then-act\n" +"if elem in s:\n" +" s.remove(elem)\n" +"\n" +"# NOT thread-safe: iteration while modifying\n" +"for elem in s:\n" +" process(elem) # another thread may modify s" +msgstr "" + +#: ../../library/threadsafety.rst:448 +msgid "" +"Consider external synchronization when sharing :class:`set` instances across " +"threads. See :ref:`freethreading-python-howto` for more information." +msgstr "" + +#: ../../library/threadsafety.rst:455 +#, fuzzy +msgid "Thread safety for bytearray objects" +msgstr "執行緒安全等級" + +#: ../../library/threadsafety.rst:459 +msgid "" +"Concatenation and comparisons use the buffer protocol, which prevents " +"resizing but does not hold the per-object lock. These operations may observe " +"intermediate states from concurrent modifications:" +msgstr "" + +#: ../../library/threadsafety.rst:463 +msgid "" +"ba + other # may observe concurrent writes\n" +"ba == other # may observe concurrent writes\n" +"ba < other # may observe concurrent writes" +msgstr "" + +#: ../../library/threadsafety.rst:472 +msgid "" +"Reading a single element or slice is safe to call from multiple threads:" +msgstr "" + +#: ../../library/threadsafety.rst:474 +msgid "" +"ba[i] # bytearray.__getitem__\n" +"ba[i:j] # slice" +msgstr "" + +#: ../../library/threadsafety.rst:480 +msgid "" +"The following operations are safe to call from multiple threads and will not " +"corrupt the bytearray:" +msgstr "" + +#: ../../library/threadsafety.rst:483 +msgid "" +"ba[i] = x # write single byte\n" +"ba[i:j] = values # write slice\n" +"ba.append(x) # append single byte\n" +"ba.extend(other) # extend with iterable\n" +"ba.insert(i, x) # insert single byte\n" +"ba.pop() # remove and return last byte\n" +"ba.pop(i) # remove and return byte at index\n" +"ba.remove(x) # remove first occurrence\n" +"ba.reverse() # reverse in place\n" +"ba.clear() # remove all bytes" +msgstr "" + +#: ../../library/threadsafety.rst:497 +msgid "" +"Slice assignment locks both objects when *values* is a :class:`bytearray`:" +msgstr "" + +#: ../../library/threadsafety.rst:499 +msgid "ba[i:j] = other_bytearray # both locked" +msgstr "" + +#: ../../library/threadsafety.rst:504 +msgid "" +"The following operations return new objects and hold the per-object lock for " +"the duration:" +msgstr "" + +#: ../../library/threadsafety.rst:507 +msgid "" +"ba.copy() # returns a shallow copy\n" +"ba * n # repeat into new bytearray" +msgstr "" + +#: ../../library/threadsafety.rst:513 +msgid "The membership test holds the lock for its duration:" +msgstr "" + +#: ../../library/threadsafety.rst:515 +msgid "x in ba # bytearray.__contains__" +msgstr "" + +#: ../../library/threadsafety.rst:520 +msgid "" +"All other bytearray methods (such as :meth:`~bytearray.find`, :meth:" +"`~bytearray.replace`, :meth:`~bytearray.split`, :meth:`~bytearray.decode`, " +"etc.) hold the per-object lock for their duration." +msgstr "" + +#: ../../library/threadsafety.rst:528 +msgid "" +"# NOT atomic: check-then-act\n" +"if x in ba:\n" +" ba.remove(x)\n" +"\n" +"# NOT thread-safe: iteration while modifying\n" +"for byte in ba:\n" +" process(byte) # another thread may modify ba" +msgstr "" + +#: ../../library/threadsafety.rst:539 +msgid "" +"To safely iterate over a bytearray that may be modified by another thread, " +"iterate over a copy:" +msgstr "" + +#: ../../library/threadsafety.rst:542 +msgid "" +"# Make a copy to iterate safely\n" +"for byte in ba.copy():\n" +" process(byte)" +msgstr "" + +#: ../../library/threadsafety.rst:549 +msgid "" +"Consider external synchronization when sharing :class:`bytearray` instances " +"across threads. See :ref:`freethreading-python-howto` for more information." +msgstr "" diff --git a/tutorial/errors.po b/tutorial/errors.po index 3a2853974f9..31ca1f856e6 100644 --- a/tutorial/errors.po +++ b/tutorial/errors.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-03-13 17:06+0000\n" "PO-Revision-Date: 2022-10-24 14:54+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -141,12 +141,12 @@ msgstr "" msgid "" "The last line of the error message indicates what happened. Exceptions come " "in different types, and the type is printed as part of the message: the " -"types in the example are :exc:`ZeroDivisionError`, :exc:`NameError` " -"and :exc:`TypeError`. The string printed as the exception type is the name " -"of the built-in exception that occurred. This is true for all built-in " -"exceptions, but need not be true for user-defined exceptions (although it is " -"a useful convention). Standard exception names are built-in identifiers (not " -"reserved keywords)." +"types in the example are :exc:`ZeroDivisionError`, :exc:`NameError` and :exc:" +"`TypeError`. The string printed as the exception type is the name of the " +"built-in exception that occurred. This is true for all built-in exceptions, " +"but need not be true for user-defined exceptions (although it is a useful " +"convention). Standard exception names are built-in identifiers (not reserved " +"keywords)." msgstr "" "錯誤訊息的最後一行指示發生了什麼事。例外有不同的類型,而類型名稱會作為訊息的" "一部份被印出。範例中的例外類型為::exc:`ZeroDivisionError`、:exc:`NameError` " @@ -185,10 +185,10 @@ msgstr "處理例外" msgid "" "It is possible to write programs that handle selected exceptions. Look at " "the following example, which asks the user for input until a valid integer " -"has been entered, but allows the user to interrupt the program " -"(using :kbd:`Control-C` or whatever the operating system supports); note " -"that a user-generated interruption is signalled by raising " -"the :exc:`KeyboardInterrupt` exception. ::" +"has been entered, but allows the user to interrupt the program (using :kbd:" +"`Control-C` or whatever the operating system supports); note that a user-" +"generated interruption is signalled by raising the :exc:`KeyboardInterrupt` " +"exception. ::" msgstr "" "編寫程式處理選定的例外是可行的。以下範例會要求使用者輸入內容,直到有效的整數" "被輸入為止,但它允許使用者中斷程式(使用 :kbd:`Control-C` 或作業系統支援的指" @@ -219,16 +219,16 @@ msgstr ":keyword:`try` 陳述式運作方式如下。" #: ../../tutorial/errors.rst:105 msgid "" -"First, the *try clause* (the statement(s) between the :keyword:`try` " -"and :keyword:`except` keywords) is executed." +"First, the *try clause* (the statement(s) between the :keyword:`try` and :" +"keyword:`except` keywords) is executed." msgstr "" "首先,執行 *try 子句*\\ (:keyword:`try` 和 :keyword:`except` 關鍵字之間的陳" "述式)。" #: ../../tutorial/errors.rst:108 msgid "" -"If no exception occurs, the *except clause* is skipped and execution of " -"the :keyword:`try` statement is finished." +"If no exception occurs, the *except clause* is skipped and execution of the :" +"keyword:`try` statement is finished." msgstr "" "如果沒有發生例外,則 *except 子句*\\ 會被跳過,:keyword:`try` 陳述式執行完" "畢。" @@ -251,18 +251,18 @@ msgid "" "handler is found, it is an *unhandled exception* and execution stops with an " "error message." msgstr "" -"如果發生的例外未符合 *except 子句* 中的例外名稱,則將其傳遞到外層" -"的 :keyword:`try` 陳述式;如果仍無法找到處理者,則它是一個\\ *未處理例外 " -"(unhandled exception)*,執行將停止,並顯示錯誤訊息。" +"如果發生的例外未符合 *except 子句* 中的例外名稱,則將其傳遞到外層的 :keyword:" +"`try` 陳述式;如果仍無法找到處理者,則它是一個\\ *未處理例外 (unhandled " +"exception)*,執行將停止,並顯示錯誤訊息。" #: ../../tutorial/errors.rst:120 +#, fuzzy msgid "" "A :keyword:`try` statement may have more than one *except clause*, to " "specify handlers for different exceptions. At most one handler will be " "executed. Handlers only handle exceptions that occur in the corresponding " "*try clause*, not in other handlers of the same :keyword:`!try` statement. " -"An *except clause* may name multiple exceptions as a parenthesized tuple, " -"for example::" +"An *except clause* may name multiple exceptions, for example::" msgstr "" ":keyword:`try` 陳述式可以有不只一個 *except 子句*,為不同的例外指定處理者,而" "最多只有一個處理者會被執行。處理者只處理對應的 try 子句中發生的例外,而不會處" @@ -270,8 +270,9 @@ msgstr "" "用一組括號內的 tuple 列舉多個例外,例如: ::" #: ../../tutorial/errors.rst:126 +#, fuzzy msgid "" -"... except (RuntimeError, TypeError, NameError):\n" +"... except RuntimeError, TypeError, NameError:\n" "... pass" msgstr "" "... except (RuntimeError, TypeError, NameError):\n" @@ -356,8 +357,8 @@ msgid "" "explicitly accessing ``.args``. ::" msgstr "" "*except 子句*\\ 可以在例外名稱後面指定一個變數。這個變數被綁定到一個例外實例 " -"(instance),其引數通常儲存在 ``args`` 屬性中。為了方便,內建例外型別定義" -"了 :meth:`~object.__str__` 以印出所有引數而不需顯式地取用 ``.args``: ::" +"(instance),其引數通常儲存在 ``args`` 屬性中。為了方便,內建例外型別定義了 :" +"meth:`~object.__str__` 以印出所有引數而不需顯式地取用 ``.args``: ::" #: ../../tutorial/errors.rst:166 msgid "" @@ -410,16 +411,15 @@ msgid "" "subclasses, :exc:`Exception`, is the base class of all the non-fatal " "exceptions. Exceptions which are not subclasses of :exc:`Exception` are not " "typically handled, because they are used to indicate that the program should " -"terminate. They include :exc:`SystemExit` which is raised " -"by :meth:`sys.exit` and :exc:`KeyboardInterrupt` which is raised when a user " -"wishes to interrupt the program." +"terminate. They include :exc:`SystemExit` which is raised by :meth:`sys." +"exit` and :exc:`KeyboardInterrupt` which is raised when a user wishes to " +"interrupt the program." msgstr "" ":exc:`BaseException` 是由全部的例外所共用的 base class。它的 subclass(子類" "別)之一,:exc:`Exception`,則是所有非嚴重例外 (non-fatal exception) 的 base " "class。有些例外不是 :exc:`Exception` 的 subclass,而它們通常不會被處理,因為" -"它們是用來指示程式應該終止。這些例外包括了由 :meth:`sys.exit` 所引發" -"的 :exc:`SystemExit`,以及當使用者想要中斷程式時所引發" -"的 :exc:`KeyboardInterrupt`。" +"它們是用來指示程式應該終止。這些例外包括了由 :meth:`sys.exit` 所引發的 :exc:" +"`SystemExit`,以及當使用者想要中斷程式時所引發的 :exc:`KeyboardInterrupt`。" #: ../../tutorial/errors.rst:194 msgid "" @@ -591,8 +591,8 @@ msgid "" "handle it, a simpler form of the :keyword:`raise` statement allows you to re-" "raise the exception::" msgstr "" -"如果你只想判斷是否引發了例外,但並不打算處理它,則可以使用簡單" -"的 :keyword:`raise` 陳述式來重新引發該例外: ::" +"如果你只想判斷是否引發了例外,但並不打算處理它,則可以使用簡單的 :keyword:" +"`raise` 陳述式來重新引發該例外: ::" #: ../../tutorial/errors.rst:277 msgid "" @@ -673,9 +673,8 @@ msgstr "" #: ../../tutorial/errors.rst:317 msgid "" -"To indicate that an exception is a direct consequence of another, " -"the :keyword:`raise` statement allows an optional :keyword:`from` " -"clause::" +"To indicate that an exception is a direct consequence of another, the :" +"keyword:`raise` statement allows an optional :keyword:`from` clause::" msgstr "" "為了表明一個例外是另一個例外直接造成的結果,:keyword:`raise` 陳述式容許一個選" "擇性的 :keyword:`from` 子句: ::" @@ -783,8 +782,8 @@ msgid "" "indirectly." msgstr "" "程式可以透過建立新的例外 class 來命名自己的例外(深入了解 Python class,詳見" -"\\ :ref:`tut-classes`\\ )。不論是直接還是間接地,例外通常應該" -"從 :exc:`Exception` class 衍生出來。" +"\\ :ref:`tut-classes`\\ )。不論是直接還是間接地,例外通常應該從 :exc:" +"`Exception` class 衍生出來。" #: ../../tutorial/errors.rst:372 msgid "" @@ -853,10 +852,10 @@ msgid "" "statement produces an exception. The following points discuss more complex " "cases when an exception occurs:" msgstr "" -"如果 :keyword:`finally` 子句存在,則 :keyword:`!finally` 子句會" -"是 :keyword:`try` 陳述式結束前執行的最後一項任務。不論 :keyword:`!try` 陳述式" -"是否產生例外,都會執行 :keyword:`!finally` 子句。以下幾點將探討例外發生時,比" -"較複雜的情況:" +"如果 :keyword:`finally` 子句存在,則 :keyword:`!finally` 子句會是 :keyword:" +"`try` 陳述式結束前執行的最後一項任務。不論 :keyword:`!try` 陳述式是否產生例" +"外,都會執行 :keyword:`!finally` 子句。以下幾點將探討例外發生時,比較複雜的情" +"況:" #: ../../tutorial/errors.rst:409 msgid "" @@ -865,55 +864,56 @@ msgid "" "not handled by an :keyword:`!except` clause, the exception is re-raised " "after the :keyword:`!finally` clause has been executed." msgstr "" -"若一個例外發生於 :keyword:`!try` 子句的執行過程,則該例外會被某" -"個 :keyword:`except` 子句處理。如果該例外沒有被 :keyword:`!except` 子句處理," -"它會在 :keyword:`!finally` 子句執行後被重新引發。" +"若一個例外發生於 :keyword:`!try` 子句的執行過程,則該例外會被某個 :keyword:" +"`except` 子句處理。如果該例外沒有被 :keyword:`!except` 子句處理,它會在 :" +"keyword:`!finally` 子句執行後被重新引發。" #: ../../tutorial/errors.rst:415 msgid "" -"An exception could occur during execution of an :keyword:`!except` " -"or :keyword:`!else` clause. Again, the exception is re-raised after " -"the :keyword:`!finally` clause has been executed." +"An exception could occur during execution of an :keyword:`!except` or :" +"keyword:`!else` clause. Again, the exception is re-raised after the :keyword:" +"`!finally` clause has been executed." msgstr "" "一個例外可能發生於 :keyword:`!except` 或 :keyword:`!else` 子句的執行過程。同" "樣地,該例外會在 :keyword:`!finally` 子句執行後被重新引發。" #: ../../tutorial/errors.rst:419 msgid "" -"If the :keyword:`!finally` clause executes " -"a :keyword:`break`, :keyword:`continue` or :keyword:`return` statement, " -"exceptions are not re-raised. This can be confusing and is therefore " -"discouraged. From version 3.14 the compiler emits a :exc:`SyntaxWarning` for " -"it (see :pep:`765`)." +"If the :keyword:`!finally` clause executes a :keyword:`break`, :keyword:" +"`continue` or :keyword:`return` statement, exceptions are not re-raised. " +"This can be confusing and is therefore discouraged. From version 3.14 the " +"compiler emits a :exc:`SyntaxWarning` for it (see :pep:`765`)." msgstr "" -"如果 :keyword:`!finally` 子句執行 :keyword:`break`、:keyword:`continue` " -"或 :keyword:`return` 陳述式,則例外不會被重新引發。這可能會令人困惑,因此不建議這麼做。" -"從 3.14 版本開始,編譯器會為此發出 :exc:`SyntaxWarning`\\ (詳見 :pep:`765`)。" +"如果 :keyword:`!finally` 子句執行 :keyword:`break`、:keyword:`continue` 或 :" +"keyword:`return` 陳述式,則例外不會被重新引發。這可能會令人困惑,因此不建議這" +"麼做。從 3.14 版本開始,編譯器會為此發出 :exc:`SyntaxWarning`\\ (詳見 :pep:" +"`765`)。" #: ../../tutorial/errors.rst:425 msgid "" -"If the :keyword:`!try` statement reaches " -"a :keyword:`break`, :keyword:`continue` or :keyword:`return` statement, " -"the :keyword:`!finally` clause will execute just prior to the :keyword:`!" -"break`, :keyword:`!continue` or :keyword:`!return` statement's execution." +"If the :keyword:`!try` statement reaches a :keyword:`break`, :keyword:" +"`continue` or :keyword:`return` statement, the :keyword:`!finally` clause " +"will execute just prior to the :keyword:`!break`, :keyword:`!continue` or :" +"keyword:`!return` statement's execution." msgstr "" -"如果 :keyword:`!try` 陳述式遇到 :keyword:`break`、:keyword:`continue` " -"或 :keyword:`return` 陳述式,則 :keyword:`!finally` 子句會在執行 :keyword:`!" +"如果 :keyword:`!try` 陳述式遇到 :keyword:`break`、:keyword:`continue` 或 :" +"keyword:`return` 陳述式,則 :keyword:`!finally` 子句會在執行 :keyword:`!" "break`、:keyword:`!continue` 或 :keyword:`!return` 陳述式之前先執行。" #: ../../tutorial/errors.rst:431 msgid "" "If a :keyword:`!finally` clause includes a :keyword:`!return` statement, the " -"returned value will be the one from the :keyword:`!finally` " -"clause's :keyword:`!return` statement, not the value from the :keyword:`!" -"try` clause's :keyword:`!return` statement. This can be confusing and is " -"therefore discouraged. From version 3.14 the compiler emits " -"a :exc:`SyntaxWarning` for it (see :pep:`765`)." +"returned value will be the one from the :keyword:`!finally` clause's :" +"keyword:`!return` statement, not the value from the :keyword:`!try` " +"clause's :keyword:`!return` statement. This can be confusing and is " +"therefore discouraged. From version 3.14 the compiler emits a :exc:" +"`SyntaxWarning` for it (see :pep:`765`)." msgstr "" "如果 :keyword:`!finally` 子句中包含 :keyword:`!return` 陳述式,則回傳值會是來" -"自 :keyword:`!finally` 子句的 :keyword:`!return` 陳述式的回傳值,而不是來" -"自 :keyword:`!try` 子句的 :keyword:`!return` 陳述式的回傳值。這可能會令人困惑,因此不建議這麼做。" -"從 3.14 版本開始,編譯器會為此發出 :exc:`SyntaxWarning`\\ (詳見 :pep:`765`)。" +"自 :keyword:`!finally` 子句的 :keyword:`!return` 陳述式的回傳值,而不是來自 :" +"keyword:`!try` 子句的 :keyword:`!return` 陳述式的回傳值。這可能會令人困惑,因" +"此不建議這麼做。從 3.14 版本開始,編譯器會為此發出 :exc:`SyntaxWarning`\\ " +"(詳見 :pep:`765`)。" #: ../../tutorial/errors.rst:439 msgid "For example::" @@ -1002,8 +1002,8 @@ msgstr "" #: ../../tutorial/errors.rst:479 msgid "" "As you can see, the :keyword:`finally` clause is executed in any event. " -"The :exc:`TypeError` raised by dividing two strings is not handled by " -"the :keyword:`except` clause and therefore re-raised after the :keyword:`!" +"The :exc:`TypeError` raised by dividing two strings is not handled by the :" +"keyword:`except` clause and therefore re-raised after the :keyword:`!" "finally` clause has been executed." msgstr "" "如你所見,:keyword:`finally` 子句在任何情況下都會被執行。兩個字串相除所引發" @@ -1051,9 +1051,9 @@ msgid "" "correctly. ::" msgstr "" "這段程式碼的問題在於,執行完該程式碼後,它讓檔案在一段不確定的時間內處於開啟" -"狀態。在簡單腳本中這不是問題,但對於較大的應用程式來說可能會是個問" -"題。:keyword:`with` 陳述式讓物件(例如檔案)在被使用時,能保證它們總是及時、" -"正確地被清理。 ::" +"狀態。在簡單腳本中這不是問題,但對於較大的應用程式來說可能會是個問題。:" +"keyword:`with` 陳述式讓物件(例如檔案)在被使用時,能保證它們總是及時、正確地" +"被清理。 ::" #: ../../tutorial/errors.rst:508 msgid ""