diff --git a/c-api/arg.po b/c-api/arg.po index d0ee0ca15e..921b3bae7f 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-26 00:14+0000\n" +"POT-Creation-Date: 2025-05-06 05:40+0000\n" "PO-Revision-Date: 2022-10-16 03:21+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" diff --git a/library/operator.po b/library/operator.po index a4e5af2d33..297a3f9c14 100644 --- a/library/operator.po +++ b/library/operator.po @@ -97,7 +97,7 @@ msgid "" "is equivalent to using the :class:`bool` constructor." msgstr "" "如果 *obj* 為真值則回傳 :const:`True`,否則回傳 :const:`False`。這等價於使" -"用 :class:`bool` 建構器。" +"用 :class:`bool` 建構函式。" #: ../../library/operator.rst:75 msgid "Return ``a is b``. Tests object identity." diff --git a/library/plistlib.po b/library/plistlib.po index cd169610e3..be0ef2cf37 100644 --- a/library/plistlib.po +++ b/library/plistlib.po @@ -42,14 +42,14 @@ msgstr "" #: ../../library/plistlib.rst:27 msgid "" -"To write out and to parse a plist file, use the :func:`dump` and :func:" -"`load` functions." +"To write out and to parse a plist file, use the :func:`dump` " +"and :func:`load` functions." msgstr "" #: ../../library/plistlib.rst:30 msgid "" -"To work with plist data in bytes or string objects, use :func:`dumps` and :" -"func:`loads`." +"To work with plist data in bytes or string objects, use :func:`dumps` " +"and :func:`loads`." msgstr "" #: ../../library/plistlib.rst:33 @@ -85,7 +85,7 @@ msgstr "" #: ../../library/plistlib.rst:53 msgid "This module defines the following functions:" -msgstr "" +msgstr "此模組定義了以下函式:" #: ../../library/plistlib.rst:57 msgid "" @@ -202,8 +202,9 @@ msgstr "" #: ../../library/plistlib.rst:136 msgid "" -"Return *value* as a plist-formatted bytes object. See the documentation for :" -"func:`dump` for an explanation of the keyword arguments of this function." +"Return *value* as a plist-formatted bytes object. See the documentation " +"for :func:`dump` for an explanation of the keyword arguments of this " +"function." msgstr "" #: ../../library/plistlib.rst:143 diff --git a/library/subprocess.po b/library/subprocess.po index a5a9086c53..8ee5e86cc5 100644 --- a/library/subprocess.po +++ b/library/subprocess.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-05-06 00:15+0000\n" "PO-Revision-Date: 2018-05-23 16:11+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2082,41 +2082,68 @@ msgid "Notes" msgstr "註解" #: ../../library/subprocess.rst:1597 -msgid "Converting an argument sequence to a string on Windows" +msgid "Timeout Behavior" msgstr "" #: ../../library/subprocess.rst:1599 msgid "" +"When using the ``timeout`` parameter in functions like :func:`run`, :meth:" +"`Popen.wait`, or :meth:`Popen.communicate`, users should be aware of the " +"following behaviors:" +msgstr "" + +#: ../../library/subprocess.rst:1603 +msgid "" +"**Process Creation Delay**: The initial process creation itself cannot be " +"interrupted on many platform APIs. This means that even when specifying a " +"timeout, you are not guaranteed to see a timeout exception until at least " +"after however long process creation takes." +msgstr "" + +#: ../../library/subprocess.rst:1608 +msgid "" +"**Extremely Small Timeout Values**: Setting very small timeout values (such " +"as a few milliseconds) may result in almost immediate :exc:`TimeoutExpired` " +"exceptions because process creation and system scheduling inherently require " +"time." +msgstr "" + +#: ../../library/subprocess.rst:1615 +msgid "Converting an argument sequence to a string on Windows" +msgstr "" + +#: ../../library/subprocess.rst:1617 +msgid "" "On Windows, an *args* sequence is converted to a string that can be parsed " "using the following rules (which correspond to the rules used by the MS C " "runtime):" msgstr "" -#: ../../library/subprocess.rst:1603 +#: ../../library/subprocess.rst:1621 msgid "" "Arguments are delimited by white space, which is either a space or a tab." msgstr "" -#: ../../library/subprocess.rst:1606 +#: ../../library/subprocess.rst:1624 msgid "" "A string surrounded by double quotation marks is interpreted as a single " "argument, regardless of white space contained within. A quoted string can " "be embedded in an argument." msgstr "" -#: ../../library/subprocess.rst:1611 +#: ../../library/subprocess.rst:1629 msgid "" "A double quotation mark preceded by a backslash is interpreted as a literal " "double quotation mark." msgstr "" -#: ../../library/subprocess.rst:1614 +#: ../../library/subprocess.rst:1632 msgid "" "Backslashes are interpreted literally, unless they immediately precede a " "double quotation mark." msgstr "" -#: ../../library/subprocess.rst:1617 +#: ../../library/subprocess.rst:1635 msgid "" "If backslashes immediately precede a double quotation mark, every pair of " "backslashes is interpreted as a literal backslash. If the number of " @@ -2124,19 +2151,19 @@ msgid "" "mark as described in rule 3." msgstr "" -#: ../../library/subprocess.rst:1626 +#: ../../library/subprocess.rst:1644 msgid ":mod:`shlex`" msgstr ":mod:`shlex`" -#: ../../library/subprocess.rst:1627 +#: ../../library/subprocess.rst:1645 msgid "Module which provides function to parse and escape command lines." msgstr "" -#: ../../library/subprocess.rst:1634 +#: ../../library/subprocess.rst:1652 msgid "Disabling use of ``vfork()`` or ``posix_spawn()``" msgstr "停用 ``vfork()`` 或 ``posix_spawn()``" -#: ../../library/subprocess.rst:1636 +#: ../../library/subprocess.rst:1654 msgid "" "On Linux, :mod:`subprocess` defaults to using the ``vfork()`` system call " "internally when it is safe to do so rather than ``fork()``. This greatly " @@ -2145,7 +2172,7 @@ msgstr "" "在 Linux 上,:mod:`subprocess` 在安全的情況下預設會在內部使用 ``vfork()`` 系" "統呼叫,而不是 ``fork()``,這顯著地提高了性能。" -#: ../../library/subprocess.rst:1640 +#: ../../library/subprocess.rst:1658 msgid "" "If you ever encounter a presumed highly unusual situation where you need to " "prevent ``vfork()`` from being used by Python, you can set the :const:" @@ -2154,11 +2181,11 @@ msgstr "" "如果你遇到了一個推定為極異常的情況,需要防止 Python 使用 ``vfork()``,你可以" "將 :const:`subprocess._USE_VFORK` 屬性設為 false 值。" -#: ../../library/subprocess.rst:1646 +#: ../../library/subprocess.rst:1664 msgid "subprocess._USE_VFORK = False # See CPython issue gh-NNNNNN." msgstr "subprocess._USE_VFORK = False # 見 CPython 問題 gh-NNNNNN." -#: ../../library/subprocess.rst:1648 +#: ../../library/subprocess.rst:1666 msgid "" "Setting this has no impact on use of ``posix_spawn()`` which could use " "``vfork()`` internally within its libc implementation. There is a similar :" @@ -2169,11 +2196,11 @@ msgstr "" "``vfork()``。如果你需要封鎖該屬性的使用,則有一個類似的 :const:`subprocess." "_USE_POSIX_SPAWN` 屬性。" -#: ../../library/subprocess.rst:1655 +#: ../../library/subprocess.rst:1673 msgid "subprocess._USE_POSIX_SPAWN = False # See CPython issue gh-NNNNNN." msgstr "subprocess._USE_POSIX_SPAWN = False # 見 CPython 問題 gh-NNNNNN." -#: ../../library/subprocess.rst:1657 +#: ../../library/subprocess.rst:1675 msgid "" "It is safe to set these to false on any Python version. They will have no " "effect on older versions when unsupported. Do not assume the attributes are " @@ -2184,7 +2211,7 @@ msgstr "" "沒有影響。不要假設屬性可供讀取。儘管有它們的名稱,真實值並不表示將使用相應的" "函式,而只是表示可能會使用。" -#: ../../library/subprocess.rst:1662 +#: ../../library/subprocess.rst:1680 msgid "" "Please file issues any time you have to use these private knobs with a way " "to reproduce the issue you were seeing. Link to that issue from a comment in " @@ -2193,11 +2220,11 @@ msgstr "" "每當你需要使用這些私有開關以重現你所看到的問題時,請隨時提出問題 (file " "issues)。從程式碼中的註解連結到該問題。" -#: ../../library/subprocess.rst:1666 +#: ../../library/subprocess.rst:1684 msgid "``_USE_POSIX_SPAWN``" msgstr "``_USE_POSIX_SPAWN``" -#: ../../library/subprocess.rst:1667 +#: ../../library/subprocess.rst:1685 msgid "``_USE_VFORK``" msgstr "``_USE_VFORK``" diff --git a/library/threading.po b/library/threading.po index bc6c0d5319..17431fee17 100644 --- a/library/threading.po +++ b/library/threading.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-05-06 00:15+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -68,13 +68,14 @@ msgid "" "lock>`, only one thread can execute Python code at once (even though certain " "performance-oriented libraries might overcome this limitation). If you want " "your application to make better use of the computational resources of multi-" -"core machines, you are advised to use :mod:`multiprocessing` or :class:" -"`concurrent.futures.ProcessPoolExecutor`. However, threading is still an " -"appropriate model if you want to run multiple I/O-bound tasks simultaneously." +"core machines, you are advised to use :mod:`multiprocessing` " +"or :class:`concurrent.futures.ProcessPoolExecutor`. However, threading is " +"still an appropriate model if you want to run multiple I/O-bound tasks " +"simultaneously." msgstr "" #: ../../library/threading.rst:130 ../../library/threading.rst:229 -#: ../../library/threading.rst:468 ../../includes/wasm-notavail.rst:3 +#: ../../library/threading.rst:577 ../../includes/wasm-notavail.rst:3 msgid "Availability" msgstr "" @@ -88,7 +89,7 @@ msgstr "" #: ../../library/threading.rst:50 msgid "This module defines the following functions:" -msgstr "" +msgstr "此模組定義了以下函式:" #: ../../library/threading.rst:55 msgid "" @@ -110,19 +111,19 @@ msgstr "" #: ../../library/threading.rst:68 msgid "The function ``currentThread`` is a deprecated alias for this function." -msgstr "" +msgstr "``currentThread`` 函式是此函式的已棄用別名。" #: ../../library/threading.rst:73 msgid "Handle uncaught exception raised by :func:`Thread.run`." -msgstr "" +msgstr "處理由 :func:`Thread.run` 引發且未被捕捉到的例外。" #: ../../library/threading.rst:75 msgid "The *args* argument has the following attributes:" -msgstr "" +msgstr "*args* 引數有下列屬性:" #: ../../library/threading.rst:77 msgid "*exc_type*: Exception type." -msgstr "" +msgstr "*exc_type*:例外型別。" #: ../../library/threading.rst:78 msgid "*exc_value*: Exception value, can be ``None``." @@ -134,7 +135,7 @@ msgstr "" #: ../../library/threading.rst:80 msgid "*thread*: Thread which raised the exception, can be ``None``." -msgstr "" +msgstr "*thread*:引發例外的執行緒,可以是 ``None``。" #: ../../library/threading.rst:82 msgid "" @@ -146,7 +147,7 @@ msgstr "" msgid "" "If this function raises an exception, :func:`sys.excepthook` is called to " "handle it." -msgstr "" +msgstr "如果這個函式引發例外,則會呼叫 :func:`sys.excepthook` 來處理它。" #: ../../library/threading.rst:88 msgid "" @@ -170,7 +171,7 @@ msgstr "" #: ../../library/threading.rst:100 msgid ":func:`sys.excepthook` handles uncaught exceptions." -msgstr "" +msgstr ":func:`sys.excepthook` 處理未被捕捉到的例外。" #: ../../library/threading.rst:106 msgid "" @@ -198,15 +199,15 @@ msgstr "" #: ../../library/threading.rst:134 msgid "Added support for GNU/kFreeBSD." -msgstr "" +msgstr "新增對 GNU/kFreeBSD 的支援。" #: ../../library/threading.rst:140 msgid "" "Return a list of all :class:`Thread` objects currently active. The list " -"includes daemonic threads and dummy thread objects created by :func:" -"`current_thread`. It excludes terminated threads and threads that have not " -"yet been started. However, the main thread is always part of the result, " -"even when terminated." +"includes daemonic threads and dummy thread objects created " +"by :func:`current_thread`. It excludes terminated threads and threads that " +"have not yet been started. However, the main thread is always part of the " +"result, even when terminated." msgstr "" #: ../../library/threading.rst:149 @@ -267,9 +268,9 @@ msgid "" "*size* argument specifies the stack size to be used for subsequently created " "threads, and must be 0 (use platform or configured default) or a positive " "integer value of at least 32,768 (32 KiB). If *size* is not specified, 0 is " -"used. If changing the thread stack size is unsupported, a :exc:" -"`RuntimeError` is raised. If the specified stack size is invalid, a :exc:" -"`ValueError` is raised and the stack size is unmodified. 32 KiB is " +"used. If changing the thread stack size is unsupported, " +"a :exc:`RuntimeError` is raised. If the specified stack size is invalid, " +"a :exc:`ValueError` is raised and the stack size is unmodified. 32 KiB is " "currently the minimum supported stack size value to guarantee sufficient " "stack space for the interpreter itself. Note that some platforms may have " "particular restrictions on values for the stack size, such as requiring a " @@ -292,8 +293,8 @@ msgstr "" msgid "" "The maximum value allowed for the *timeout* parameter of blocking functions " "(:meth:`Lock.acquire`, :meth:`RLock.acquire`, :meth:`Condition.wait`, etc.). " -"Specifying a timeout greater than this value will raise an :exc:" -"`OverflowError`." +"Specifying a timeout greater than this value will raise " +"an :exc:`OverflowError`." msgstr "" #: ../../library/threading.rst:246 @@ -323,38 +324,273 @@ msgstr "" #: ../../library/threading.rst:263 msgid "" -"Thread-local data is data whose values are thread specific. To manage " -"thread-local data, just create an instance of :class:`local` (or a subclass) " -"and store attributes on it::" +"Thread-local data is data whose values are thread specific. If you have data " +"that you want to be local to a thread, create a :class:`local` object and " +"use its attributes::" msgstr "" #: ../../library/threading.rst:267 msgid "" -"mydata = threading.local()\n" -"mydata.x = 1" +">>> mydata = local()\n" +">>> mydata.number = 42\n" +">>> mydata.number\n" +"42" msgstr "" -"mydata = threading.local()\n" -"mydata.x = 1" +">>> mydata = local()\n" +">>> mydata.number = 42\n" +">>> mydata.number\n" +"42" -#: ../../library/threading.rst:270 -msgid "The instance's values will be different for separate threads." +#: ../../library/threading.rst:272 +msgid "You can also access the :class:`local`-object's dictionary::" msgstr "" -#: ../../library/threading.rst:275 -msgid "A class that represents thread-local data." +#: ../../library/threading.rst:274 +msgid "" +">>> mydata.__dict__\n" +"{'number': 42}\n" +">>> mydata.__dict__.setdefault('widgets', [])\n" +"[]\n" +">>> mydata.widgets\n" +"[]" +msgstr "" +">>> mydata.__dict__\n" +"{'number': 42}\n" +">>> mydata.__dict__.setdefault('widgets', [])\n" +"[]\n" +">>> mydata.widgets\n" +"[]" + +#: ../../library/threading.rst:281 +msgid "If we access the data in a different thread::" +msgstr "" + +#: ../../library/threading.rst:283 +msgid "" +">>> log = []\n" +">>> def f():\n" +"... items = sorted(mydata.__dict__.items())\n" +"... log.append(items)\n" +"... mydata.number = 11\n" +"... log.append(mydata.number)\n" +"\n" +">>> import threading\n" +">>> thread = threading.Thread(target=f)\n" +">>> thread.start()\n" +">>> thread.join()\n" +">>> log\n" +"[[], 11]" +msgstr "" +">>> log = []\n" +">>> def f():\n" +"... items = sorted(mydata.__dict__.items())\n" +"... log.append(items)\n" +"... mydata.number = 11\n" +"... log.append(mydata.number)\n" +"\n" +">>> import threading\n" +">>> thread = threading.Thread(target=f)\n" +">>> thread.start()\n" +">>> thread.join()\n" +">>> log\n" +"[[], 11]" + +#: ../../library/threading.rst:297 +msgid "" +"we get different data. Furthermore, changes made in the other thread don't " +"affect data seen in this thread::" msgstr "" -#: ../../library/threading.rst:277 +#: ../../library/threading.rst:300 msgid "" -"For more details and extensive examples, see the documentation string of " -"the :mod:`!_threading_local` module: :source:`Lib/_threading_local.py`." +">>> mydata.number\n" +"42" msgstr "" +">>> mydata.number\n" +"42" -#: ../../library/threading.rst:284 -msgid "Thread Objects" +#: ../../library/threading.rst:303 +msgid "" +"Of course, values you get from a :class:`local` object, including " +"their :attr:`~object.__dict__` attribute, are for whatever thread was " +"current at the time the attribute was read. For that reason, you generally " +"don't want to save these values across threads, as they apply only to the " +"thread they came from." +msgstr "" + +#: ../../library/threading.rst:309 +msgid "" +"You can create custom :class:`local` objects by subclassing " +"the :class:`local` class::" +msgstr "" + +#: ../../library/threading.rst:312 +msgid "" +">>> class MyLocal(local):\n" +"... number = 2\n" +"... def __init__(self, /, **kw):\n" +"... self.__dict__.update(kw)\n" +"... def squared(self):\n" +"... return self.number ** 2" +msgstr "" +">>> class MyLocal(local):\n" +"... number = 2\n" +"... def __init__(self, /, **kw):\n" +"... self.__dict__.update(kw)\n" +"... def squared(self):\n" +"... return self.number ** 2" + +#: ../../library/threading.rst:319 +msgid "" +"This can be useful to support default values, methods and initialization. " +"Note that if you define an :py:meth:`~object.__init__` method, it will be " +"called each time the :class:`local` object is used in a separate thread. " +"This is necessary to initialize each thread's dictionary." +msgstr "" + +#: ../../library/threading.rst:325 +msgid "Now if we create a :class:`local` object::" +msgstr "現在如果我們建立一個 :class:`local` 物件: ::" + +#: ../../library/threading.rst:327 +msgid ">>> mydata = MyLocal(color='red')" +msgstr ">>> mydata = MyLocal(color='red')" + +#: ../../library/threading.rst:329 +msgid "we have a default number::" +msgstr "會有一個預設的數字: ::" + +#: ../../library/threading.rst:331 +msgid "" +">>> mydata.number\n" +"2" +msgstr "" +">>> mydata.number\n" +"2" + +#: ../../library/threading.rst:334 +msgid "an initial color::" +msgstr "和一個初始顏色: ::" + +#: ../../library/threading.rst:336 +msgid "" +">>> mydata.color\n" +"'red'\n" +">>> del mydata.color" +msgstr "" +">>> mydata.color\n" +"'red'\n" +">>> del mydata.color" + +#: ../../library/threading.rst:340 +msgid "And a method that operates on the data::" +msgstr "和一個操作資料的方法: ::" + +#: ../../library/threading.rst:342 +msgid "" +">>> mydata.squared()\n" +"4" +msgstr "" +">>> mydata.squared()\n" +"4" + +#: ../../library/threading.rst:345 +msgid "As before, we can access the data in a separate thread::" +msgstr "" + +#: ../../library/threading.rst:347 +msgid "" +">>> log = []\n" +">>> thread = threading.Thread(target=f)\n" +">>> thread.start()\n" +">>> thread.join()\n" +">>> log\n" +"[[('color', 'red')], 11]" +msgstr "" +">>> log = []\n" +">>> thread = threading.Thread(target=f)\n" +">>> thread.start()\n" +">>> thread.join()\n" +">>> log\n" +"[[('color', 'red')], 11]" + +#: ../../library/threading.rst:354 +msgid "without affecting this thread's data::" +msgstr "" + +#: ../../library/threading.rst:356 +msgid "" +">>> mydata.number\n" +"2\n" +">>> mydata.color\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'MyLocal' object has no attribute 'color'" +msgstr "" +">>> mydata.number\n" +"2\n" +">>> mydata.color\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'MyLocal' object has no attribute 'color'" + +#: ../../library/threading.rst:363 +msgid "" +"Note that subclasses can define :term:`__slots__`, but they are not thread " +"local. They are shared across threads::" msgstr "" -#: ../../library/threading.rst:286 +#: ../../library/threading.rst:366 +msgid "" +">>> class MyLocal(local):\n" +"... __slots__ = 'number'\n" +"\n" +">>> mydata = MyLocal()\n" +">>> mydata.number = 42\n" +">>> mydata.color = 'red'" +msgstr "" +">>> class MyLocal(local):\n" +"... __slots__ = 'number'\n" +"\n" +">>> mydata = MyLocal()\n" +">>> mydata.number = 42\n" +">>> mydata.color = 'red'" + +#: ../../library/threading.rst:373 +msgid "So, the separate thread::" +msgstr "" + +#: ../../library/threading.rst:375 +msgid "" +">>> thread = threading.Thread(target=f)\n" +">>> thread.start()\n" +">>> thread.join()" +msgstr "" +">>> thread = threading.Thread(target=f)\n" +">>> thread.start()\n" +">>> thread.join()" + +#: ../../library/threading.rst:379 +msgid "affects what we see::" +msgstr "" + +#: ../../library/threading.rst:381 +msgid "" +">>> mydata.number\n" +"11" +msgstr "" +">>> mydata.number\n" +"11" + +#: ../../library/threading.rst:387 +msgid "A class that represents thread-local data." +msgstr "" + +#: ../../library/threading.rst:393 +msgid "Thread Objects" +msgstr "Thread 物件" + +#: ../../library/threading.rst:395 msgid "" "The :class:`Thread` class represents an activity that is run in a separate " "thread of control. There are two ways to specify the activity: by passing a " @@ -364,42 +600,42 @@ msgid "" "``__init__()`` and :meth:`~Thread.run` methods of this class." msgstr "" -#: ../../library/threading.rst:293 +#: ../../library/threading.rst:402 msgid "" "Once a thread object is created, its activity must be started by calling the " "thread's :meth:`~Thread.start` method. This invokes the :meth:`~Thread.run` " "method in a separate thread of control." msgstr "" -#: ../../library/threading.rst:297 +#: ../../library/threading.rst:406 msgid "" "Once the thread's activity is started, the thread is considered 'alive'. It " "stops being alive when its :meth:`~Thread.run` method terminates -- either " -"normally, or by raising an unhandled exception. The :meth:`~Thread." -"is_alive` method tests whether the thread is alive." +"normally, or by raising an unhandled exception. " +"The :meth:`~Thread.is_alive` method tests whether the thread is alive." msgstr "" -#: ../../library/threading.rst:302 +#: ../../library/threading.rst:411 msgid "" "Other threads can call a thread's :meth:`~Thread.join` method. This blocks " "the calling thread until the thread whose :meth:`~Thread.join` method is " "called is terminated." msgstr "" -#: ../../library/threading.rst:306 +#: ../../library/threading.rst:415 msgid "" "A thread has a name. The name can be passed to the constructor, and read or " "changed through the :attr:`~Thread.name` attribute." msgstr "" -#: ../../library/threading.rst:309 +#: ../../library/threading.rst:418 msgid "" -"If the :meth:`~Thread.run` method raises an exception, :func:`threading." -"excepthook` is called to handle it. By default, :func:`threading.excepthook` " -"ignores silently :exc:`SystemExit`." +"If the :meth:`~Thread.run` method raises an " +"exception, :func:`threading.excepthook` is called to handle it. By " +"default, :func:`threading.excepthook` ignores silently :exc:`SystemExit`." msgstr "" -#: ../../library/threading.rst:313 +#: ../../library/threading.rst:422 msgid "" "A thread can be flagged as a \"daemon thread\". The significance of this " "flag is that the entire Python program exits when only daemon threads are " @@ -408,7 +644,7 @@ msgid "" "constructor argument." msgstr "" -#: ../../library/threading.rst:320 +#: ../../library/threading.rst:429 msgid "" "Daemon threads are abruptly stopped at shutdown. Their resources (such as " "open files, database transactions, etc.) may not be released properly. If " @@ -416,13 +652,13 @@ msgid "" "suitable signalling mechanism such as an :class:`Event`." msgstr "" -#: ../../library/threading.rst:325 +#: ../../library/threading.rst:434 msgid "" "There is a \"main thread\" object; this corresponds to the initial thread of " "control in the Python program. It is not a daemon thread." msgstr "" -#: ../../library/threading.rst:328 +#: ../../library/threading.rst:437 msgid "" "There is the possibility that \"dummy thread objects\" are created. These " "are thread objects corresponding to \"alien threads\", which are threads of " @@ -433,25 +669,25 @@ msgid "" "threads." msgstr "" -#: ../../library/threading.rst:339 +#: ../../library/threading.rst:448 msgid "" "This constructor should always be called with keyword arguments. Arguments " "are:" msgstr "" -#: ../../library/threading.rst:342 +#: ../../library/threading.rst:451 msgid "" "*group* should be ``None``; reserved for future extension when a :class:`!" "ThreadGroup` class is implemented." msgstr "" -#: ../../library/threading.rst:345 +#: ../../library/threading.rst:454 msgid "" "*target* is the callable object to be invoked by the :meth:`run` method. " "Defaults to ``None``, meaning nothing is called." msgstr "" -#: ../../library/threading.rst:348 +#: ../../library/threading.rst:457 msgid "" "*name* is the thread name. By default, a unique name is constructed of the " "form \"Thread-*N*\" where *N* is a small decimal number, or \"Thread-*N* " @@ -459,62 +695,62 @@ msgid "" "is specified." msgstr "" -#: ../../library/threading.rst:353 +#: ../../library/threading.rst:462 msgid "" "*args* is a list or tuple of arguments for the target invocation. Defaults " "to ``()``." msgstr "" -#: ../../library/threading.rst:355 +#: ../../library/threading.rst:464 msgid "" "*kwargs* is a dictionary of keyword arguments for the target invocation. " "Defaults to ``{}``." msgstr "" -#: ../../library/threading.rst:358 +#: ../../library/threading.rst:467 msgid "" "If not ``None``, *daemon* explicitly sets whether the thread is daemonic. If " "``None`` (the default), the daemonic property is inherited from the current " "thread." msgstr "" -#: ../../library/threading.rst:362 +#: ../../library/threading.rst:471 msgid "" "If the subclass overrides the constructor, it must make sure to invoke the " "base class constructor (``Thread.__init__()``) before doing anything else to " "the thread." msgstr "" -#: ../../library/threading.rst:366 +#: ../../library/threading.rst:475 msgid "Added the *daemon* parameter." msgstr "新增 *daemon* 參數。" -#: ../../library/threading.rst:369 +#: ../../library/threading.rst:478 msgid "Use the *target* name if *name* argument is omitted." msgstr "" -#: ../../library/threading.rst:374 +#: ../../library/threading.rst:483 msgid "Start the thread's activity." msgstr "" -#: ../../library/threading.rst:376 +#: ../../library/threading.rst:485 msgid "" "It must be called at most once per thread object. It arranges for the " "object's :meth:`~Thread.run` method to be invoked in a separate thread of " "control." msgstr "" -#: ../../library/threading.rst:380 +#: ../../library/threading.rst:489 msgid "" "This method will raise a :exc:`RuntimeError` if called more than once on the " "same thread object." msgstr "" -#: ../../library/threading.rst:385 +#: ../../library/threading.rst:494 msgid "Method representing the thread's activity." msgstr "" -#: ../../library/threading.rst:387 +#: ../../library/threading.rst:496 msgid "" "You may override this method in a subclass. The standard :meth:`run` method " "invokes the callable object passed to the object's constructor as the " @@ -522,17 +758,17 @@ msgid "" "the *args* and *kwargs* arguments, respectively." msgstr "" -#: ../../library/threading.rst:392 +#: ../../library/threading.rst:501 msgid "" -"Using list or tuple as the *args* argument which passed to the :class:" -"`Thread` could achieve the same effect." +"Using list or tuple as the *args* argument which passed to " +"the :class:`Thread` could achieve the same effect." msgstr "" -#: ../../library/threading.rst:395 +#: ../../library/threading.rst:504 msgid "Example::" msgstr "舉例來說: ::" -#: ../../library/threading.rst:397 +#: ../../library/threading.rst:506 msgid "" ">>> from threading import Thread\n" ">>> t = Thread(target=print, args=[1])\n" @@ -550,7 +786,7 @@ msgstr "" ">>> t.run()\n" "1" -#: ../../library/threading.rst:409 +#: ../../library/threading.rst:518 msgid "" "Wait until the thread terminates. This blocks the calling thread until the " "thread whose :meth:`~Thread.join` method is called terminates -- either " @@ -558,27 +794,27 @@ msgid "" "occurs." msgstr "" -#: ../../library/threading.rst:414 +#: ../../library/threading.rst:523 msgid "" "When the *timeout* argument is present and not ``None``, it should be a " "floating-point number specifying a timeout for the operation in seconds (or " "fractions thereof). As :meth:`~Thread.join` always returns ``None``, you " "must call :meth:`~Thread.is_alive` after :meth:`~Thread.join` to decide " -"whether a timeout happened -- if the thread is still alive, the :meth:" -"`~Thread.join` call timed out." +"whether a timeout happened -- if the thread is still alive, " +"the :meth:`~Thread.join` call timed out." msgstr "" -#: ../../library/threading.rst:421 +#: ../../library/threading.rst:530 msgid "" "When the *timeout* argument is not present or ``None``, the operation will " "block until the thread terminates." msgstr "" -#: ../../library/threading.rst:424 +#: ../../library/threading.rst:533 msgid "A thread can be joined many times." msgstr "" -#: ../../library/threading.rst:426 +#: ../../library/threading.rst:535 msgid "" ":meth:`~Thread.join` raises a :exc:`RuntimeError` if an attempt is made to " "join the current thread as that would cause a deadlock. It is also an error " @@ -586,20 +822,20 @@ msgid "" "do so raise the same exception." msgstr "" -#: ../../library/threading.rst:433 +#: ../../library/threading.rst:542 msgid "" "A string used for identification purposes only. It has no semantics. " "Multiple threads may be given the same name. The initial name is set by the " "constructor." msgstr "" -#: ../../library/threading.rst:440 +#: ../../library/threading.rst:549 msgid "" "Deprecated getter/setter API for :attr:`~Thread.name`; use it directly as a " "property instead." msgstr "" -#: ../../library/threading.rst:447 +#: ../../library/threading.rst:556 msgid "" "The 'thread identifier' of this thread or ``None`` if the thread has not " "been started. This is a nonzero integer. See the :func:`get_ident` " @@ -608,7 +844,7 @@ msgid "" "thread has exited." msgstr "" -#: ../../library/threading.rst:455 +#: ../../library/threading.rst:564 msgid "" "The Thread ID (``TID``) of this thread, as assigned by the OS (kernel). This " "is a non-negative integer, or ``None`` if the thread has not been started. " @@ -617,102 +853,102 @@ msgid "" "after which the value may be recycled by the OS)." msgstr "" -#: ../../library/threading.rst:464 +#: ../../library/threading.rst:573 msgid "" "Similar to Process IDs, Thread IDs are only valid (guaranteed unique system-" "wide) from the time the thread is created until the thread has been " "terminated." msgstr "" -#: ../../library/threading.rst:474 +#: ../../library/threading.rst:583 msgid "Return whether the thread is alive." msgstr "" -#: ../../library/threading.rst:476 +#: ../../library/threading.rst:585 msgid "" "This method returns ``True`` just before the :meth:`~Thread.run` method " "starts until just after the :meth:`~Thread.run` method terminates. The " "module function :func:`.enumerate` returns a list of all alive threads." msgstr "" -#: ../../library/threading.rst:482 +#: ../../library/threading.rst:591 msgid "" "A boolean value indicating whether this thread is a daemon thread (``True``) " "or not (``False``). This must be set before :meth:`~Thread.start` is " "called, otherwise :exc:`RuntimeError` is raised. Its initial value is " "inherited from the creating thread; the main thread is not a daemon thread " -"and therefore all threads created in the main thread default to :attr:" -"`~Thread.daemon` = ``False``." +"and therefore all threads created in the main thread default " +"to :attr:`~Thread.daemon` = ``False``." msgstr "" -#: ../../library/threading.rst:489 +#: ../../library/threading.rst:598 msgid "" "The entire Python program exits when no alive non-daemon threads are left." msgstr "" -#: ../../library/threading.rst:494 +#: ../../library/threading.rst:603 msgid "" "Deprecated getter/setter API for :attr:`~Thread.daemon`; use it directly as " "a property instead." msgstr "" -#: ../../library/threading.rst:503 +#: ../../library/threading.rst:612 msgid "Lock Objects" msgstr "Lock 物件" -#: ../../library/threading.rst:505 +#: ../../library/threading.rst:614 msgid "" "A primitive lock is a synchronization primitive that is not owned by a " "particular thread when locked. In Python, it is currently the lowest level " -"synchronization primitive available, implemented directly by the :mod:" -"`_thread` extension module." +"synchronization primitive available, implemented directly by " +"the :mod:`_thread` extension module." msgstr "" "原始鎖 (primitive lock) 是一種同步原語 (synchronization primitive),在鎖定時" -"不屬於特定執行緒。在 Python 中,它是目前可用的最低階同步原語,直接由 :mod:" -"`_thread` 擴充模組實作。" +"不屬於特定執行緒。在 Python 中,它是目前可用的最低階同步原語,直接" +"由 :mod:`_thread` 擴充模組實作。" -#: ../../library/threading.rst:510 +#: ../../library/threading.rst:619 msgid "" "A primitive lock is in one of two states, \"locked\" or \"unlocked\". It is " -"created in the unlocked state. It has two basic methods, :meth:`~Lock." -"acquire` and :meth:`~Lock.release`. When the state is unlocked, :meth:" -"`~Lock.acquire` changes the state to locked and returns immediately. When " -"the state is locked, :meth:`~Lock.acquire` blocks until a call to :meth:" -"`~Lock.release` in another thread changes it to unlocked, then the :meth:" -"`~Lock.acquire` call resets it to locked and returns. The :meth:`~Lock." -"release` method should only be called in the locked state; it changes the " -"state to unlocked and returns immediately. If an attempt is made to release " -"an unlocked lock, a :exc:`RuntimeError` will be raised." +"created in the unlocked state. It has two basic " +"methods, :meth:`~Lock.acquire` and :meth:`~Lock.release`. When the state is " +"unlocked, :meth:`~Lock.acquire` changes the state to locked and returns " +"immediately. When the state is locked, :meth:`~Lock.acquire` blocks until a " +"call to :meth:`~Lock.release` in another thread changes it to unlocked, then " +"the :meth:`~Lock.acquire` call resets it to locked and returns. " +"The :meth:`~Lock.release` method should only be called in the locked state; " +"it changes the state to unlocked and returns immediately. If an attempt is " +"made to release an unlocked lock, a :exc:`RuntimeError` will be raised." msgstr "" "原始鎖會處於兩種狀態之一:「鎖定 (locked)」或「未鎖定 (unclocked)」,建立時會" -"處於未鎖定狀態。它有兩個基本方法 :meth:`~Lock.acquire` 和 :meth:`~Lock." -"release`。當狀態為未鎖定時,:meth:`~Lock.acquire` 會將狀態變更為鎖定並立即回" -"傳。當狀態被鎖定時,:meth:`~Lock.acquire` 會阻塞 (block),直到另一個執行緒中" -"對 :meth:`~Lock.release` 的呼叫將其更改為未鎖定狀態,然後 :meth:`~Lock." -"acquire` 呼叫會將其重置為鎖定並回傳。:meth:`~Lock.release` 方法只能在鎖定狀態" -"下呼叫;它將狀態更改為未鎖定並立即回傳。如果嘗試釋放未鎖定的鎖,則會引發 :" -"exc:`RuntimeError`。" - -#: ../../library/threading.rst:521 +"處於未鎖定狀態。它有兩個基本方法 :meth:`~Lock.acquire` " +"和 :meth:`~Lock.release`。當狀態為未鎖定時,:meth:`~Lock.acquire` 會將狀態變" +"更為鎖定並立即回傳。當狀態被鎖定時,:meth:`~Lock.acquire` 會阻塞 (block),直" +"到另一個執行緒中對 :meth:`~Lock.release` 的呼叫將其更改為未鎖定狀態,然" +"後 :meth:`~Lock.acquire` 呼叫會將其重置為鎖定並回傳。:meth:`~Lock.release` 方" +"法只能在鎖定狀態下呼叫;它將狀態更改為未鎖定並立即回傳。如果嘗試釋放未鎖定的" +"鎖,則會引發 :exc:`RuntimeError`。" + +#: ../../library/threading.rst:630 msgid "Locks also support the :ref:`context management protocol `." msgstr "鎖也支援\\ :ref:`情境管理協定 `。" -#: ../../library/threading.rst:523 +#: ../../library/threading.rst:632 msgid "" "When more than one thread is blocked in :meth:`~Lock.acquire` waiting for " -"the state to turn to unlocked, only one thread proceeds when a :meth:`~Lock." -"release` call resets the state to unlocked; which one of the waiting threads " -"proceeds is not defined, and may vary across implementations." +"the state to turn to unlocked, only one thread proceeds when " +"a :meth:`~Lock.release` call resets the state to unlocked; which one of the " +"waiting threads proceeds is not defined, and may vary across implementations." msgstr "" -"當多個執行緒阻塞在 :meth:`~Lock.acquire` 中等待狀態轉變為未鎖定,此時若呼叫 :" -"meth:`~Lock.release` 將狀態重置為未鎖定,則只會有一個執行緒繼續進行;哪一個等" -"待執行緒會繼續進行是未定義的,並且可能因實作而異。" +"當多個執行緒阻塞在 :meth:`~Lock.acquire` 中等待狀態轉變為未鎖定,此時若呼" +"叫 :meth:`~Lock.release` 將狀態重置為未鎖定,則只會有一個執行緒繼續進行;哪一" +"個等待執行緒會繼續進行是未定義的,並且可能因實作而異。" -#: ../../library/threading.rst:528 +#: ../../library/threading.rst:637 msgid "All methods are executed atomically." msgstr "所有方法均以最小不可分割的操作方式 (atomically) 執行。" -#: ../../library/threading.rst:533 +#: ../../library/threading.rst:642 msgid "" "The class implementing primitive lock objects. Once a thread has acquired a " "lock, subsequent attempts to acquire it block, until it is released; any " @@ -721,7 +957,7 @@ msgstr "" "實作原始鎖物件的類別。一旦執行緒獲得了鎖,後續再嘗試獲得它就會被阻塞,直到鎖" "被釋放;任何執行緒都可以去釋放它。" -#: ../../library/threading.rst:537 +#: ../../library/threading.rst:646 msgid "" "``Lock`` is now a class. In earlier Pythons, ``Lock`` was a factory function " "which returned an instance of the underlying private lock type." @@ -729,11 +965,11 @@ msgstr "" "``Lock`` 現在是一個類別。在早期的 Python 中,``Lock`` 是一個會回傳底層私有鎖" "型別實例的工廠函式。" -#: ../../library/threading.rst:545 ../../library/threading.rst:636 +#: ../../library/threading.rst:654 ../../library/threading.rst:745 msgid "Acquire a lock, blocking or non-blocking." msgstr "阻塞或非阻塞地取得鎖。" -#: ../../library/threading.rst:547 +#: ../../library/threading.rst:656 msgid "" "When invoked with the *blocking* argument set to ``True`` (the default), " "block until the lock is unlocked, then set it to locked and return ``True``." @@ -741,7 +977,7 @@ msgstr "" "當以 *blocking* 引數設為 ``True``\\ (預設值)來叫用,將會阻塞直到鎖被解鎖," "然後將其設為鎖定並回傳 ``True``。" -#: ../../library/threading.rst:550 +#: ../../library/threading.rst:659 msgid "" "When invoked with the *blocking* argument set to ``False``, do not block. If " "a call with *blocking* set to ``True`` would block, return ``False`` " @@ -751,7 +987,7 @@ msgstr "" "``True`` 的呼叫會阻塞,則立即回傳 ``False``;否則將鎖設為鎖定並回傳 " "``True``。" -#: ../../library/threading.rst:554 +#: ../../library/threading.rst:663 msgid "" "When invoked with the floating-point *timeout* argument set to a positive " "value, block for at most the number of seconds specified by *timeout* and as " @@ -763,7 +999,7 @@ msgstr "" "塞 *timeout* 指定的秒數。``-1`` 的 *timeout* 引數代表指定為不會停止的等待。" "當 *blocking* 為 ``False`` 時禁止指定 *timeout*。" -#: ../../library/threading.rst:560 +#: ../../library/threading.rst:669 msgid "" "The return value is ``True`` if the lock is acquired successfully, ``False`` " "if not (for example if the *timeout* expired)." @@ -771,24 +1007,24 @@ msgstr "" "如果成功取得鎖,則回傳值為 ``True``,否則回傳值為 ``False``\\ (例如像是 " "*timeout* 已逾期)。" -#: ../../library/threading.rst:563 ../../library/threading.rst:674 -#: ../../library/threading.rst:921 +#: ../../library/threading.rst:672 ../../library/threading.rst:783 +#: ../../library/threading.rst:1030 msgid "The *timeout* parameter is new." msgstr "新的 *timeout* 參數。" -#: ../../library/threading.rst:566 +#: ../../library/threading.rst:675 msgid "" "Lock acquisition can now be interrupted by signals on POSIX if the " "underlying threading implementation supports it." msgstr "如果底層執行緒實作支援的話,鎖的取得現在可以被 POSIX 上的訊號中斷。" -#: ../../library/threading.rst:573 +#: ../../library/threading.rst:682 msgid "" "Release a lock. This can be called from any thread, not only the thread " "which has acquired the lock." msgstr "釋放鎖。這可以從任何執行緒呼叫,而不是只有獲得鎖的執行緒。" -#: ../../library/threading.rst:576 +#: ../../library/threading.rst:685 msgid "" "When the lock is locked, reset it to unlocked, and return. If any other " "threads are blocked waiting for the lock to become unlocked, allow exactly " @@ -797,23 +1033,23 @@ msgstr "" "當鎖被鎖定時,將其重置為未鎖定然後回傳。如果任何其他執行緒在等待鎖被解鎖時被" "阻塞,只允許其中一個執行緒繼續進行。" -#: ../../library/threading.rst:580 +#: ../../library/threading.rst:689 msgid "When invoked on an unlocked lock, a :exc:`RuntimeError` is raised." msgstr "當在未鎖定的鎖上叫用時,會引發 :exc:`RuntimeError`" -#: ../../library/threading.rst:582 ../../library/threading.rst:690 +#: ../../library/threading.rst:691 ../../library/threading.rst:799 msgid "There is no return value." msgstr "沒有回傳值。" -#: ../../library/threading.rst:586 +#: ../../library/threading.rst:695 msgid "Return ``True`` if the lock is acquired." msgstr "如果有取得了鎖,則回傳 ``True``。" -#: ../../library/threading.rst:593 +#: ../../library/threading.rst:702 msgid "RLock Objects" msgstr "RLock 物件" -#: ../../library/threading.rst:595 +#: ../../library/threading.rst:704 msgid "" "A reentrant lock is a synchronization primitive that may be acquired " "multiple times by the same thread. Internally, it uses the concepts of " @@ -826,26 +1062,26 @@ msgstr "" "「遞迴等級 (recursion level)」的概念。在鎖定狀態下,某個執行緒會擁有鎖;在未" "鎖定狀態下則沒有執行緒擁有它。" -#: ../../library/threading.rst:601 +#: ../../library/threading.rst:710 msgid "" -"Threads call a lock's :meth:`~RLock.acquire` method to lock it, and its :" -"meth:`~Lock.release` method to unlock it." +"Threads call a lock's :meth:`~RLock.acquire` method to lock it, and " +"its :meth:`~Lock.release` method to unlock it." msgstr "" -"執行緒呼叫鎖的 :meth:`~RLock.acquire` 方法來鎖定它,並呼叫它的 :meth:`~Lock." -"release` 方法來解鎖它。" +"執行緒呼叫鎖的 :meth:`~RLock.acquire` 方法來鎖定它,並呼叫它" +"的 :meth:`~Lock.release` 方法來解鎖它。" -#: ../../library/threading.rst:606 +#: ../../library/threading.rst:715 msgid "" "Reentrant locks support the :ref:`context management protocol `, " -"so it is recommended to use :keyword:`with` instead of manually calling :" -"meth:`~RLock.acquire` and :meth:`~RLock.release` to handle acquiring and " -"releasing the lock for a block of code." +"so it is recommended to use :keyword:`with` instead of manually " +"calling :meth:`~RLock.acquire` and :meth:`~RLock.release` to handle " +"acquiring and releasing the lock for a block of code." msgstr "" "可重入鎖支援\\ :ref:`情境管理協定`,因此建議使用 :keyword:`with` " "而不是手動呼叫 :meth:`~RLock.acquire` 和 :meth:`~RLock.release` 來對程式碼區" "塊處理鎖的獲得和釋放。" -#: ../../library/threading.rst:611 +#: ../../library/threading.rst:720 msgid "" "RLock's :meth:`~RLock.acquire`/:meth:`~RLock.release` call pairs may be " "nested, unlike Lock's :meth:`~Lock.acquire`/:meth:`~Lock.release`. Only the " @@ -858,7 +1094,7 @@ msgstr "" "個 :meth:`~RLock.release`\\ (最外面一對的 :meth:`~Lock.release`)會將鎖重置" "為未鎖定狀態,並允許在 :meth:`~RLock.acquire` 中阻塞的另一個執行緒繼續進行。" -#: ../../library/threading.rst:617 +#: ../../library/threading.rst:726 msgid "" ":meth:`~RLock.acquire`/:meth:`~RLock.release` must be used in pairs: each " "acquire must have a release in the thread that has acquired the lock. " @@ -869,7 +1105,7 @@ msgstr "" "已獲得鎖的執行緒中有一個釋放。如果鎖釋放的次數不能和取得的次數一樣的話,可能" "會導致死鎖 (deadlock)。" -#: ../../library/threading.rst:624 +#: ../../library/threading.rst:733 msgid "" "This class implements reentrant lock objects. A reentrant lock must be " "released by the thread that acquired it. Once a thread has acquired a " @@ -880,7 +1116,7 @@ msgstr "" "得了可重入鎖,同一個執行緒可以再次獲得它而不會阻塞;執行緒每次獲得它也都必須" "釋放它一次。" -#: ../../library/threading.rst:629 +#: ../../library/threading.rst:738 msgid "" "Note that ``RLock`` is actually a factory function which returns an instance " "of the most efficient version of the concrete RLock class that is supported " @@ -889,11 +1125,11 @@ msgstr "" "請注意,``RLock`` 實際上是一個工廠函式,它會回傳平台有支援的特定 RLock 類別的" "最高效率版本的實例。" -#: ../../library/threading.rst:640 +#: ../../library/threading.rst:749 msgid ":ref:`Using RLock as a context manager `" msgstr ":ref:`將 RLock 用作為情境管理器 `" -#: ../../library/threading.rst:641 +#: ../../library/threading.rst:750 msgid "" "Recommended over manual :meth:`!acquire` and :meth:`release` calls whenever " "practical." @@ -901,16 +1137,16 @@ msgstr "" "若是使用場景合理,和手動呼叫 :meth:`!acquire` 和 :meth:`release` 相比,會是更" "為推薦的使用方式。" -#: ../../library/threading.rst:645 +#: ../../library/threading.rst:754 msgid "" "When invoked with the *blocking* argument set to ``True`` (the default):" msgstr "當以 *blocking* 引數設為 ``True``\\ (預設值)來呼叫:" -#: ../../library/threading.rst:647 ../../library/threading.rst:659 +#: ../../library/threading.rst:756 ../../library/threading.rst:768 msgid "If no thread owns the lock, acquire the lock and return immediately." msgstr "如果沒有執行緒擁有鎖,則獲得鎖並立即回傳。" -#: ../../library/threading.rst:649 +#: ../../library/threading.rst:758 msgid "" "If another thread owns the lock, block until we are able to acquire lock, or " "*timeout*, if set to a positive float value." @@ -918,32 +1154,32 @@ msgstr "" "如果另一個執行緒擁有鎖,則阻塞直到能夠取得鎖,或者達到 *timeout*\\ (如果設定" "為正浮點值)。" -#: ../../library/threading.rst:652 +#: ../../library/threading.rst:761 msgid "" "If the same thread owns the lock, acquire the lock again, and return " "immediately. This is the difference between :class:`Lock` and :class:`!" "RLock`; :class:`Lock` handles this case the same as the previous, blocking " "until the lock can be acquired." msgstr "" -"如果同一個執行緒擁有鎖,則再次取得鎖,並立即回傳。這就是 :class:`Lock` 和 :" -"class:`!RLock` 之間的差別;:class:`Lock` 處理方式與上一種情況相同,會阻塞直到" -"能夠取得鎖。" +"如果同一個執行緒擁有鎖,則再次取得鎖,並立即回傳。這就是 :class:`Lock` " +"和 :class:`!RLock` 之間的差別;:class:`Lock` 處理方式與上一種情況相同,會阻塞" +"直到能夠取得鎖。" -#: ../../library/threading.rst:657 +#: ../../library/threading.rst:766 msgid "When invoked with the *blocking* argument set to ``False``:" msgstr "當以 *blocking* 引數設為 ``False`` 來呼叫:" -#: ../../library/threading.rst:661 +#: ../../library/threading.rst:770 msgid "If another thread owns the lock, return immediately." msgstr "如果另一個執行緒擁有該鎖,則立即回傳。" -#: ../../library/threading.rst:663 +#: ../../library/threading.rst:772 msgid "" "If the same thread owns the lock, acquire the lock again and return " "immediately." msgstr "如果同一個執行緒擁有鎖,則再次取得鎖並立即回傳。" -#: ../../library/threading.rst:666 +#: ../../library/threading.rst:775 msgid "" "In all cases, if the thread was able to acquire the lock, return ``True``. " "If the thread was unable to acquire the lock (i.e. if not blocking or the " @@ -952,7 +1188,7 @@ msgstr "" "在所有情況下,如果執行緒能夠取得鎖則回傳 ``True``。如果執行緒無法取得鎖(即沒" "有阻塞或已達超時限制)則回傳 ``False``。" -#: ../../library/threading.rst:670 +#: ../../library/threading.rst:779 msgid "" "If called multiple times, failing to call :meth:`~RLock.release` as many " "times may lead to deadlock. Consider using :class:`!RLock` as a context " @@ -961,7 +1197,7 @@ msgstr "" "如果多次呼叫,又未能呼叫相同次數的 :meth:`~RLock.release`,則可能會導致死鎖。" "考慮將 :class:`!RLock` 作為情境管理器使用,而不是直接呼叫 acquire/release。" -#: ../../library/threading.rst:680 +#: ../../library/threading.rst:789 msgid "" "Release a lock, decrementing the recursion level. If after the decrement it " "is zero, reset the lock to unlocked (not owned by any thread), and if any " @@ -973,20 +1209,20 @@ msgstr "" "並且如果任何其他執行緒被阻塞以等待鎖變成未鎖定狀態,則僅允許其中一個執行緒繼" "續進行。如果遞減後遞迴等級仍然非零,則鎖會保持鎖定並由呼叫它的執行緒所擁有。" -#: ../../library/threading.rst:686 +#: ../../library/threading.rst:795 msgid "" -"Only call this method when the calling thread owns the lock. A :exc:" -"`RuntimeError` is raised if this method is called when the lock is not " -"acquired." +"Only call this method when the calling thread owns the lock. " +"A :exc:`RuntimeError` is raised if this method is called when the lock is " +"not acquired." msgstr "" -"僅當呼叫的執行緒擁有鎖時才能呼叫此方法。如果在未取得鎖時呼叫此方法則會引發 :" -"exc:`RuntimeError`。" +"僅當呼叫的執行緒擁有鎖時才能呼叫此方法。如果在未取得鎖時呼叫此方法則會引" +"發 :exc:`RuntimeError`。" -#: ../../library/threading.rst:696 +#: ../../library/threading.rst:805 msgid "Condition Objects" msgstr "" -#: ../../library/threading.rst:698 +#: ../../library/threading.rst:807 msgid "" "A condition variable is always associated with some kind of lock; this can " "be passed in or one will be created by default. Passing one in is useful " @@ -994,32 +1230,33 @@ msgid "" "of the condition object: you don't have to track it separately." msgstr "" -#: ../../library/threading.rst:703 +#: ../../library/threading.rst:812 msgid "" "A condition variable obeys the :ref:`context management protocol `: using the ``with`` statement acquires the associated lock for the " -"duration of the enclosed block. The :meth:`~Condition.acquire` and :meth:" -"`~Condition.release` methods also call the corresponding methods of the " -"associated lock." +"duration of the enclosed block. The :meth:`~Condition.acquire` " +"and :meth:`~Condition.release` methods also call the corresponding methods " +"of the associated lock." msgstr "" -#: ../../library/threading.rst:709 +#: ../../library/threading.rst:818 msgid "" -"Other methods must be called with the associated lock held. The :meth:" -"`~Condition.wait` method releases the lock, and then blocks until another " -"thread awakens it by calling :meth:`~Condition.notify` or :meth:`~Condition." -"notify_all`. Once awakened, :meth:`~Condition.wait` re-acquires the lock " -"and returns. It is also possible to specify a timeout." +"Other methods must be called with the associated lock held. " +"The :meth:`~Condition.wait` method releases the lock, and then blocks until " +"another thread awakens it by calling :meth:`~Condition.notify` " +"or :meth:`~Condition.notify_all`. Once awakened, :meth:`~Condition.wait` re-" +"acquires the lock and returns. It is also possible to specify a timeout." msgstr "" -#: ../../library/threading.rst:715 +#: ../../library/threading.rst:824 msgid "" "The :meth:`~Condition.notify` method wakes up one of the threads waiting for " -"the condition variable, if any are waiting. The :meth:`~Condition." -"notify_all` method wakes up all threads waiting for the condition variable." +"the condition variable, if any are waiting. " +"The :meth:`~Condition.notify_all` method wakes up all threads waiting for " +"the condition variable." msgstr "" -#: ../../library/threading.rst:719 +#: ../../library/threading.rst:828 msgid "" "Note: the :meth:`~Condition.notify` and :meth:`~Condition.notify_all` " "methods don't release the lock; this means that the thread or threads " @@ -1028,19 +1265,19 @@ msgid "" "or :meth:`~Condition.notify_all` finally relinquishes ownership of the lock." msgstr "" -#: ../../library/threading.rst:725 +#: ../../library/threading.rst:834 msgid "" "The typical programming style using condition variables uses the lock to " "synchronize access to some shared state; threads that are interested in a " "particular change of state call :meth:`~Condition.wait` repeatedly until " -"they see the desired state, while threads that modify the state call :meth:" -"`~Condition.notify` or :meth:`~Condition.notify_all` when they change the " -"state in such a way that it could possibly be a desired state for one of the " -"waiters. For example, the following code is a generic producer-consumer " -"situation with unlimited buffer capacity::" +"they see the desired state, while threads that modify the state " +"call :meth:`~Condition.notify` or :meth:`~Condition.notify_all` when they " +"change the state in such a way that it could possibly be a desired state for " +"one of the waiters. For example, the following code is a generic producer-" +"consumer situation with unlimited buffer capacity::" msgstr "" -#: ../../library/threading.rst:734 +#: ../../library/threading.rst:843 msgid "" "# Consume one item\n" "with cv:\n" @@ -1054,17 +1291,17 @@ msgid "" " cv.notify()" msgstr "" -#: ../../library/threading.rst:745 +#: ../../library/threading.rst:854 msgid "" "The ``while`` loop checking for the application's condition is necessary " "because :meth:`~Condition.wait` can return after an arbitrary long time, and " "the condition which prompted the :meth:`~Condition.notify` call may no " -"longer hold true. This is inherent to multi-threaded programming. The :" -"meth:`~Condition.wait_for` method can be used to automate the condition " +"longer hold true. This is inherent to multi-threaded programming. " +"The :meth:`~Condition.wait_for` method can be used to automate the condition " "checking, and eases the computation of timeouts::" msgstr "" -#: ../../library/threading.rst:752 +#: ../../library/threading.rst:861 msgid "" "# Consume an item\n" "with cv:\n" @@ -1072,54 +1309,54 @@ msgid "" " get_an_available_item()" msgstr "" -#: ../../library/threading.rst:757 +#: ../../library/threading.rst:866 msgid "" -"To choose between :meth:`~Condition.notify` and :meth:`~Condition." -"notify_all`, consider whether one state change can be interesting for only " -"one or several waiting threads. E.g. in a typical producer-consumer " -"situation, adding one item to the buffer only needs to wake up one consumer " -"thread." +"To choose between :meth:`~Condition.notify` " +"and :meth:`~Condition.notify_all`, consider whether one state change can be " +"interesting for only one or several waiting threads. E.g. in a typical " +"producer-consumer situation, adding one item to the buffer only needs to " +"wake up one consumer thread." msgstr "" -#: ../../library/threading.rst:765 +#: ../../library/threading.rst:874 msgid "" "This class implements condition variable objects. A condition variable " "allows one or more threads to wait until they are notified by another thread." msgstr "" -#: ../../library/threading.rst:768 +#: ../../library/threading.rst:877 msgid "" "If the *lock* argument is given and not ``None``, it must be a :class:`Lock` " "or :class:`RLock` object, and it is used as the underlying lock. Otherwise, " "a new :class:`RLock` object is created and used as the underlying lock." msgstr "" -#: ../../library/threading.rst:772 ../../library/threading.rst:896 -#: ../../library/threading.rst:942 ../../library/threading.rst:994 -#: ../../library/threading.rst:1062 +#: ../../library/threading.rst:881 ../../library/threading.rst:1005 +#: ../../library/threading.rst:1051 ../../library/threading.rst:1103 +#: ../../library/threading.rst:1171 msgid "changed from a factory function to a class." msgstr "" -#: ../../library/threading.rst:777 +#: ../../library/threading.rst:886 msgid "" "Acquire the underlying lock. This method calls the corresponding method on " "the underlying lock; the return value is whatever that method returns." msgstr "" -#: ../../library/threading.rst:782 +#: ../../library/threading.rst:891 msgid "" "Release the underlying lock. This method calls the corresponding method on " "the underlying lock; there is no return value." msgstr "" -#: ../../library/threading.rst:787 +#: ../../library/threading.rst:896 msgid "" "Wait until notified or until a timeout occurs. If the calling thread has not " "acquired the lock when this method is called, a :exc:`RuntimeError` is " "raised." msgstr "" -#: ../../library/threading.rst:791 +#: ../../library/threading.rst:900 msgid "" "This method releases the underlying lock, and then blocks until it is " "awakened by a :meth:`notify` or :meth:`notify_all` call for the same " @@ -1127,41 +1364,41 @@ msgid "" "Once awakened or timed out, it re-acquires the lock and returns." msgstr "" -#: ../../library/threading.rst:796 +#: ../../library/threading.rst:905 msgid "" "When the *timeout* argument is present and not ``None``, it should be a " "floating-point number specifying a timeout for the operation in seconds (or " "fractions thereof)." msgstr "" -#: ../../library/threading.rst:800 +#: ../../library/threading.rst:909 msgid "" -"When the underlying lock is an :class:`RLock`, it is not released using its :" -"meth:`release` method, since this may not actually unlock the lock when it " -"was acquired multiple times recursively. Instead, an internal interface of " -"the :class:`RLock` class is used, which really unlocks it even when it has " -"been recursively acquired several times. Another internal interface is then " -"used to restore the recursion level when the lock is reacquired." +"When the underlying lock is an :class:`RLock`, it is not released using " +"its :meth:`release` method, since this may not actually unlock the lock when " +"it was acquired multiple times recursively. Instead, an internal interface " +"of the :class:`RLock` class is used, which really unlocks it even when it " +"has been recursively acquired several times. Another internal interface is " +"then used to restore the recursion level when the lock is reacquired." msgstr "" -#: ../../library/threading.rst:808 +#: ../../library/threading.rst:917 msgid "" "The return value is ``True`` unless a given *timeout* expired, in which case " "it is ``False``." msgstr "" -#: ../../library/threading.rst:811 ../../library/threading.rst:1027 +#: ../../library/threading.rst:920 ../../library/threading.rst:1136 msgid "Previously, the method always returned ``None``." msgstr "" -#: ../../library/threading.rst:816 +#: ../../library/threading.rst:925 msgid "" "Wait until a condition evaluates to true. *predicate* should be a callable " "which result will be interpreted as a boolean value. A *timeout* may be " "provided giving the maximum time to wait." msgstr "" -#: ../../library/threading.rst:820 +#: ../../library/threading.rst:929 msgid "" "This utility method may call :meth:`wait` repeatedly until the predicate is " "satisfied, or until a timeout occurs. The return value is the last return " @@ -1169,13 +1406,13 @@ msgid "" "out." msgstr "" -#: ../../library/threading.rst:825 +#: ../../library/threading.rst:934 msgid "" "Ignoring the timeout feature, calling this method is roughly equivalent to " "writing::" msgstr "" -#: ../../library/threading.rst:828 +#: ../../library/threading.rst:937 msgid "" "while not predicate():\n" " cv.wait()" @@ -1183,27 +1420,27 @@ msgstr "" "while not predicate():\n" " cv.wait()" -#: ../../library/threading.rst:831 +#: ../../library/threading.rst:940 msgid "" "Therefore, the same rules apply as with :meth:`wait`: The lock must be held " "when called and is re-acquired on return. The predicate is evaluated with " "the lock held." msgstr "" -#: ../../library/threading.rst:839 +#: ../../library/threading.rst:948 msgid "" "By default, wake up one thread waiting on this condition, if any. If the " -"calling thread has not acquired the lock when this method is called, a :exc:" -"`RuntimeError` is raised." +"calling thread has not acquired the lock when this method is called, " +"a :exc:`RuntimeError` is raised." msgstr "" -#: ../../library/threading.rst:843 +#: ../../library/threading.rst:952 msgid "" "This method wakes up at most *n* of the threads waiting for the condition " "variable; it is a no-op if no threads are waiting." msgstr "" -#: ../../library/threading.rst:846 +#: ../../library/threading.rst:955 msgid "" "The current implementation wakes up exactly *n* threads, if at least *n* " "threads are waiting. However, it's not safe to rely on this behavior. A " @@ -1211,52 +1448,52 @@ msgid "" "threads." msgstr "" -#: ../../library/threading.rst:851 +#: ../../library/threading.rst:960 msgid "" "Note: an awakened thread does not actually return from its :meth:`wait` call " "until it can reacquire the lock. Since :meth:`notify` does not release the " "lock, its caller should." msgstr "" -#: ../../library/threading.rst:857 +#: ../../library/threading.rst:966 msgid "" -"Wake up all threads waiting on this condition. This method acts like :meth:" -"`notify`, but wakes up all waiting threads instead of one. If the calling " -"thread has not acquired the lock when this method is called, a :exc:" -"`RuntimeError` is raised." +"Wake up all threads waiting on this condition. This method acts " +"like :meth:`notify`, but wakes up all waiting threads instead of one. If the " +"calling thread has not acquired the lock when this method is called, " +"a :exc:`RuntimeError` is raised." msgstr "" -#: ../../library/threading.rst:862 +#: ../../library/threading.rst:971 msgid "The method ``notifyAll`` is a deprecated alias for this method." msgstr "" -#: ../../library/threading.rst:868 +#: ../../library/threading.rst:977 msgid "Semaphore Objects" msgstr "" -#: ../../library/threading.rst:870 +#: ../../library/threading.rst:979 msgid "" "This is one of the oldest synchronization primitives in the history of " "computer science, invented by the early Dutch computer scientist Edsger W. " -"Dijkstra (he used the names ``P()`` and ``V()`` instead of :meth:`~Semaphore." -"acquire` and :meth:`~Semaphore.release`)." +"Dijkstra (he used the names ``P()`` and ``V()`` instead " +"of :meth:`~Semaphore.acquire` and :meth:`~Semaphore.release`)." msgstr "" -#: ../../library/threading.rst:875 +#: ../../library/threading.rst:984 msgid "" -"A semaphore manages an internal counter which is decremented by each :meth:" -"`~Semaphore.acquire` call and incremented by each :meth:`~Semaphore.release` " -"call. The counter can never go below zero; when :meth:`~Semaphore.acquire` " -"finds that it is zero, it blocks, waiting until some other thread calls :" -"meth:`~Semaphore.release`." +"A semaphore manages an internal counter which is decremented by " +"each :meth:`~Semaphore.acquire` call and incremented by " +"each :meth:`~Semaphore.release` call. The counter can never go below zero; " +"when :meth:`~Semaphore.acquire` finds that it is zero, it blocks, waiting " +"until some other thread calls :meth:`~Semaphore.release`." msgstr "" -#: ../../library/threading.rst:881 +#: ../../library/threading.rst:990 msgid "" "Semaphores also support the :ref:`context management protocol `." msgstr "" -#: ../../library/threading.rst:886 +#: ../../library/threading.rst:995 msgid "" "This class implements semaphore objects. A semaphore manages an atomic " "counter representing the number of :meth:`release` calls minus the number " @@ -1265,75 +1502,75 @@ msgid "" "If not given, *value* defaults to 1." msgstr "" -#: ../../library/threading.rst:892 +#: ../../library/threading.rst:1001 msgid "" "The optional argument gives the initial *value* for the internal counter; it " "defaults to ``1``. If the *value* given is less than 0, :exc:`ValueError` is " "raised." msgstr "" -#: ../../library/threading.rst:901 +#: ../../library/threading.rst:1010 msgid "Acquire a semaphore." msgstr "" -#: ../../library/threading.rst:903 +#: ../../library/threading.rst:1012 msgid "When invoked without arguments:" msgstr "" -#: ../../library/threading.rst:905 +#: ../../library/threading.rst:1014 msgid "" "If the internal counter is larger than zero on entry, decrement it by one " "and return ``True`` immediately." msgstr "" -#: ../../library/threading.rst:907 +#: ../../library/threading.rst:1016 msgid "" -"If the internal counter is zero on entry, block until awoken by a call to :" -"meth:`~Semaphore.release`. Once awoken (and the counter is greater than 0), " -"decrement the counter by 1 and return ``True``. Exactly one thread will be " -"awoken by each call to :meth:`~Semaphore.release`. The order in which " +"If the internal counter is zero on entry, block until awoken by a call " +"to :meth:`~Semaphore.release`. Once awoken (and the counter is greater than " +"0), decrement the counter by 1 and return ``True``. Exactly one thread will " +"be awoken by each call to :meth:`~Semaphore.release`. The order in which " "threads are awoken should not be relied on." msgstr "" -#: ../../library/threading.rst:913 +#: ../../library/threading.rst:1022 msgid "" "When invoked with *blocking* set to ``False``, do not block. If a call " "without an argument would block, return ``False`` immediately; otherwise, do " "the same thing as when called without arguments, and return ``True``." msgstr "" -#: ../../library/threading.rst:917 +#: ../../library/threading.rst:1026 msgid "" "When invoked with a *timeout* other than ``None``, it will block for at most " "*timeout* seconds. If acquire does not complete successfully in that " "interval, return ``False``. Return ``True`` otherwise." msgstr "" -#: ../../library/threading.rst:926 +#: ../../library/threading.rst:1035 msgid "" "Release a semaphore, incrementing the internal counter by *n*. When it was " "zero on entry and other threads are waiting for it to become larger than " "zero again, wake up *n* of those threads." msgstr "" -#: ../../library/threading.rst:930 +#: ../../library/threading.rst:1039 msgid "Added the *n* parameter to release multiple waiting threads at once." msgstr "" -#: ../../library/threading.rst:936 +#: ../../library/threading.rst:1045 msgid "" "Class implementing bounded semaphore objects. A bounded semaphore checks to " -"make sure its current value doesn't exceed its initial value. If it does, :" -"exc:`ValueError` is raised. In most situations semaphores are used to guard " -"resources with limited capacity. If the semaphore is released too many " -"times it's a sign of a bug. If not given, *value* defaults to 1." +"make sure its current value doesn't exceed its initial value. If it " +"does, :exc:`ValueError` is raised. In most situations semaphores are used to " +"guard resources with limited capacity. If the semaphore is released too " +"many times it's a sign of a bug. If not given, *value* defaults to 1." msgstr "" -#: ../../library/threading.rst:949 +#: ../../library/threading.rst:1058 msgid ":class:`Semaphore` Example" msgstr ":class:`Semaphore` 範例" -#: ../../library/threading.rst:951 +#: ../../library/threading.rst:1060 msgid "" "Semaphores are often used to guard resources with limited capacity, for " "example, a database server. In any situation where the size of the resource " @@ -1341,7 +1578,7 @@ msgid "" "threads, your main thread would initialize the semaphore::" msgstr "" -#: ../../library/threading.rst:956 +#: ../../library/threading.rst:1065 msgid "" "maxconnections = 5\n" "# ...\n" @@ -1351,13 +1588,13 @@ msgstr "" "# ...\n" "pool_sema = BoundedSemaphore(value=maxconnections)" -#: ../../library/threading.rst:960 +#: ../../library/threading.rst:1069 msgid "" "Once spawned, worker threads call the semaphore's acquire and release " "methods when they need to connect to the server::" msgstr "" -#: ../../library/threading.rst:963 +#: ../../library/threading.rst:1072 msgid "" "with pool_sema:\n" " conn = connectdb()\n" @@ -1373,61 +1610,62 @@ msgstr "" " finally:\n" " conn.close()" -#: ../../library/threading.rst:970 +#: ../../library/threading.rst:1079 msgid "" "The use of a bounded semaphore reduces the chance that a programming error " "which causes the semaphore to be released more than it's acquired will go " "undetected." msgstr "" -#: ../../library/threading.rst:977 +#: ../../library/threading.rst:1086 msgid "Event Objects" msgstr "" -#: ../../library/threading.rst:979 +#: ../../library/threading.rst:1088 msgid "" "This is one of the simplest mechanisms for communication between threads: " "one thread signals an event and other threads wait for it." msgstr "" -#: ../../library/threading.rst:982 +#: ../../library/threading.rst:1091 msgid "" -"An event object manages an internal flag that can be set to true with the :" -"meth:`~Event.set` method and reset to false with the :meth:`~Event.clear` " -"method. The :meth:`~Event.wait` method blocks until the flag is true." +"An event object manages an internal flag that can be set to true with " +"the :meth:`~Event.set` method and reset to false with " +"the :meth:`~Event.clear` method. The :meth:`~Event.wait` method blocks " +"until the flag is true." msgstr "" -#: ../../library/threading.rst:989 +#: ../../library/threading.rst:1098 msgid "" "Class implementing event objects. An event manages a flag that can be set " -"to true with the :meth:`~Event.set` method and reset to false with the :meth:" -"`clear` method. The :meth:`wait` method blocks until the flag is true. The " -"flag is initially false." +"to true with the :meth:`~Event.set` method and reset to false with " +"the :meth:`clear` method. The :meth:`wait` method blocks until the flag is " +"true. The flag is initially false." msgstr "" -#: ../../library/threading.rst:999 +#: ../../library/threading.rst:1108 msgid "Return ``True`` if and only if the internal flag is true." msgstr "" -#: ../../library/threading.rst:1001 +#: ../../library/threading.rst:1110 msgid "The method ``isSet`` is a deprecated alias for this method." msgstr "" -#: ../../library/threading.rst:1005 +#: ../../library/threading.rst:1114 msgid "" "Set the internal flag to true. All threads waiting for it to become true are " "awakened. Threads that call :meth:`wait` once the flag is true will not " "block at all." msgstr "" -#: ../../library/threading.rst:1011 +#: ../../library/threading.rst:1120 msgid "" "Reset the internal flag to false. Subsequently, threads calling :meth:`wait` " "will block until :meth:`.set` is called to set the internal flag to true " "again." msgstr "" -#: ../../library/threading.rst:1017 +#: ../../library/threading.rst:1126 msgid "" "Block as long as the internal flag is false and the timeout, if given, has " "not expired. The return value represents the reason that this blocking " @@ -1436,26 +1674,26 @@ msgid "" "become true within the given wait time." msgstr "" -#: ../../library/threading.rst:1023 +#: ../../library/threading.rst:1132 msgid "" "When the timeout argument is present and not ``None``, it should be a " "floating-point number specifying a timeout for the operation in seconds, or " "fractions thereof." msgstr "" -#: ../../library/threading.rst:1034 +#: ../../library/threading.rst:1143 msgid "Timer Objects" msgstr "" -#: ../../library/threading.rst:1036 +#: ../../library/threading.rst:1145 msgid "" "This class represents an action that should be run only after a certain " -"amount of time has passed --- a timer. :class:`Timer` is a subclass of :" -"class:`Thread` and as such also functions as an example of creating custom " -"threads." +"amount of time has passed --- a timer. :class:`Timer` is a subclass " +"of :class:`Thread` and as such also functions as an example of creating " +"custom threads." msgstr "" -#: ../../library/threading.rst:1040 +#: ../../library/threading.rst:1149 msgid "" "Timers are started, as with threads, by calling their :meth:`Timer.start " "` method. The timer can be stopped (before its action has " @@ -1464,11 +1702,11 @@ msgid "" "interval specified by the user." msgstr "" -#: ../../library/threading.rst:1046 +#: ../../library/threading.rst:1155 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/threading.rst:1048 +#: ../../library/threading.rst:1157 msgid "" "def hello():\n" " print(\"hello, world\")\n" @@ -1482,7 +1720,7 @@ msgstr "" "t = Timer(30.0, hello)\n" "t.start() # 30 秒後會印出 \"hello, world\"" -#: ../../library/threading.rst:1057 +#: ../../library/threading.rst:1166 msgid "" "Create a timer that will run *function* with arguments *args* and keyword " "arguments *kwargs*, after *interval* seconds have passed. If *args* is " @@ -1490,17 +1728,17 @@ msgid "" "``None`` (the default) then an empty dict will be used." msgstr "" -#: ../../library/threading.rst:1067 +#: ../../library/threading.rst:1176 msgid "" "Stop the timer, and cancel the execution of the timer's action. This will " "only work if the timer is still in its waiting stage." msgstr "" -#: ../../library/threading.rst:1072 +#: ../../library/threading.rst:1181 msgid "Barrier Objects" msgstr "" -#: ../../library/threading.rst:1076 +#: ../../library/threading.rst:1185 msgid "" "This class provides a simple synchronization primitive for use by a fixed " "number of threads that need to wait for each other. Each of the threads " @@ -1509,18 +1747,18 @@ msgid "" "calls. At this point, the threads are released simultaneously." msgstr "" -#: ../../library/threading.rst:1082 +#: ../../library/threading.rst:1191 msgid "" "The barrier can be reused any number of times for the same number of threads." msgstr "" -#: ../../library/threading.rst:1084 +#: ../../library/threading.rst:1193 msgid "" "As an example, here is a simple way to synchronize a client and server " "thread::" msgstr "" -#: ../../library/threading.rst:1086 +#: ../../library/threading.rst:1195 msgid "" "b = Barrier(2, timeout=5)\n" "\n" @@ -1552,7 +1790,7 @@ msgstr "" " connection = make_connection()\n" " process_client_connection(connection)" -#: ../../library/threading.rst:1104 +#: ../../library/threading.rst:1213 msgid "" "Create a barrier object for *parties* number of threads. An *action*, when " "provided, is a callable to be called by one of the threads when they are " @@ -1560,7 +1798,7 @@ msgid "" "the :meth:`wait` method." msgstr "" -#: ../../library/threading.rst:1111 +#: ../../library/threading.rst:1220 msgid "" "Pass the barrier. When all the threads party to the barrier have called " "this function, they are all released simultaneously. If a *timeout* is " @@ -1568,14 +1806,14 @@ msgid "" "constructor." msgstr "" -#: ../../library/threading.rst:1116 +#: ../../library/threading.rst:1225 msgid "" "The return value is an integer in the range 0 to *parties* -- 1, different " "for each thread. This can be used to select a thread to do some special " "housekeeping, e.g.::" msgstr "" -#: ../../library/threading.rst:1120 +#: ../../library/threading.rst:1229 msgid "" "i = barrier.wait()\n" "if i == 0:\n" @@ -1587,37 +1825,37 @@ msgstr "" " # 只會有一個執行緒會印出這個\n" " print(\"passed the barrier\")" -#: ../../library/threading.rst:1125 +#: ../../library/threading.rst:1234 msgid "" "If an *action* was provided to the constructor, one of the threads will have " "called it prior to being released. Should this call raise an error, the " "barrier is put into the broken state." msgstr "" -#: ../../library/threading.rst:1129 +#: ../../library/threading.rst:1238 msgid "If the call times out, the barrier is put into the broken state." msgstr "" -#: ../../library/threading.rst:1131 +#: ../../library/threading.rst:1240 msgid "" "This method may raise a :class:`BrokenBarrierError` exception if the barrier " "is broken or reset while a thread is waiting." msgstr "" -#: ../../library/threading.rst:1136 +#: ../../library/threading.rst:1245 msgid "" "Return the barrier to the default, empty state. Any threads waiting on it " "will receive the :class:`BrokenBarrierError` exception." msgstr "" -#: ../../library/threading.rst:1139 +#: ../../library/threading.rst:1248 msgid "" "Note that using this function may require some external synchronization if " "there are other threads whose state is unknown. If a barrier is broken it " "may be better to just leave it and create a new one." msgstr "" -#: ../../library/threading.rst:1145 +#: ../../library/threading.rst:1254 msgid "" "Put the barrier into a broken state. This causes any active or future calls " "to :meth:`wait` to fail with the :class:`BrokenBarrierError`. Use this for " @@ -1625,36 +1863,36 @@ msgid "" "application." msgstr "" -#: ../../library/threading.rst:1150 +#: ../../library/threading.rst:1259 msgid "" "It may be preferable to simply create the barrier with a sensible *timeout* " "value to automatically guard against one of the threads going awry." msgstr "" -#: ../../library/threading.rst:1156 +#: ../../library/threading.rst:1265 msgid "The number of threads required to pass the barrier." msgstr "" -#: ../../library/threading.rst:1160 +#: ../../library/threading.rst:1269 msgid "The number of threads currently waiting in the barrier." msgstr "" -#: ../../library/threading.rst:1164 +#: ../../library/threading.rst:1273 msgid "A boolean that is ``True`` if the barrier is in the broken state." msgstr "" -#: ../../library/threading.rst:1169 +#: ../../library/threading.rst:1278 msgid "" -"This exception, a subclass of :exc:`RuntimeError`, is raised when the :class:" -"`Barrier` object is reset or broken." +"This exception, a subclass of :exc:`RuntimeError`, is raised when " +"the :class:`Barrier` object is reset or broken." msgstr "" -#: ../../library/threading.rst:1176 +#: ../../library/threading.rst:1285 msgid "" "Using locks, conditions, and semaphores in the :keyword:`!with` statement" msgstr "" -#: ../../library/threading.rst:1178 +#: ../../library/threading.rst:1287 msgid "" "All of the objects provided by this module that have ``acquire`` and " "``release`` methods can be used as context managers for a :keyword:`with` " @@ -1663,7 +1901,7 @@ msgid "" "following snippet::" msgstr "" -#: ../../library/threading.rst:1184 +#: ../../library/threading.rst:1293 msgid "" "with some_lock:\n" " # do something..." @@ -1671,11 +1909,11 @@ msgstr "" "with some_lock:\n" " # 做某些事情..." -#: ../../library/threading.rst:1187 +#: ../../library/threading.rst:1296 msgid "is equivalent to::" msgstr "" -#: ../../library/threading.rst:1189 +#: ../../library/threading.rst:1298 msgid "" "some_lock.acquire()\n" "try:\n" @@ -1689,11 +1927,11 @@ msgstr "" "finally:\n" " some_lock.release()" -#: ../../library/threading.rst:1195 +#: ../../library/threading.rst:1304 msgid "" -"Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`, :class:" -"`Semaphore`, and :class:`BoundedSemaphore` objects may be used as :keyword:" -"`with` statement context managers." +"Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`, :class:`Semaphore`, " +"and :class:`BoundedSemaphore` objects may be used as :keyword:`with` " +"statement context managers." msgstr "" #: ../../library/threading.rst:158 ../../library/threading.rst:176 @@ -1707,3 +1945,10 @@ msgstr "debugger(除錯器)" #: ../../library/threading.rst:187 ../../library/threading.rst:205 msgid "profile function" msgstr "" + +#~ msgid "" +#~ "mydata = threading.local()\n" +#~ "mydata.x = 1" +#~ msgstr "" +#~ "mydata = threading.local()\n" +#~ "mydata.x = 1" diff --git a/library/typing.po b/library/typing.po index 68cfc42bf8..2306bfda2b 100644 --- a/library/typing.po +++ b/library/typing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-03 00:14+0000\n" +"POT-Creation-Date: 2025-05-06 02:41+0000\n" "PO-Revision-Date: 2024-07-11 11:12+0800\n" "Last-Translator: Li-Hung Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -387,8 +387,8 @@ msgstr "" "註釋。 ``Callable[[int], str]`` 象徵為一個函式,可以接受一個型別" "為 :class:`int` 的引數,並回傳一個 :class:`str`。" -#: ../../library/typing.rst:215 ../../library/typing.rst:3121 -#: ../../library/typing.rst:3301 +#: ../../library/typing.rst:215 ../../library/typing.rst:3161 +#: ../../library/typing.rst:3341 msgid "For example:" msgstr "舉例來說:" @@ -492,7 +492,7 @@ msgstr "" "``Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable], " "ReturnType]`` 的形式。" -#: ../../library/typing.rst:285 ../../library/typing.rst:3791 +#: ../../library/typing.rst:285 ../../library/typing.rst:3831 msgid "" "``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. " "See :pep:`612` for more details." @@ -1467,10 +1467,10 @@ msgstr "" "不可以將此兩種混合。" #: ../../library/typing.rst:868 ../../library/typing.rst:986 -#: ../../library/typing.rst:1043 ../../library/typing.rst:1209 -#: ../../library/typing.rst:1270 ../../library/typing.rst:1312 -#: ../../library/typing.rst:1513 ../../library/typing.rst:1574 -#: ../../library/typing.rst:3058 ../../library/typing.rst:3286 +#: ../../library/typing.rst:1043 ../../library/typing.rst:1215 +#: ../../library/typing.rst:1302 ../../library/typing.rst:1344 +#: ../../library/typing.rst:1553 ../../library/typing.rst:1614 +#: ../../library/typing.rst:3098 ../../library/typing.rst:3326 msgid "For example::" msgstr "舉例來說: ::" @@ -1538,7 +1538,7 @@ msgstr "" "此。然而,若是一個型別僅為 ``str`` 的物件則不相容。一個字串若是透過組合多個 " "``LiteralString`` 型別的物件建立,則此字串也可以視為 ``LiteralString``。" -#: ../../library/typing.rst:912 ../../library/typing.rst:2145 +#: ../../library/typing.rst:912 ../../library/typing.rst:2185 msgid "Example:" msgstr "舉例來說: ::" @@ -1841,53 +1841,67 @@ msgid "Union[Union[int, str], float] == Union[int, str, float]" msgstr "Union[Union[int, str], float] == Union[int, str, float]" #: ../../library/typing.rst:1101 +msgid "" +"However, this does not apply to unions referenced through a type alias, to " +"avoid forcing evaluation of the underlying :class:`TypeAliasType`::" +msgstr "" + +#: ../../library/typing.rst:1104 +msgid "" +"type A = Union[int, str]\n" +"Union[A, float] != Union[int, str, float]" +msgstr "" +"type A = Union[int, str]\n" +"Union[A, float] != Union[int, str, float]" + +#: ../../library/typing.rst:1107 msgid "Unions of a single argument vanish, e.g.::" msgstr "單一引數的聯集會消失不見,舉例來說: ::" -#: ../../library/typing.rst:1103 +#: ../../library/typing.rst:1109 msgid "Union[int] == int # The constructor actually returns int" -msgstr "Union[int] == int # The constructor actually returns int" +msgstr "Union[int] == int # 實際上建構函式會回傳 int" -#: ../../library/typing.rst:1105 +#: ../../library/typing.rst:1111 ../../library/typing.rst:1245 msgid "Redundant arguments are skipped, e.g.::" msgstr "多餘的引數會被略過,舉例來說: ::" -#: ../../library/typing.rst:1107 +#: ../../library/typing.rst:1113 msgid "Union[int, str, int] == Union[int, str] == int | str" msgstr "Union[int, str, int] == Union[int, str] == int | str" -#: ../../library/typing.rst:1109 +#: ../../library/typing.rst:1115 msgid "When comparing unions, the argument order is ignored, e.g.::" msgstr "當比較聯集時,引數的順序會被忽略,舉例來說: ::" -#: ../../library/typing.rst:1111 +#: ../../library/typing.rst:1117 msgid "Union[int, str] == Union[str, int]" msgstr "Union[int, str] == Union[str, int]" -#: ../../library/typing.rst:1113 +#: ../../library/typing.rst:1119 msgid "You cannot subclass or instantiate a ``Union``." msgstr "你不能建立 ``Union`` 的子類別或是實例。" -#: ../../library/typing.rst:1115 +#: ../../library/typing.rst:1121 msgid "You cannot write ``Union[X][Y]``." msgstr "你不能寫成 ``Union[X][Y]``。" -#: ../../library/typing.rst:1117 +#: ../../library/typing.rst:1123 msgid "Don't remove explicit subclasses from unions at runtime." msgstr "請勿在 runtime 中將顯性子類別從聯集中移除。" -#: ../../library/typing.rst:1120 +#: ../../library/typing.rst:1126 msgid "" "Unions can now be written as ``X | Y``. See :ref:`union type " "expressions`." msgstr "" "現在可以將聯集寫成 ``X | Y``。請見\\ :ref:`聯集型別運算式 `。" -#: ../../library/typing.rst:1126 +#: ../../library/typing.rst:1132 msgid "``Optional[X]`` is equivalent to ``X | None`` (or ``Union[X, None]``)." msgstr "``Optional[X]`` 與 ``X | None`` 是相等的(或是 ``Union[X, None]``)。" -#: ../../library/typing.rst:1128 +#: ../../library/typing.rst:1134 msgid "" "Note that this is not the same concept as an optional argument, which is one " "that has a default. An optional argument with a default does not require " @@ -1898,7 +1912,7 @@ msgstr "" "有預設值的選擇性引數的型別註釋中不具有 ``Optional`` 限定符 (qualifier),單純" "的因為它就是選擇性的。舉例來說: ::" -#: ../../library/typing.rst:1133 +#: ../../library/typing.rst:1139 msgid "" "def foo(arg: int = 0) -> None:\n" " ..." @@ -1906,7 +1920,7 @@ msgstr "" "def foo(arg: int = 0) -> None:\n" " ..." -#: ../../library/typing.rst:1136 +#: ../../library/typing.rst:1142 msgid "" "On the other hand, if an explicit value of ``None`` is allowed, the use of " "``Optional`` is appropriate, whether the argument is optional or not. For " @@ -1915,7 +1929,7 @@ msgstr "" "另一方面,如果一個顯性的值 ``None`` 是被允許的,不論引數是不是選擇性的," "``Optional`` 都適用。舉例來說: ::" -#: ../../library/typing.rst:1140 +#: ../../library/typing.rst:1146 msgid "" "def foo(arg: Optional[int] = None) -> None:\n" " ..." @@ -1923,7 +1937,7 @@ msgstr "" "def foo(arg: Optional[int] = None) -> None:\n" " ..." -#: ../../library/typing.rst:1143 +#: ../../library/typing.rst:1149 msgid "" "Optional can now be written as ``X | None``. See :ref:`union type " "expressions`." @@ -1931,11 +1945,11 @@ msgstr "" "現在可以將 Optional 寫成 ``X | None``。請見\\ :ref:`聯集型別運算式 `。" -#: ../../library/typing.rst:1149 +#: ../../library/typing.rst:1155 msgid "Special form for annotating higher-order functions." msgstr "用於註釋高階函式的特別型式。" -#: ../../library/typing.rst:1151 +#: ../../library/typing.rst:1157 msgid "" "``Concatenate`` can be used in conjunction with :ref:`Callable ` and :class:`ParamSpec` to annotate a higher-order callable which " @@ -1953,7 +1967,7 @@ msgstr "" "效。``Concatenate`` 的最後一個參數必須為一個 :class:`ParamSpec` 或是刪節號 " "(``...``)。" -#: ../../library/typing.rst:1160 +#: ../../library/typing.rst:1166 msgid "" "For example, to annotate a decorator ``with_lock`` which provides " "a :class:`threading.Lock` to the decorated function, ``Concatenate`` can be " @@ -1969,7 +1983,7 @@ msgstr "" "Callable 物件。在這種情況下,:class:`ParamSpec` 指出回傳的 Callable 物件的參" "數型別會依賴傳遞的 Callable 物件的參數型別: ::" -#: ../../library/typing.rst:1168 +#: ../../library/typing.rst:1174 msgid "" "from collections.abc import Callable\n" "from threading import Lock\n" @@ -1997,32 +2011,32 @@ msgid "" "sum_threadsafe([1.1, 2.2, 3.3])" msgstr "" -#: ../../library/typing.rst:1196 ../../library/typing.rst:2113 +#: ../../library/typing.rst:1202 ../../library/typing.rst:2153 msgid "" ":pep:`612` -- Parameter Specification Variables (the PEP which introduced " "``ParamSpec`` and ``Concatenate``)" msgstr ":pep:`612` -- 參數技術規範變數" -#: ../../library/typing.rst:1198 +#: ../../library/typing.rst:1204 msgid ":class:`ParamSpec`" msgstr ":class:`ParamSpec`" -#: ../../library/typing.rst:1199 ../../library/typing.rst:2116 +#: ../../library/typing.rst:1205 ../../library/typing.rst:2156 msgid ":ref:`annotating-callables`" msgstr ":ref:`annotating-callables`" -#: ../../library/typing.rst:1203 +#: ../../library/typing.rst:1209 msgid "Special typing form to define \"literal types\"." msgstr "特殊型別格式,用於定義「文本型別 (literal type)」。" -#: ../../library/typing.rst:1205 +#: ../../library/typing.rst:1211 msgid "" "``Literal`` can be used to indicate to type checkers that the annotated " "object has a value equivalent to one of the provided literals." msgstr "" "``Literal`` 可以用於型別檢查器並指出註釋物件具有一個與提供的文本相同的值。" -#: ../../library/typing.rst:1211 +#: ../../library/typing.rst:1217 msgid "" "def validate_simple(data: Any) -> Literal[True]: # always returns True\n" " ...\n" @@ -2035,7 +2049,7 @@ msgid "" "open_helper('/other/path', 'typo') # Error in type checker" msgstr "" -#: ../../library/typing.rst:1221 +#: ../../library/typing.rst:1227 msgid "" "``Literal[...]`` cannot be subclassed. At runtime, an arbitrary value is " "allowed as type argument to ``Literal[...]``, but type checkers may impose " @@ -2045,7 +2059,57 @@ msgstr "" "``Literal[...]`` 的型別引數,但型別檢查器可能會加強限制。更多有關文本型別的詳" "細資訊請看 :pep:`586`。" -#: ../../library/typing.rst:1227 +#: ../../library/typing.rst:1231 +msgid "Additional details:" +msgstr "其他細節:" + +#: ../../library/typing.rst:1233 +msgid "The arguments must be literal values and there must be at least one." +msgstr "引數必須為文本值且必須有至少一個。" + +#: ../../library/typing.rst:1235 +msgid "Nested ``Literal`` types are flattened, e.g.::" +msgstr "巢狀的 ``Literal`` 會是扁平化的 (flattened),舉例來說: ::" + +#: ../../library/typing.rst:1237 +msgid "assert Literal[Literal[1, 2], 3] == Literal[1, 2, 3]" +msgstr "assert Literal[Literal[1, 2], 3] == Literal[1, 2, 3]" + +#: ../../library/typing.rst:1239 +msgid "" +"However, this does not apply to ``Literal`` types referenced through a type " +"alias, to avoid forcing evaluation of the underlying :class:`TypeAliasType`::" +msgstr "" + +#: ../../library/typing.rst:1242 +msgid "" +"type A = Literal[1, 2]\n" +"assert Literal[A, 3] != Literal[1, 2, 3]" +msgstr "" +"type A = Literal[1, 2]\n" +"assert Literal[A, 3] != Literal[1, 2, 3]" + +#: ../../library/typing.rst:1247 +msgid "assert Literal[1, 2, 1] == Literal[1, 2]" +msgstr "assert Literal[1, 2, 1] == Literal[1, 2]" + +#: ../../library/typing.rst:1249 +msgid "When comparing literals, the argument order is ignored, e.g.::" +msgstr "當比較文本時,引數的順序會被忽略,舉例來說: ::" + +#: ../../library/typing.rst:1251 +msgid "assert Literal[1, 2] == Literal[2, 1]" +msgstr "assert Literal[1, 2] == Literal[2, 1]" + +#: ../../library/typing.rst:1253 +msgid "You cannot subclass or instantiate a ``Literal``." +msgstr "你不能建立 ``Literal`` 的子類別或是實例。" + +#: ../../library/typing.rst:1255 +msgid "You cannot write ``Literal[X][Y]``." +msgstr "你不能寫成 ``Literal[X][Y]``。" + +#: ../../library/typing.rst:1259 msgid "" "``Literal`` now de-duplicates parameters. Equality comparisons of " "``Literal`` objects are no longer order dependent. ``Literal`` objects will " @@ -2056,11 +2120,11 @@ msgstr "" "比較不再依照相依性排序。``Literal`` 物件現在會在相等性比較期間,若任一個其中" "的參數無法 :term:`hashable` 時,則會引發一個 :exc:`TypeError` 例外。" -#: ../../library/typing.rst:1235 +#: ../../library/typing.rst:1267 msgid "Special type construct to mark class variables." msgstr "特殊型別建構,用來標記類別變數。" -#: ../../library/typing.rst:1237 +#: ../../library/typing.rst:1269 msgid "" "As introduced in :pep:`526`, a variable annotation wrapped in ClassVar " "indicates that a given attribute is intended to be used as a class variable " @@ -2070,18 +2134,21 @@ msgstr "" "定的屬性 (attribute) 意圖被當作類別變數使用,且不該被設定成該類別的實例。使用" "方法如下: ::" -#: ../../library/typing.rst:1241 +#: ../../library/typing.rst:1273 msgid "" "class Starship:\n" " stats: ClassVar[dict[str, int]] = {} # class variable\n" " damage: int = 10 # instance variable" msgstr "" +"class Starship:\n" +" stats: ClassVar[dict[str, int]] = {} # 類別變數\n" +" damage: int = 10 # 實例變數" -#: ../../library/typing.rst:1245 +#: ../../library/typing.rst:1277 msgid ":data:`ClassVar` accepts only types and cannot be further subscribed." msgstr ":data:`ClassVar` 只接受型別請不得使用下標。" -#: ../../library/typing.rst:1247 +#: ../../library/typing.rst:1279 msgid "" ":data:`ClassVar` is not a class itself, and should not be used " "with :func:`isinstance` or :func:`issubclass`. :data:`ClassVar` does not " @@ -2094,22 +2161,22 @@ msgstr "" "為,但它可以被第三方的型別檢查器使用。舉例來說,一個型別檢查器可能會標記下方" "的程式碼為一個錯誤: ::" -#: ../../library/typing.rst:1253 +#: ../../library/typing.rst:1285 msgid "" "enterprise_d = Starship(3000)\n" "enterprise_d.stats = {} # Error, setting class variable on instance\n" "Starship.stats = {} # This is OK" msgstr "" -#: ../../library/typing.rst:1261 +#: ../../library/typing.rst:1293 msgid ":data:`ClassVar` can now be nested in :data:`Final` and vice versa." msgstr "" -#: ../../library/typing.rst:1265 +#: ../../library/typing.rst:1297 msgid "Special typing construct to indicate final names to type checkers." msgstr "特殊型別建構,用來指出給型別檢查器的最終名稱。" -#: ../../library/typing.rst:1267 +#: ../../library/typing.rst:1299 msgid "" "Final names cannot be reassigned in any scope. Final names declared in class " "scopes cannot be overridden in subclasses." @@ -2117,7 +2184,7 @@ msgstr "" "最終名稱不可以在任何作用域 (scope) 中重新賦值。在類別作用域中宣告的最終名稱," "不得在子類別中進行覆寫 (override)。" -#: ../../library/typing.rst:1272 +#: ../../library/typing.rst:1304 msgid "" "MAX_SIZE: Final = 9000\n" "MAX_SIZE += 1 # Error reported by type checker\n" @@ -2129,22 +2196,22 @@ msgid "" " TIMEOUT = 1 # Error reported by type checker" msgstr "" -#: ../../library/typing.rst:1281 ../../library/typing.rst:3074 +#: ../../library/typing.rst:1313 ../../library/typing.rst:3114 msgid "" "There is no runtime checking of these properties. See :pep:`591` for more " "details." msgstr "" "這些屬性 (property) 不會在 runtime 時進行檢查。更多詳細資訊請看 :pep:`591`。" -#: ../../library/typing.rst:1288 +#: ../../library/typing.rst:1320 msgid ":data:`Final` can now be nested in :data:`ClassVar` and vice versa." msgstr "" -#: ../../library/typing.rst:1292 +#: ../../library/typing.rst:1324 msgid "Special typing construct to mark a :class:`TypedDict` key as required." msgstr "特殊型別建構,用來標記一個 :class:`TypedDict` 鍵值是必須的。" -#: ../../library/typing.rst:1294 +#: ../../library/typing.rst:1326 msgid "" "This is mainly useful for ``total=False`` TypedDicts. See :class:`TypedDict` " "and :pep:`655` for more details." @@ -2152,23 +2219,23 @@ msgstr "" "主要用於 ``total=False`` 的 TypedDict。更多細節請見 :class:`TypedDict` " "與 :pep:`655`。" -#: ../../library/typing.rst:1301 +#: ../../library/typing.rst:1333 msgid "" "Special typing construct to mark a :class:`TypedDict` key as potentially " "missing." msgstr "特殊型別建構,用來標記一個 :class:`TypedDict` 鍵值是可能消失的。" -#: ../../library/typing.rst:1304 +#: ../../library/typing.rst:1336 msgid "See :class:`TypedDict` and :pep:`655` for more details." msgstr "更多細節請見 :class:`TypedDict` 與 :pep:`655`。" -#: ../../library/typing.rst:1310 +#: ../../library/typing.rst:1342 msgid "" "A special typing construct to mark an item of a :class:`TypedDict` as read-" "only." msgstr "特殊型別建構,用來標記一個 :class:`TypedDict` 的項目是唯讀的。" -#: ../../library/typing.rst:1314 +#: ../../library/typing.rst:1346 msgid "" "class Movie(TypedDict):\n" " title: ReadOnly[str]\n" @@ -2178,20 +2245,27 @@ msgid "" " m[\"year\"] = 1999 # allowed\n" " m[\"title\"] = \"The Matrix\" # typechecker error" msgstr "" +"class Movie(TypedDict):\n" +" title: ReadOnly[str]\n" +" year: int\n" +"\n" +"def mutate_movie(m: Movie) -> None:\n" +" m[\"year\"] = 1999 # allowed\n" +" m[\"title\"] = \"The Matrix\" # 型別檢查器錯誤" -#: ../../library/typing.rst:1322 +#: ../../library/typing.rst:1354 msgid "There is no runtime checking for this property." msgstr "這些屬性 (property) 不會在 runtime 時進行檢查。" -#: ../../library/typing.rst:1324 +#: ../../library/typing.rst:1356 msgid "See :class:`TypedDict` and :pep:`705` for more details." msgstr "更多細節請見 :class:`TypedDict` 與 :pep:`705`。" -#: ../../library/typing.rst:1330 +#: ../../library/typing.rst:1362 msgid "Special typing form to add context-specific metadata to an annotation." msgstr "" -#: ../../library/typing.rst:1332 +#: ../../library/typing.rst:1364 msgid "" "Add metadata ``x`` to a given type ``T`` by using the annotation " "``Annotated[T, x]``. Metadata added using ``Annotated`` can be used by " @@ -2199,7 +2273,7 @@ msgid "" "a :attr:`!__metadata__` attribute." msgstr "" -#: ../../library/typing.rst:1337 +#: ../../library/typing.rst:1369 msgid "" "If a library or tool encounters an annotation ``Annotated[T, x]`` and has no " "special logic for the metadata, it should ignore the metadata and simply " @@ -2208,7 +2282,7 @@ msgid "" "system." msgstr "" -#: ../../library/typing.rst:1343 +#: ../../library/typing.rst:1375 msgid "" "Using ``Annotated[T, x]`` as an annotation still allows for static " "typechecking of ``T``, as type checkers will simply ignore the metadata " @@ -2218,7 +2292,7 @@ msgid "" "for a function or class." msgstr "" -#: ../../library/typing.rst:1350 +#: ../../library/typing.rst:1382 msgid "" "The responsibility of how to interpret the metadata lies with the tool or " "library encountering an ``Annotated`` annotation. A tool or library " @@ -2226,13 +2300,13 @@ msgid "" "determine if they are of interest (e.g., using :func:`isinstance`)." msgstr "" -#: ../../library/typing.rst:1358 +#: ../../library/typing.rst:1390 msgid "" "Here is an example of how you might use ``Annotated`` to add metadata to " "type annotations if you were doing range analysis:" msgstr "" -#: ../../library/typing.rst:1361 +#: ../../library/typing.rst:1393 msgid "" "@dataclass\n" "class ValueRange:\n" @@ -2250,14 +2324,14 @@ msgstr "" "T1 = Annotated[int, ValueRange(-10, 5)]\n" "T2 = Annotated[T1, ValueRange(-20, 3)]" -#: ../../library/typing.rst:1371 +#: ../../library/typing.rst:1403 msgid "" "The first argument to ``Annotated`` must be a valid type. Multiple metadata " "elements can be supplied as ``Annotated`` supports variadic arguments. The " "order of the metadata elements is preserved and matters for equality checks::" msgstr "" -#: ../../library/typing.rst:1375 +#: ../../library/typing.rst:1407 msgid "" "@dataclass\n" "class ctype:\n" @@ -2277,20 +2351,20 @@ msgstr "" "\n" "assert a1 != a2 # 順序是有意義的" -#: ../../library/typing.rst:1384 +#: ../../library/typing.rst:1416 msgid "" "It is up to the tool consuming the annotations to decide whether the client " "is allowed to add multiple metadata elements to one annotation and how to " "merge those annotations." msgstr "" -#: ../../library/typing.rst:1388 +#: ../../library/typing.rst:1420 msgid "" "Nested ``Annotated`` types are flattened. The order of the metadata elements " "starts with the innermost annotation::" msgstr "" -#: ../../library/typing.rst:1391 +#: ../../library/typing.rst:1423 msgid "" "assert Annotated[Annotated[int, ValueRange(3, 10)], ctype(\"char\")] == " "Annotated[\n" @@ -2302,11 +2376,30 @@ msgstr "" " int, ValueRange(3, 10), ctype(\"char\")\n" "]" -#: ../../library/typing.rst:1395 +#: ../../library/typing.rst:1427 +msgid "" +"However, this does not apply to ``Annotated`` types referenced through a " +"type alias, to avoid forcing evaluation of the " +"underlying :class:`TypeAliasType`::" +msgstr "" + +#: ../../library/typing.rst:1430 +msgid "" +"type From3To10[T] = Annotated[T, ValueRange(3, 10)]\n" +"assert Annotated[From3To10[int], ctype(\"char\")] != Annotated[\n" +" int, ValueRange(3, 10), ctype(\"char\")\n" +"]" +msgstr "" +"type From3To10[T] = Annotated[T, ValueRange(3, 10)]\n" +"assert Annotated[From3To10[int], ctype(\"char\")] != Annotated[\n" +" int, ValueRange(3, 10), ctype(\"char\")\n" +"]" + +#: ../../library/typing.rst:1435 msgid "Duplicated metadata elements are not removed::" msgstr "" -#: ../../library/typing.rst:1397 +#: ../../library/typing.rst:1437 msgid "" "assert Annotated[int, ValueRange(3, 10)] != Annotated[\n" " int, ValueRange(3, 10), ValueRange(3, 10)\n" @@ -2316,11 +2409,11 @@ msgstr "" " int, ValueRange(3, 10), ValueRange(3, 10)\n" "]" -#: ../../library/typing.rst:1401 +#: ../../library/typing.rst:1441 msgid "``Annotated`` can be used with nested and generic aliases:" msgstr "" -#: ../../library/typing.rst:1403 +#: ../../library/typing.rst:1443 msgid "" "@dataclass\n" "class MaxLen:\n" @@ -2334,29 +2427,31 @@ msgid "" "type V = Vec[int]" msgstr "" -#: ../../library/typing.rst:1415 +#: ../../library/typing.rst:1455 msgid "``Annotated`` cannot be used with an unpacked :class:`TypeVarTuple`::" msgstr "" -#: ../../library/typing.rst:1417 +#: ../../library/typing.rst:1457 msgid "" "type Variadic[*Ts] = Annotated[*Ts, Ann1] = Annotated[T1, T2, T3, ..., " "Ann1] # NOT valid" msgstr "" +"type Variadic[*Ts] = Annotated[*Ts, Ann1] = Annotated[T1, T2, T3, ..., " +"Ann1] # 無效" -#: ../../library/typing.rst:1419 +#: ../../library/typing.rst:1459 msgid "" "where ``T1``, ``T2``, ... are :class:`TypeVars `. This is invalid " "as only one type should be passed to Annotated." msgstr "" -#: ../../library/typing.rst:1422 +#: ../../library/typing.rst:1462 msgid "" "By default, :func:`get_type_hints` strips the metadata from annotations. " "Pass ``include_extras=True`` to have the metadata preserved:" msgstr "" -#: ../../library/typing.rst:1425 +#: ../../library/typing.rst:1465 msgid "" ">>> from typing import Annotated, get_type_hints\n" ">>> def func(x: Annotated[int, \"metadata\"]) -> None: pass\n" @@ -2374,13 +2469,13 @@ msgstr "" ">>> get_type_hints(func, include_extras=True)\n" "{'x': typing.Annotated[int, 'metadata'], 'return': }" -#: ../../library/typing.rst:1435 +#: ../../library/typing.rst:1475 msgid "" "At runtime, the metadata associated with an ``Annotated`` type can be " "retrieved via the :attr:`!__metadata__` attribute:" msgstr "" -#: ../../library/typing.rst:1438 +#: ../../library/typing.rst:1478 msgid "" ">>> from typing import Annotated\n" ">>> X = Annotated[int, \"very\", \"important\", \"metadata\"]\n" @@ -2396,13 +2491,13 @@ msgstr "" ">>> X.__metadata__\n" "('very', 'important', 'metadata')" -#: ../../library/typing.rst:1447 +#: ../../library/typing.rst:1487 msgid "" "If you want to retrieve the original type wrapped by ``Annotated``, use " "the :attr:`!__origin__` attribute:" msgstr "" -#: ../../library/typing.rst:1450 +#: ../../library/typing.rst:1490 msgid "" ">>> from typing import Annotated, get_origin\n" ">>> Password = Annotated[str, \"secret\"]\n" @@ -2414,11 +2509,11 @@ msgstr "" ">>> Password.__origin__\n" "" -#: ../../library/typing.rst:1457 +#: ../../library/typing.rst:1497 msgid "Note that using :func:`get_origin` will return ``Annotated`` itself:" msgstr "" -#: ../../library/typing.rst:1459 +#: ../../library/typing.rst:1499 msgid "" ">>> get_origin(Password)\n" "typing.Annotated" @@ -2426,20 +2521,20 @@ msgstr "" ">>> get_origin(Password)\n" "typing.Annotated" -#: ../../library/typing.rst:1466 +#: ../../library/typing.rst:1506 msgid ":pep:`593` - Flexible function and variable annotations" msgstr "" -#: ../../library/typing.rst:1467 +#: ../../library/typing.rst:1507 msgid "The PEP introducing ``Annotated`` to the standard library." msgstr "" -#: ../../library/typing.rst:1474 ../../library/typing.rst:1558 +#: ../../library/typing.rst:1514 ../../library/typing.rst:1598 msgid "" "Special typing construct for marking user-defined type predicate functions." msgstr "" -#: ../../library/typing.rst:1476 +#: ../../library/typing.rst:1516 msgid "" "``TypeIs`` can be used to annotate the return type of a user-defined type " "predicate function. ``TypeIs`` only accepts a single type argument. At " @@ -2447,7 +2542,7 @@ msgid "" "one positional argument." msgstr "" -#: ../../library/typing.rst:1481 +#: ../../library/typing.rst:1521 msgid "" "``TypeIs`` aims to benefit *type narrowing* -- a technique used by static " "type checkers to determine a more precise type of an expression within a " @@ -2457,7 +2552,7 @@ msgid "" "predicate\"::" msgstr "" -#: ../../library/typing.rst:1487 +#: ../../library/typing.rst:1527 msgid "" "def is_str(val: str | float):\n" " # \"isinstance\" type predicate\n" @@ -2469,7 +2564,7 @@ msgid "" " ..." msgstr "" -#: ../../library/typing.rst:1496 +#: ../../library/typing.rst:1536 msgid "" "Sometimes it would be convenient to use a user-defined boolean function as a " "type predicate. Such a function should use ``TypeIs[...]`` " @@ -2480,29 +2575,29 @@ msgid "" "does not return ``True`` for all instances of the narrowed type." msgstr "" -#: ../../library/typing.rst:1504 +#: ../../library/typing.rst:1544 msgid "" "Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a " "given function:" msgstr "" -#: ../../library/typing.rst:1507 ../../library/typing.rst:1568 +#: ../../library/typing.rst:1547 ../../library/typing.rst:1608 msgid "The return value is a boolean." -msgstr "" +msgstr "回傳值是一個布林值。" -#: ../../library/typing.rst:1508 +#: ../../library/typing.rst:1548 msgid "" "If the return value is ``True``, the type of its argument is the " "intersection of the argument's original type and ``NarrowedType``." msgstr "" -#: ../../library/typing.rst:1510 +#: ../../library/typing.rst:1550 msgid "" "If the return value is ``False``, the type of its argument is narrowed to " "exclude ``NarrowedType``." msgstr "" -#: ../../library/typing.rst:1515 +#: ../../library/typing.rst:1555 msgid "" "from typing import assert_type, final, TypeIs\n" "\n" @@ -2526,7 +2621,7 @@ msgid "" " assert_type(arg, Unrelated)" msgstr "" -#: ../../library/typing.rst:1536 +#: ../../library/typing.rst:1576 msgid "" "The type inside ``TypeIs`` must be consistent with the type of the " "function's argument; if it is not, static type checkers will raise an " @@ -2535,27 +2630,27 @@ msgid "" "functions in a type-safe manner." msgstr "" -#: ../../library/typing.rst:1542 +#: ../../library/typing.rst:1582 msgid "" "If a ``TypeIs`` function is a class or instance method, then the type in " "``TypeIs`` maps to the type of the second parameter (after ``cls`` or " "``self``)." msgstr "" -#: ../../library/typing.rst:1546 +#: ../../library/typing.rst:1586 msgid "" "In short, the form ``def foo(arg: TypeA) -> TypeIs[TypeB]: ...``, means that " "if ``foo(arg)`` returns ``True``, then ``arg`` is an instance of ``TypeB``, " "and if it returns ``False``, it is not an instance of ``TypeB``." msgstr "" -#: ../../library/typing.rst:1550 +#: ../../library/typing.rst:1590 msgid "" "``TypeIs`` also works with type variables. For more information, " "see :pep:`742` (Narrowing types with ``TypeIs``)." msgstr "" -#: ../../library/typing.rst:1560 +#: ../../library/typing.rst:1600 msgid "" "Type predicate functions are user-defined functions that return whether " "their argument is an instance of a particular type. ``TypeGuard`` works " @@ -2563,25 +2658,25 @@ msgid "" "checking behavior (see below)." msgstr "" -#: ../../library/typing.rst:1565 +#: ../../library/typing.rst:1605 msgid "" "Using ``-> TypeGuard`` tells the static type checker that for a given " "function:" msgstr "" -#: ../../library/typing.rst:1569 +#: ../../library/typing.rst:1609 msgid "" "If the return value is ``True``, the type of its argument is the type inside " "``TypeGuard``." msgstr "" -#: ../../library/typing.rst:1572 +#: ../../library/typing.rst:1612 msgid "" "``TypeGuard`` also works with type variables. See :pep:`647` for more " "details." msgstr "" -#: ../../library/typing.rst:1576 +#: ../../library/typing.rst:1616 msgid "" "def is_str_list(val: list[object]) -> TypeGuard[list[str]]:\n" " '''Determines whether all objects in the list are strings'''\n" @@ -2596,11 +2691,11 @@ msgid "" " print(\"Not a list of strings!\")" msgstr "" -#: ../../library/typing.rst:1588 +#: ../../library/typing.rst:1628 msgid "``TypeIs`` and ``TypeGuard`` differ in the following ways:" -msgstr "" +msgstr "``TypeIs`` 和 ``TypeGuard`` 在以下幾個方面有所不同:" -#: ../../library/typing.rst:1590 +#: ../../library/typing.rst:1630 msgid "" "``TypeIs`` requires the narrowed type to be a subtype of the input type, " "while ``TypeGuard`` does not. The main reason is to allow for things like " @@ -2608,7 +2703,7 @@ msgid "" "subtype of the former, since ``list`` is invariant." msgstr "" -#: ../../library/typing.rst:1594 +#: ../../library/typing.rst:1634 msgid "" "When a ``TypeGuard`` function returns ``True``, type checkers narrow the " "type of the variable to exactly the ``TypeGuard`` type. When a ``TypeIs`` " @@ -2617,7 +2712,7 @@ msgid "" "type. (Technically, this is known as an intersection type.)" msgstr "" -#: ../../library/typing.rst:1598 +#: ../../library/typing.rst:1638 msgid "" "When a ``TypeGuard`` function returns ``False``, type checkers cannot narrow " "the type of the variable at all. When a ``TypeIs`` function returns " @@ -2625,18 +2720,18 @@ msgid "" "``TypeIs`` type." msgstr "" -#: ../../library/typing.rst:1607 +#: ../../library/typing.rst:1647 msgid "Typing operator to conceptually mark an object as having been unpacked." msgstr "" -#: ../../library/typing.rst:1609 +#: ../../library/typing.rst:1649 msgid "" "For example, using the unpack operator ``*`` on a :ref:`type variable tuple " "` is equivalent to using ``Unpack`` to mark the type variable " "tuple as having been unpacked::" msgstr "" -#: ../../library/typing.rst:1613 +#: ../../library/typing.rst:1653 msgid "" "Ts = TypeVarTuple('Ts')\n" "tup: tuple[*Ts]\n" @@ -2644,7 +2739,7 @@ msgid "" "tup: tuple[Unpack[Ts]]" msgstr "" -#: ../../library/typing.rst:1618 +#: ../../library/typing.rst:1658 msgid "" "In fact, ``Unpack`` can be used interchangeably with ``*`` in the context " "of :class:`typing.TypeVarTuple ` and :class:`builtins.tuple " @@ -2652,7 +2747,7 @@ msgid "" "versions of Python, where ``*`` couldn't be used in certain places::" msgstr "" -#: ../../library/typing.rst:1624 +#: ../../library/typing.rst:1664 msgid "" "# In older versions of Python, TypeVarTuple and Unpack\n" "# are located in the `typing_extensions` backports package.\n" @@ -2663,13 +2758,13 @@ msgid "" "tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible" msgstr "" -#: ../../library/typing.rst:1632 +#: ../../library/typing.rst:1672 msgid "" "``Unpack`` can also be used along with :class:`typing.TypedDict` for typing " "``**kwargs`` in a function signature::" msgstr "" -#: ../../library/typing.rst:1635 +#: ../../library/typing.rst:1675 msgid "" "from typing import TypedDict, Unpack\n" "\n" @@ -2682,23 +2777,23 @@ msgid "" "def foo(**kwargs: Unpack[Movie]): ..." msgstr "" -#: ../../library/typing.rst:1645 +#: ../../library/typing.rst:1685 msgid "" "See :pep:`692` for more details on using ``Unpack`` for ``**kwargs`` typing." msgstr "" -#: ../../library/typing.rst:1650 +#: ../../library/typing.rst:1690 msgid "Building generic types and type aliases" msgstr "" -#: ../../library/typing.rst:1652 +#: ../../library/typing.rst:1692 msgid "" "The following classes should not be used directly as annotations. Their " "intended purpose is to be building blocks for creating generic types and " "type aliases." msgstr "" -#: ../../library/typing.rst:1656 +#: ../../library/typing.rst:1696 msgid "" "These objects can be created through special syntax (:ref:`type parameter " "lists ` and the :keyword:`type` statement). For compatibility " @@ -2706,35 +2801,39 @@ msgid "" "syntax, as documented below." msgstr "" -#: ../../library/typing.rst:1663 +#: ../../library/typing.rst:1703 msgid "Abstract base class for generic types." msgstr "" -#: ../../library/typing.rst:1665 +#: ../../library/typing.rst:1705 msgid "" "A generic type is typically declared by adding a list of type parameters " "after the class name::" msgstr "" -#: ../../library/typing.rst:1668 +#: ../../library/typing.rst:1708 msgid "" "class Mapping[KT, VT]:\n" " def __getitem__(self, key: KT) -> VT:\n" " ...\n" " # Etc." msgstr "" +"class Mapping[KT, VT]:\n" +" def __getitem__(self, key: KT) -> VT:\n" +" ...\n" +" # Etc." -#: ../../library/typing.rst:1673 +#: ../../library/typing.rst:1713 msgid "" "Such a class implicitly inherits from ``Generic``. The runtime semantics of " "this syntax are discussed in the :ref:`Language Reference `." msgstr "" -#: ../../library/typing.rst:1677 +#: ../../library/typing.rst:1717 msgid "This class can then be used as follows::" msgstr "" -#: ../../library/typing.rst:1679 +#: ../../library/typing.rst:1719 msgid "" "def lookup_name[X, Y](mapping: Mapping[X, Y], key: X, default: Y) -> Y:\n" " try:\n" @@ -2748,20 +2847,20 @@ msgstr "" " except KeyError:\n" " return default" -#: ../../library/typing.rst:1685 +#: ../../library/typing.rst:1725 msgid "" "Here the brackets after the function name indicate a :ref:`generic function " "`." msgstr "" -#: ../../library/typing.rst:1688 +#: ../../library/typing.rst:1728 msgid "" "For backwards compatibility, generic classes can also be declared by " "explicitly inheriting from ``Generic``. In this case, the type parameters " "must be declared separately::" msgstr "" -#: ../../library/typing.rst:1693 +#: ../../library/typing.rst:1733 msgid "" "KT = TypeVar('KT')\n" "VT = TypeVar('VT')\n" @@ -2779,18 +2878,18 @@ msgstr "" " ...\n" " # Etc." -#: ../../library/typing.rst:1705 +#: ../../library/typing.rst:1745 msgid "Type variable." msgstr "" -#: ../../library/typing.rst:1707 +#: ../../library/typing.rst:1747 msgid "" "The preferred way to construct a type variable is via the dedicated syntax " "for :ref:`generic functions `, :ref:`generic classes " "`, and :ref:`generic type aliases `::" msgstr "" -#: ../../library/typing.rst:1712 +#: ../../library/typing.rst:1752 msgid "" "class Sequence[T]: # T is a TypeVar\n" " ..." @@ -2798,13 +2897,13 @@ msgstr "" "class Sequence[T]: # T 是一個 TypeVar\n" " ..." -#: ../../library/typing.rst:1715 +#: ../../library/typing.rst:1755 msgid "" "This syntax can also be used to create bounded and constrained type " "variables::" msgstr "" -#: ../../library/typing.rst:1718 +#: ../../library/typing.rst:1758 msgid "" "class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound;\n" " ... # we can say that S is \"bounded by `str`\"\n" @@ -2815,13 +2914,13 @@ msgid "" " ..." msgstr "" -#: ../../library/typing.rst:1725 +#: ../../library/typing.rst:1765 msgid "" "However, if desired, reusable type variables can also be constructed " "manually, like so::" msgstr "" -#: ../../library/typing.rst:1727 +#: ../../library/typing.rst:1767 msgid "" "T = TypeVar('T') # Can be anything\n" "S = TypeVar('S', bound=str) # Can be any subtype of str\n" @@ -2831,7 +2930,7 @@ msgstr "" "S = TypeVar('S', bound=str) # 可以是任何 str 的子型別\n" "A = TypeVar('A', str, bytes) # 必須是 str 或 bytes" -#: ../../library/typing.rst:1731 +#: ../../library/typing.rst:1771 msgid "" "Type variables exist primarily for the benefit of static type checkers. " "They serve as the parameters for generic types as well as for generic " @@ -2839,7 +2938,7 @@ msgid "" "information on generic types. Generic functions work as follows::" msgstr "" -#: ../../library/typing.rst:1737 +#: ../../library/typing.rst:1777 msgid "" "def repeat[T](x: T, n: int) -> Sequence[T]:\n" " \"\"\"Return a list containing n references to x.\"\"\"\n" @@ -2857,13 +2956,13 @@ msgid "" " return x + y" msgstr "" -#: ../../library/typing.rst:1752 +#: ../../library/typing.rst:1792 msgid "" "Note that type variables can be *bounded*, *constrained*, or neither, but " "cannot be both bounded *and* constrained." msgstr "" -#: ../../library/typing.rst:1755 +#: ../../library/typing.rst:1795 msgid "" "The variance of type variables is inferred by type checkers when they are " "created through the :ref:`type parameter syntax ` or when " @@ -2873,14 +2972,14 @@ msgid "" "invariant. See :pep:`484` and :pep:`695` for more details." msgstr "" -#: ../../library/typing.rst:1763 +#: ../../library/typing.rst:1803 msgid "" "Bounded type variables and constrained type variables have different " "semantics in several important ways. Using a *bounded* type variable means " "that the ``TypeVar`` will be solved using the most specific type possible::" msgstr "" -#: ../../library/typing.rst:1767 +#: ../../library/typing.rst:1807 msgid "" "x = print_capitalized('a string')\n" "reveal_type(x) # revealed type is str\n" @@ -2894,13 +2993,13 @@ msgid "" "z = print_capitalized(45) # error: int is not a subtype of str" msgstr "" -#: ../../library/typing.rst:1778 +#: ../../library/typing.rst:1818 msgid "" "The upper bound of a type variable can be a concrete type, abstract type " "(ABC or Protocol), or even a union of types::" msgstr "" -#: ../../library/typing.rst:1781 +#: ../../library/typing.rst:1821 msgid "" "# Can be anything with an __abs__ method\n" "def print_abs[T: SupportsAbs](arg: T) -> None:\n" @@ -2911,13 +3010,13 @@ msgid "" "V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method" msgstr "" -#: ../../library/typing.rst:1790 +#: ../../library/typing.rst:1830 msgid "" "Using a *constrained* type variable, however, means that the ``TypeVar`` can " "only ever be solved as being exactly one of the constraints given::" msgstr "" -#: ../../library/typing.rst:1793 +#: ../../library/typing.rst:1833 msgid "" "a = concatenate('one', 'two')\n" "reveal_type(a) # revealed type is str\n" @@ -2930,56 +3029,56 @@ msgid "" "or bytes in a function call, but not both" msgstr "" -#: ../../library/typing.rst:1801 +#: ../../library/typing.rst:1841 msgid "At runtime, ``isinstance(x, T)`` will raise :exc:`TypeError`." msgstr "在 runtime ``isinstance(x, T)`` 會引發 :exc:`TypeError`。" -#: ../../library/typing.rst:1805 +#: ../../library/typing.rst:1845 msgid "The name of the type variable." msgstr "" -#: ../../library/typing.rst:1809 +#: ../../library/typing.rst:1849 msgid "Whether the type var has been explicitly marked as covariant." msgstr "" -#: ../../library/typing.rst:1813 +#: ../../library/typing.rst:1853 msgid "Whether the type var has been explicitly marked as contravariant." msgstr "" -#: ../../library/typing.rst:1817 +#: ../../library/typing.rst:1857 msgid "" "Whether the type variable's variance should be inferred by type checkers." msgstr "" -#: ../../library/typing.rst:1823 +#: ../../library/typing.rst:1863 msgid "The upper bound of the type variable, if any." msgstr "" -#: ../../library/typing.rst:1827 +#: ../../library/typing.rst:1867 msgid "" "For type variables created through :ref:`type parameter syntax `, the bound is evaluated only when the attribute is accessed, not " "when the type variable is created (see :ref:`lazy-evaluation`)." msgstr "" -#: ../../library/typing.rst:1833 +#: ../../library/typing.rst:1873 msgid "A tuple containing the constraints of the type variable, if any." msgstr "" -#: ../../library/typing.rst:1837 +#: ../../library/typing.rst:1877 msgid "" "For type variables created through :ref:`type parameter syntax `, the constraints are evaluated only when the attribute is accessed, " "not when the type variable is created (see :ref:`lazy-evaluation`)." msgstr "" -#: ../../library/typing.rst:1843 +#: ../../library/typing.rst:1883 msgid "" "The default value of the type variable, or :data:`typing.NoDefault` if it " "has no default." msgstr "" -#: ../../library/typing.rst:1850 +#: ../../library/typing.rst:1890 msgid "" "Return whether or not the type variable has a default value. This is " "equivalent to checking whether :attr:`__default__` is not " @@ -2987,31 +3086,31 @@ msgid "" "evaluation of the :ref:`lazily evaluated ` default value." msgstr "" -#: ../../library/typing.rst:1859 +#: ../../library/typing.rst:1899 msgid "" "Type variables can now be declared using the :ref:`type parameter ` syntax introduced by :pep:`695`. The ``infer_variance`` parameter " "was added." msgstr "" -#: ../../library/typing.rst:1865 ../../library/typing.rst:2004 -#: ../../library/typing.rst:2106 +#: ../../library/typing.rst:1905 ../../library/typing.rst:2044 +#: ../../library/typing.rst:2146 msgid "Support for default values was added." msgstr "新增對預設值的支援。" -#: ../../library/typing.rst:1871 +#: ../../library/typing.rst:1911 msgid "" "Type variable tuple. A specialized form of :ref:`type variable ` " "that enables *variadic* generics." msgstr "" -#: ../../library/typing.rst:1874 +#: ../../library/typing.rst:1914 msgid "" "Type variable tuples can be declared in :ref:`type parameter lists ` using a single asterisk (``*``) before the name::" msgstr "" -#: ../../library/typing.rst:1877 +#: ../../library/typing.rst:1917 msgid "" "def move_first_element_to_last[T, *Ts](tup: tuple[T, *Ts]) -> tuple[*Ts, " "T]:\n" @@ -3021,11 +3120,11 @@ msgstr "" "T]:\n" " return (*tup[1:], tup[0])" -#: ../../library/typing.rst:1880 +#: ../../library/typing.rst:1920 msgid "Or by explicitly invoking the ``TypeVarTuple`` constructor::" msgstr "" -#: ../../library/typing.rst:1882 +#: ../../library/typing.rst:1922 msgid "" "T = TypeVar(\"T\")\n" "Ts = TypeVarTuple(\"Ts\")\n" @@ -3039,7 +3138,7 @@ msgstr "" "def move_first_element_to_last(tup: tuple[T, *Ts]) -> tuple[*Ts, T]:\n" " return (*tup[1:], tup[0])" -#: ../../library/typing.rst:1888 +#: ../../library/typing.rst:1928 msgid "" "A normal type variable enables parameterization with a single type. A type " "variable tuple, in contrast, allows parameterization with an *arbitrary* " @@ -3047,7 +3146,7 @@ msgid "" "wrapped in a tuple. For example::" msgstr "" -#: ../../library/typing.rst:1893 +#: ../../library/typing.rst:1933 msgid "" "# T is bound to int, Ts is bound to ()\n" "# Return value is (1,), which has type tuple[int]\n" @@ -3067,7 +3166,7 @@ msgid "" "move_first_element_to_last(tup=())" msgstr "" -#: ../../library/typing.rst:1910 +#: ../../library/typing.rst:1950 msgid "" "Note the use of the unpacking operator ``*`` in ``tuple[T, *Ts]``. " "Conceptually, you can think of ``Ts`` as a tuple of type variables ``(T1, " @@ -3077,13 +3176,13 @@ msgid "" "` instead, as ``Unpack[Ts]``.)" msgstr "" -#: ../../library/typing.rst:1918 +#: ../../library/typing.rst:1958 msgid "" "Type variable tuples must *always* be unpacked. This helps distinguish type " "variable tuples from normal type variables::" msgstr "" -#: ../../library/typing.rst:1921 +#: ../../library/typing.rst:1961 msgid "" "x: Ts # Not valid\n" "x: tuple[Ts] # Not valid\n" @@ -3093,13 +3192,13 @@ msgstr "" "x: tuple[Ts] # 無效\n" "x: tuple[*Ts] # 正確的做法" -#: ../../library/typing.rst:1925 +#: ../../library/typing.rst:1965 msgid "" "Type variable tuples can be used in the same contexts as normal type " "variables. For example, in class definitions, arguments, and return types::" msgstr "" -#: ../../library/typing.rst:1928 +#: ../../library/typing.rst:1968 msgid "" "class Array[*Shape]:\n" " def __getitem__(self, key: tuple[*Shape]) -> float: ...\n" @@ -3111,12 +3210,12 @@ msgstr "" " def __abs__(self) -> \"Array[*Shape]\": ...\n" " def get_shape(self) -> tuple[*Shape]: ..." -#: ../../library/typing.rst:1933 +#: ../../library/typing.rst:1973 msgid "" "Type variable tuples can be happily combined with normal type variables:" msgstr "" -#: ../../library/typing.rst:1935 +#: ../../library/typing.rst:1975 msgid "" "class Array[DType, *Shape]: # This is fine\n" " pass\n" @@ -3131,13 +3230,13 @@ msgid "" "int_array_2d: Array[int, Height, Width] = Array() # Yup, fine too" msgstr "" -#: ../../library/typing.rst:1949 +#: ../../library/typing.rst:1989 msgid "" "However, note that at most one type variable tuple may appear in a single " "list of type arguments or type parameters::" msgstr "" -#: ../../library/typing.rst:1952 +#: ../../library/typing.rst:1992 msgid "" "x: tuple[*Ts, *Ts] # Not valid\n" "class Array[*Shape, *Shape]: # Not valid\n" @@ -3147,13 +3246,13 @@ msgstr "" "class Array[*Shape, *Shape]: # 無效\n" " pass" -#: ../../library/typing.rst:1956 +#: ../../library/typing.rst:1996 msgid "" "Finally, an unpacked type variable tuple can be used as the type annotation " "of ``*args``::" msgstr "" -#: ../../library/typing.rst:1959 +#: ../../library/typing.rst:1999 msgid "" "def call_soon[*Ts](\n" " callback: Callable[[*Ts], None],\n" @@ -3169,7 +3268,7 @@ msgstr "" " ...\n" " callback(*args)" -#: ../../library/typing.rst:1966 +#: ../../library/typing.rst:2006 msgid "" "In contrast to non-unpacked annotations of ``*args`` - e.g. ``*args: int``, " "which would specify that *all* arguments are ``int`` - ``*args: *Ts`` " @@ -3178,21 +3277,21 @@ msgid "" "``call_soon`` match the types of the (positional) arguments of ``callback``." msgstr "" -#: ../../library/typing.rst:1973 +#: ../../library/typing.rst:2013 msgid "See :pep:`646` for more details on type variable tuples." msgstr "" -#: ../../library/typing.rst:1977 +#: ../../library/typing.rst:2017 msgid "The name of the type variable tuple." msgstr "" -#: ../../library/typing.rst:1981 +#: ../../library/typing.rst:2021 msgid "" "The default value of the type variable tuple, or :data:`typing.NoDefault` if " "it has no default." msgstr "" -#: ../../library/typing.rst:1988 +#: ../../library/typing.rst:2028 msgid "" "Return whether or not the type variable tuple has a default value. This is " "equivalent to checking whether :attr:`__default__` is not " @@ -3200,39 +3299,39 @@ msgid "" "evaluation of the :ref:`lazily evaluated ` default value." msgstr "" -#: ../../library/typing.rst:1999 +#: ../../library/typing.rst:2039 msgid "" "Type variable tuples can now be declared using the :ref:`type parameter " "` syntax introduced by :pep:`695`." msgstr "" -#: ../../library/typing.rst:2008 +#: ../../library/typing.rst:2048 msgid "" "Parameter specification variable. A specialized version of :ref:`type " "variables `." msgstr "" -#: ../../library/typing.rst:2011 +#: ../../library/typing.rst:2051 msgid "" "In :ref:`type parameter lists `, parameter specifications can " "be declared with two asterisks (``**``)::" msgstr "" -#: ../../library/typing.rst:2014 +#: ../../library/typing.rst:2054 msgid "type IntFunc[**P] = Callable[P, int]" msgstr "type IntFunc[**P] = Callable[P, int]" -#: ../../library/typing.rst:2016 +#: ../../library/typing.rst:2056 msgid "" "For compatibility with Python 3.11 and earlier, ``ParamSpec`` objects can " "also be created as follows::" msgstr "" -#: ../../library/typing.rst:2019 +#: ../../library/typing.rst:2059 msgid "P = ParamSpec('P')" msgstr "P = ParamSpec('P')" -#: ../../library/typing.rst:2021 +#: ../../library/typing.rst:2061 msgid "" "Parameter specification variables exist primarily for the benefit of static " "type checkers. They are used to forward the parameter types of one callable " @@ -3242,7 +3341,7 @@ msgid "" "See :class:`Generic` for more information on generic types." msgstr "" -#: ../../library/typing.rst:2028 +#: ../../library/typing.rst:2068 msgid "" "For example, to add basic logging to a function, one can create a decorator " "``add_logging`` to log function calls. The parameter specification variable " @@ -3250,7 +3349,7 @@ msgid "" "new callable returned by it have inter-dependent type parameters::" msgstr "" -#: ../../library/typing.rst:2033 +#: ../../library/typing.rst:2073 msgid "" "from collections.abc import Callable\n" "import logging\n" @@ -3268,27 +3367,27 @@ msgid "" " return x + y" msgstr "" -#: ../../library/typing.rst:2048 +#: ../../library/typing.rst:2088 msgid "" "Without ``ParamSpec``, the simplest way to annotate this previously was to " "use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However " "this causes two problems:" msgstr "" -#: ../../library/typing.rst:2052 +#: ../../library/typing.rst:2092 msgid "" "The type checker can't type check the ``inner`` function because ``*args`` " "and ``**kwargs`` have to be typed :data:`Any`." msgstr "" -#: ../../library/typing.rst:2054 +#: ../../library/typing.rst:2094 msgid "" ":func:`~cast` may be required in the body of the ``add_logging`` decorator " "when returning the ``inner`` function, or the static type checker must be " "told to ignore the ``return inner``." msgstr "" -#: ../../library/typing.rst:2061 +#: ../../library/typing.rst:2101 msgid "" "Since ``ParamSpec`` captures both positional and keyword parameters, " "``P.args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its " @@ -3301,17 +3400,17 @@ msgid "" "and :class:`ParamSpecKwargs`." msgstr "" -#: ../../library/typing.rst:2073 +#: ../../library/typing.rst:2113 msgid "The name of the parameter specification." msgstr "" -#: ../../library/typing.rst:2077 +#: ../../library/typing.rst:2117 msgid "" "The default value of the parameter specification, " "or :data:`typing.NoDefault` if it has no default." msgstr "" -#: ../../library/typing.rst:2084 +#: ../../library/typing.rst:2124 msgid "" "Return whether or not the parameter specification has a default value. This " "is equivalent to checking whether :attr:`__default__` is not " @@ -3319,7 +3418,7 @@ msgid "" "evaluation of the :ref:`lazily evaluated ` default value." msgstr "" -#: ../../library/typing.rst:2091 +#: ../../library/typing.rst:2131 msgid "" "Parameter specification variables created with ``covariant=True`` or " "``contravariant=True`` can be used to declare covariant or contravariant " @@ -3328,23 +3427,23 @@ msgid "" "to be decided." msgstr "" -#: ../../library/typing.rst:2101 +#: ../../library/typing.rst:2141 msgid "" "Parameter specifications can now be declared using the :ref:`type parameter " "` syntax introduced by :pep:`695`." msgstr "" -#: ../../library/typing.rst:2109 +#: ../../library/typing.rst:2149 msgid "" "Only parameter specification variables defined in global scope can be " "pickled." msgstr "" -#: ../../library/typing.rst:2115 +#: ../../library/typing.rst:2155 msgid ":data:`Concatenate`" msgstr ":data:`Concatenate`" -#: ../../library/typing.rst:2121 +#: ../../library/typing.rst:2161 msgid "" "Arguments and keyword arguments attributes of a :class:`ParamSpec`. The " "``P.args`` attribute of a ``ParamSpec`` is an instance of ``ParamSpecArgs``, " @@ -3353,13 +3452,13 @@ msgid "" "checkers." msgstr "" -#: ../../library/typing.rst:2126 +#: ../../library/typing.rst:2166 msgid "" "Calling :func:`get_origin` on either of these objects will return the " "original ``ParamSpec``:" msgstr "" -#: ../../library/typing.rst:2129 +#: ../../library/typing.rst:2169 msgid "" ">>> from typing import ParamSpec, get_origin\n" ">>> P = ParamSpec(\"P\")\n" @@ -3375,11 +3474,11 @@ msgstr "" ">>> get_origin(P.kwargs) is P\n" "True" -#: ../../library/typing.rst:2143 +#: ../../library/typing.rst:2183 msgid "The type of type aliases created through the :keyword:`type` statement." msgstr "" -#: ../../library/typing.rst:2147 +#: ../../library/typing.rst:2187 msgid "" ">>> type Alias = int\n" ">>> type(Alias)\n" @@ -3389,11 +3488,11 @@ msgstr "" ">>> type(Alias)\n" "" -#: ../../library/typing.rst:2157 +#: ../../library/typing.rst:2197 msgid "The name of the type alias:" msgstr "" -#: ../../library/typing.rst:2159 +#: ../../library/typing.rst:2199 msgid "" ">>> type Alias = int\n" ">>> Alias.__name__\n" @@ -3403,11 +3502,11 @@ msgstr "" ">>> Alias.__name__\n" "'Alias'" -#: ../../library/typing.rst:2167 +#: ../../library/typing.rst:2207 msgid "The module in which the type alias was defined::" msgstr "" -#: ../../library/typing.rst:2169 +#: ../../library/typing.rst:2209 msgid "" ">>> type Alias = int\n" ">>> Alias.__module__\n" @@ -3417,13 +3516,13 @@ msgstr "" ">>> Alias.__module__\n" "'__main__'" -#: ../../library/typing.rst:2175 +#: ../../library/typing.rst:2215 msgid "" "The type parameters of the type alias, or an empty tuple if the alias is not " "generic:" msgstr "" -#: ../../library/typing.rst:2178 +#: ../../library/typing.rst:2218 msgid "" ">>> type ListOrSet[T] = list[T] | set[T]\n" ">>> ListOrSet.__type_params__\n" @@ -3439,14 +3538,14 @@ msgstr "" ">>> NotGeneric.__type_params__\n" "()" -#: ../../library/typing.rst:2189 +#: ../../library/typing.rst:2229 msgid "" "The type alias's value. This is :ref:`lazily evaluated `, " "so names used in the definition of the alias are not resolved until the " "``__value__`` attribute is accessed:" msgstr "" -#: ../../library/typing.rst:2193 +#: ../../library/typing.rst:2233 msgid "" ">>> type Mutually = Recursive\n" ">>> type Recursive = Mutually\n" @@ -3470,27 +3569,27 @@ msgstr "" ">>> Recursive.__value__\n" "Mutually" -#: ../../library/typing.rst:2207 +#: ../../library/typing.rst:2247 msgid "Other special directives" msgstr "" -#: ../../library/typing.rst:2209 +#: ../../library/typing.rst:2249 msgid "" "These functions and classes should not be used directly as annotations. " "Their intended purpose is to be building blocks for creating and declaring " "types." msgstr "" -#: ../../library/typing.rst:2215 +#: ../../library/typing.rst:2255 msgid "Typed version of :func:`collections.namedtuple`." msgstr "" -#: ../../library/typing.rst:2217 ../../library/typing.rst:2309 -#: ../../library/typing.rst:3357 +#: ../../library/typing.rst:2257 ../../library/typing.rst:2349 +#: ../../library/typing.rst:3397 msgid "Usage::" msgstr "用法: ::" -#: ../../library/typing.rst:2219 +#: ../../library/typing.rst:2259 msgid "" "class Employee(NamedTuple):\n" " name: str\n" @@ -3500,20 +3599,20 @@ msgstr "" " name: str\n" " id: int" -#: ../../library/typing.rst:2223 +#: ../../library/typing.rst:2263 msgid "This is equivalent to::" msgstr "這等價於: ::" -#: ../../library/typing.rst:2225 +#: ../../library/typing.rst:2265 msgid "Employee = collections.namedtuple('Employee', ['name', 'id'])" msgstr "Employee = collections.namedtuple('Employee', ['name', 'id'])" -#: ../../library/typing.rst:2227 +#: ../../library/typing.rst:2267 msgid "" "To give a field a default value, you can assign to it in the class body::" msgstr "" -#: ../../library/typing.rst:2229 +#: ../../library/typing.rst:2269 msgid "" "class Employee(NamedTuple):\n" " name: str\n" @@ -3529,12 +3628,12 @@ msgstr "" "employee = Employee('Guido')\n" "assert employee.id == 3" -#: ../../library/typing.rst:2236 +#: ../../library/typing.rst:2276 msgid "" "Fields with a default value must come after any fields without a default." msgstr "" -#: ../../library/typing.rst:2238 +#: ../../library/typing.rst:2278 msgid "" "The resulting class has an extra attribute ``__annotations__`` giving a dict " "that maps the field names to the field types. (The field names are in the " @@ -3543,11 +3642,11 @@ msgid "" "API.)" msgstr "" -#: ../../library/typing.rst:2244 +#: ../../library/typing.rst:2284 msgid "``NamedTuple`` subclasses can also have docstrings and methods::" msgstr "" -#: ../../library/typing.rst:2246 +#: ../../library/typing.rst:2286 msgid "" "class Employee(NamedTuple):\n" " \"\"\"Represents an employee.\"\"\"\n" @@ -3558,11 +3657,11 @@ msgid "" " return f''" msgstr "" -#: ../../library/typing.rst:2254 +#: ../../library/typing.rst:2294 msgid "``NamedTuple`` subclasses can be generic::" msgstr "" -#: ../../library/typing.rst:2256 +#: ../../library/typing.rst:2296 msgid "" "class Group[T](NamedTuple):\n" " key: T\n" @@ -3572,11 +3671,11 @@ msgstr "" " key: T\n" " group: list[T]" -#: ../../library/typing.rst:2260 +#: ../../library/typing.rst:2300 msgid "Backward-compatible usage::" msgstr "" -#: ../../library/typing.rst:2262 +#: ../../library/typing.rst:2302 msgid "" "# For creating a generic NamedTuple on Python 3.11\n" "T = TypeVar(\"T\")\n" @@ -3589,38 +3688,38 @@ msgid "" "Employee = NamedTuple('Employee', [('name', str), ('id', int)])" msgstr "" -#: ../../library/typing.rst:2272 +#: ../../library/typing.rst:2312 msgid "Added support for :pep:`526` variable annotation syntax." msgstr "" -#: ../../library/typing.rst:2275 +#: ../../library/typing.rst:2315 msgid "Added support for default values, methods, and docstrings." msgstr "" -#: ../../library/typing.rst:2278 +#: ../../library/typing.rst:2318 msgid "" "The ``_field_types`` and ``__annotations__`` attributes are now regular " "dictionaries instead of instances of ``OrderedDict``." msgstr "" -#: ../../library/typing.rst:2282 +#: ../../library/typing.rst:2322 msgid "" "Removed the ``_field_types`` attribute in favor of the more standard " "``__annotations__`` attribute which has the same information." msgstr "" -#: ../../library/typing.rst:2286 +#: ../../library/typing.rst:2326 msgid "Added support for generic namedtuples." msgstr "" -#: ../../library/typing.rst:2289 +#: ../../library/typing.rst:2329 msgid "" "The undocumented keyword argument syntax for creating NamedTuple classes " "(``NT = NamedTuple(\"NT\", x=int)``) is deprecated, and will be disallowed " "in 3.15. Use the class-based syntax or the functional syntax instead." msgstr "" -#: ../../library/typing.rst:2294 +#: ../../library/typing.rst:2334 msgid "" "When using the functional syntax to create a NamedTuple class, failing to " "pass a value to the 'fields' parameter (``NT = NamedTuple(\"NT\")``) is " @@ -3630,48 +3729,48 @@ msgid "" "NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", [])``." msgstr "" -#: ../../library/typing.rst:2304 +#: ../../library/typing.rst:2344 msgid "Helper class to create low-overhead :ref:`distinct types `." msgstr "" -#: ../../library/typing.rst:2306 +#: ../../library/typing.rst:2346 msgid "" "A ``NewType`` is considered a distinct type by a typechecker. At runtime, " "however, calling a ``NewType`` returns its argument unchanged." msgstr "" -#: ../../library/typing.rst:2311 +#: ../../library/typing.rst:2351 msgid "" "UserId = NewType('UserId', int) # Declare the NewType \"UserId\"\n" "first_user = UserId(1) # \"UserId\" returns the argument unchanged at " "runtime" msgstr "" -#: ../../library/typing.rst:2316 +#: ../../library/typing.rst:2356 msgid "The module in which the new type is defined." msgstr "" -#: ../../library/typing.rst:2320 +#: ../../library/typing.rst:2360 msgid "The name of the new type." msgstr "" -#: ../../library/typing.rst:2324 +#: ../../library/typing.rst:2364 msgid "The type that the new type is based on." msgstr "" -#: ../../library/typing.rst:2328 +#: ../../library/typing.rst:2368 msgid "``NewType`` is now a class rather than a function." msgstr "" -#: ../../library/typing.rst:2333 +#: ../../library/typing.rst:2373 msgid "Base class for protocol classes." msgstr "" -#: ../../library/typing.rst:2335 +#: ../../library/typing.rst:2375 msgid "Protocol classes are defined like this::" msgstr "" -#: ../../library/typing.rst:2337 +#: ../../library/typing.rst:2377 msgid "" "class Proto(Protocol):\n" " def meth(self) -> int:\n" @@ -3681,13 +3780,13 @@ msgstr "" " def meth(self) -> int:\n" " ..." -#: ../../library/typing.rst:2341 +#: ../../library/typing.rst:2381 msgid "" "Such classes are primarily used with static type checkers that recognize " "structural subtyping (static duck-typing), for example::" msgstr "" -#: ../../library/typing.rst:2344 +#: ../../library/typing.rst:2384 msgid "" "class C:\n" " def meth(self) -> int:\n" @@ -3699,7 +3798,7 @@ msgid "" "func(C()) # Passes static type check" msgstr "" -#: ../../library/typing.rst:2353 +#: ../../library/typing.rst:2393 msgid "" "See :pep:`544` for more details. Protocol classes decorated " "with :func:`runtime_checkable` (described later) act as simple-minded " @@ -3708,11 +3807,11 @@ msgid "" "used as the second argument to :func:`isinstance` or :func:`issubclass`." msgstr "" -#: ../../library/typing.rst:2359 +#: ../../library/typing.rst:2399 msgid "Protocol classes can be generic, for example::" msgstr "" -#: ../../library/typing.rst:2361 +#: ../../library/typing.rst:2401 msgid "" "class GenProto[T](Protocol):\n" " def meth(self) -> T:\n" @@ -3722,13 +3821,13 @@ msgstr "" " def meth(self) -> T:\n" " ..." -#: ../../library/typing.rst:2365 +#: ../../library/typing.rst:2405 msgid "" "In code that needs to be compatible with Python 3.11 or older, generic " "Protocols can be written as follows::" msgstr "" -#: ../../library/typing.rst:2368 +#: ../../library/typing.rst:2408 msgid "" "T = TypeVar(\"T\")\n" "\n" @@ -3742,11 +3841,11 @@ msgstr "" " def meth(self) -> T:\n" " ..." -#: ../../library/typing.rst:2378 +#: ../../library/typing.rst:2418 msgid "Mark a protocol class as a runtime protocol." msgstr "" -#: ../../library/typing.rst:2380 +#: ../../library/typing.rst:2420 msgid "" "Such a protocol can be used with :func:`isinstance` and :func:`issubclass`. " "This allows a simple-minded structural check, very similar to \"one trick " @@ -3754,7 +3853,7 @@ msgid "" "as :class:`~collections.abc.Iterable`. For example::" msgstr "" -#: ../../library/typing.rst:2384 +#: ../../library/typing.rst:2424 msgid "" "@runtime_checkable\n" "class Closable(Protocol):\n" @@ -3782,12 +3881,12 @@ msgstr "" "import threading\n" "assert isinstance(threading.Thread(name='Bob'), Named)" -#: ../../library/typing.rst:2397 +#: ../../library/typing.rst:2437 msgid "" "This decorator raises :exc:`TypeError` when applied to a non-protocol class." msgstr "" -#: ../../library/typing.rst:2401 +#: ../../library/typing.rst:2441 msgid "" ":func:`!runtime_checkable` will check only the presence of the required " "methods or attributes, not their type signatures or types. For " @@ -3798,7 +3897,7 @@ msgid "" "impossible to call (instantiate) :class:`ssl.SSLObject`." msgstr "" -#: ../../library/typing.rst:2412 +#: ../../library/typing.rst:2452 msgid "" "An :func:`isinstance` check against a runtime-checkable protocol can be " "surprisingly slow compared to an ``isinstance()`` check against a non-" @@ -3806,7 +3905,7 @@ msgid "" "calls for structural checks in performance-sensitive code." msgstr "" -#: ../../library/typing.rst:2420 +#: ../../library/typing.rst:2460 msgid "" "The internal implementation of :func:`isinstance` checks against runtime-" "checkable protocols now uses :func:`inspect.getattr_static` to look up " @@ -3816,7 +3915,7 @@ msgid "" "versa. Most users are unlikely to be affected by this change." msgstr "" -#: ../../library/typing.rst:2429 +#: ../../library/typing.rst:2469 msgid "" "The members of a runtime-checkable protocol are now considered \"frozen\" at " "runtime as soon as the class has been created. Monkey-patching attributes " @@ -3826,13 +3925,13 @@ msgid "" "details." msgstr "" -#: ../../library/typing.rst:2440 +#: ../../library/typing.rst:2480 msgid "" "Special construct to add type hints to a dictionary. At runtime it is a " "plain :class:`dict`." msgstr "" -#: ../../library/typing.rst:2443 +#: ../../library/typing.rst:2483 msgid "" "``TypedDict`` declares a dictionary type that expects all of its instances " "to have a certain set of keys, where each key is associated with a value of " @@ -3840,7 +3939,7 @@ msgid "" "enforced by type checkers. Usage::" msgstr "" -#: ../../library/typing.rst:2449 +#: ../../library/typing.rst:2489 msgid "" "class Point2D(TypedDict):\n" " x: int\n" @@ -3853,17 +3952,17 @@ msgid "" "assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')" msgstr "" -#: ../../library/typing.rst:2459 +#: ../../library/typing.rst:2499 msgid "" "An alternative way to create a ``TypedDict`` is by using function-call " "syntax. The second argument must be a literal :class:`dict`::" msgstr "" -#: ../../library/typing.rst:2462 +#: ../../library/typing.rst:2502 msgid "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})" msgstr "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})" -#: ../../library/typing.rst:2464 +#: ../../library/typing.rst:2504 msgid "" "This functional syntax allows defining keys which are not " "valid :ref:`identifiers `, for example because they are " @@ -3871,7 +3970,7 @@ msgid "" "` like regular private names::" msgstr "" -#: ../../library/typing.rst:2469 +#: ../../library/typing.rst:2509 msgid "" "# raises SyntaxError\n" "class Point2D(TypedDict):\n" @@ -3886,13 +3985,13 @@ msgid "" "Definition = TypedDict('Definition', {'__schema': str}) # not mangled" msgstr "" -#: ../../library/typing.rst:2481 +#: ../../library/typing.rst:2521 msgid "" "By default, all keys must be present in a ``TypedDict``. It is possible to " "mark individual keys as non-required using :data:`NotRequired`::" msgstr "" -#: ../../library/typing.rst:2484 +#: ../../library/typing.rst:2524 msgid "" "class Point2D(TypedDict):\n" " x: int\n" @@ -3912,19 +4011,19 @@ msgstr "" "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': " "NotRequired[str]})" -#: ../../library/typing.rst:2492 +#: ../../library/typing.rst:2532 msgid "" "This means that a ``Point2D`` ``TypedDict`` can have the ``label`` key " "omitted." msgstr "" -#: ../../library/typing.rst:2495 +#: ../../library/typing.rst:2535 msgid "" "It is also possible to mark all keys as non-required by default by " "specifying a totality of ``False``::" msgstr "" -#: ../../library/typing.rst:2498 +#: ../../library/typing.rst:2538 msgid "" "class Point2D(TypedDict, total=False):\n" " x: int\n" @@ -3940,7 +4039,7 @@ msgstr "" "# 替代語法\n" "Point2D = TypedDict('Point2D', {'x': int, 'y': int}, total=False)" -#: ../../library/typing.rst:2505 +#: ../../library/typing.rst:2545 msgid "" "This means that a ``Point2D`` ``TypedDict`` can have any of the keys " "omitted. A type checker is only expected to support a literal ``False`` or " @@ -3948,13 +4047,13 @@ msgid "" "and makes all items defined in the class body required." msgstr "" -#: ../../library/typing.rst:2510 +#: ../../library/typing.rst:2550 msgid "" "Individual keys of a ``total=False`` ``TypedDict`` can be marked as required " "using :data:`Required`::" msgstr "" -#: ../../library/typing.rst:2513 +#: ../../library/typing.rst:2553 msgid "" "class Point2D(TypedDict, total=False):\n" " x: Required[int]\n" @@ -3980,13 +4079,13 @@ msgstr "" " 'label': str\n" "}, total=False)" -#: ../../library/typing.rst:2525 +#: ../../library/typing.rst:2565 msgid "" "It is possible for a ``TypedDict`` type to inherit from one or more other " "``TypedDict`` types using the class-based syntax. Usage::" msgstr "" -#: ../../library/typing.rst:2529 +#: ../../library/typing.rst:2569 msgid "" "class Point3D(Point2D):\n" " z: int" @@ -3994,13 +4093,13 @@ msgstr "" "class Point3D(Point2D):\n" " z: int" -#: ../../library/typing.rst:2532 +#: ../../library/typing.rst:2572 msgid "" "``Point3D`` has three items: ``x``, ``y`` and ``z``. It is equivalent to " "this definition::" msgstr "" -#: ../../library/typing.rst:2535 +#: ../../library/typing.rst:2575 msgid "" "class Point3D(TypedDict):\n" " x: int\n" @@ -4012,13 +4111,13 @@ msgstr "" " y: int\n" " z: int" -#: ../../library/typing.rst:2540 +#: ../../library/typing.rst:2580 msgid "" "A ``TypedDict`` cannot inherit from a non-\\ ``TypedDict`` class, except " "for :class:`Generic`. For example::" msgstr "" -#: ../../library/typing.rst:2543 +#: ../../library/typing.rst:2583 msgid "" "class X(TypedDict):\n" " x: int\n" @@ -4044,11 +4143,11 @@ msgstr "" "\n" "class XZ(X, Z): pass # 引發 TypeError" -#: ../../library/typing.rst:2555 +#: ../../library/typing.rst:2595 msgid "A ``TypedDict`` can be generic::" msgstr "" -#: ../../library/typing.rst:2557 +#: ../../library/typing.rst:2597 msgid "" "class Group[T](TypedDict):\n" " key: T\n" @@ -4058,13 +4157,13 @@ msgstr "" " key: T\n" " group: list[T]" -#: ../../library/typing.rst:2561 +#: ../../library/typing.rst:2601 msgid "" "To create a generic ``TypedDict`` that is compatible with Python 3.11 or " "lower, inherit from :class:`Generic` explicitly:" msgstr "" -#: ../../library/typing.rst:2564 +#: ../../library/typing.rst:2604 msgid "" "T = TypeVar(\"T\")\n" "\n" @@ -4078,7 +4177,7 @@ msgstr "" " key: T\n" " group: list[T]" -#: ../../library/typing.rst:2572 +#: ../../library/typing.rst:2612 msgid "" "A ``TypedDict`` can be introspected via annotations dicts " "(see :ref:`annotations-howto` for more information on annotations best " @@ -4086,12 +4185,12 @@ msgid "" "and :attr:`__optional_keys__`." msgstr "" -#: ../../library/typing.rst:2578 +#: ../../library/typing.rst:2618 msgid "" "``Point2D.__total__`` gives the value of the ``total`` argument. Example:" msgstr "" -#: ../../library/typing.rst:2581 +#: ../../library/typing.rst:2621 msgid "" ">>> from typing import TypedDict\n" ">>> class Point2D(TypedDict): pass\n" @@ -4115,7 +4214,7 @@ msgstr "" ">>> Point3D.__total__\n" "True" -#: ../../library/typing.rst:2594 +#: ../../library/typing.rst:2634 msgid "" "This attribute reflects *only* the value of the ``total`` argument to the " "current ``TypedDict`` class, not whether the class is semantically total. " @@ -4126,21 +4225,21 @@ msgid "" "introspection." msgstr "" -#: ../../library/typing.rst:2607 +#: ../../library/typing.rst:2647 msgid "" "``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` " "return :class:`frozenset` objects containing required and non-required keys, " "respectively." msgstr "" -#: ../../library/typing.rst:2610 +#: ../../library/typing.rst:2650 msgid "" "Keys marked with :data:`Required` will always appear in " "``__required_keys__`` and keys marked with :data:`NotRequired` will always " "appear in ``__optional_keys__``." msgstr "" -#: ../../library/typing.rst:2613 +#: ../../library/typing.rst:2653 msgid "" "For backwards compatibility with Python 3.10 and below, it is also possible " "to use inheritance to declare both required and non-required keys in the " @@ -4149,7 +4248,7 @@ msgid "" "``TypedDict`` with a different value for ``total``:" msgstr "" -#: ../../library/typing.rst:2620 +#: ../../library/typing.rst:2660 msgid "" ">>> class Point2D(TypedDict, total=False):\n" "... x: int\n" @@ -4175,7 +4274,7 @@ msgstr "" ">>> Point3D.__optional_keys__ == frozenset({'x', 'y'})\n" "True" -#: ../../library/typing.rst:2638 +#: ../../library/typing.rst:2678 msgid "" "If ``from __future__ import annotations`` is used or if annotations are " "given as strings, annotations are not evaluated when the ``TypedDict`` is " @@ -4184,48 +4283,48 @@ msgid "" "attributes may be incorrect." msgstr "" -#: ../../library/typing.rst:2644 +#: ../../library/typing.rst:2684 msgid "Support for :data:`ReadOnly` is reflected in the following attributes:" msgstr "" -#: ../../library/typing.rst:2648 +#: ../../library/typing.rst:2688 msgid "" "A :class:`frozenset` containing the names of all read-only keys. Keys are " "read-only if they carry the :data:`ReadOnly` qualifier." msgstr "" -#: ../../library/typing.rst:2655 +#: ../../library/typing.rst:2695 msgid "" "A :class:`frozenset` containing the names of all mutable keys. Keys are " "mutable if they do not carry the :data:`ReadOnly` qualifier." msgstr "" -#: ../../library/typing.rst:2660 +#: ../../library/typing.rst:2700 msgid "" "See :pep:`589` for more examples and detailed rules of using ``TypedDict``." msgstr "" -#: ../../library/typing.rst:2664 +#: ../../library/typing.rst:2704 msgid "" "Added support for marking individual keys as :data:`Required` " "or :data:`NotRequired`. See :pep:`655`." msgstr "" -#: ../../library/typing.rst:2668 +#: ../../library/typing.rst:2708 msgid "Added support for generic ``TypedDict``\\ s." msgstr "" -#: ../../library/typing.rst:2671 +#: ../../library/typing.rst:2711 msgid "" "Removed support for the keyword-argument method of creating ``TypedDict``\\ " "s." msgstr "" -#: ../../library/typing.rst:2674 +#: ../../library/typing.rst:2714 msgid "Support for the :data:`ReadOnly` qualifier was added." msgstr "" -#: ../../library/typing.rst:2677 +#: ../../library/typing.rst:2717 msgid "" "When using the functional syntax to create a TypedDict class, failing to " "pass a value to the 'fields' parameter (``TD = TypedDict(\"TD\")``) is " @@ -4235,106 +4334,106 @@ msgid "" "TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", {})``." msgstr "" -#: ../../library/typing.rst:2686 +#: ../../library/typing.rst:2726 msgid "Protocols" msgstr "協定" -#: ../../library/typing.rst:2688 +#: ../../library/typing.rst:2728 msgid "" "The following protocols are provided by the :mod:`!typing` module. All are " "decorated with :func:`@runtime_checkable `." msgstr "" -#: ../../library/typing.rst:2693 +#: ../../library/typing.rst:2733 msgid "" "An ABC with one abstract method ``__abs__`` that is covariant in its return " "type." msgstr "" -#: ../../library/typing.rst:2698 +#: ../../library/typing.rst:2738 msgid "An ABC with one abstract method ``__bytes__``." msgstr "一個有抽象方法 ``__bytes__`` 的 ABC。" -#: ../../library/typing.rst:2702 +#: ../../library/typing.rst:2742 msgid "An ABC with one abstract method ``__complex__``." msgstr "一個有抽象方法 ``__complex__`` 的 ABC。" -#: ../../library/typing.rst:2706 +#: ../../library/typing.rst:2746 msgid "An ABC with one abstract method ``__float__``." msgstr "一個有抽象方法 ``__float__`` 的 ABC。" -#: ../../library/typing.rst:2710 +#: ../../library/typing.rst:2750 msgid "An ABC with one abstract method ``__index__``." msgstr "一個有抽象方法 ``__index__`` 的 ABC。" -#: ../../library/typing.rst:2716 +#: ../../library/typing.rst:2756 msgid "An ABC with one abstract method ``__int__``." msgstr "一個有抽象方法 ``__int__`` 的 ABC。" -#: ../../library/typing.rst:2720 +#: ../../library/typing.rst:2760 msgid "" "An ABC with one abstract method ``__round__`` that is covariant in its " "return type." msgstr "" -#: ../../library/typing.rst:2724 +#: ../../library/typing.rst:2764 msgid "ABCs for working with IO" msgstr "" -#: ../../library/typing.rst:2730 +#: ../../library/typing.rst:2770 msgid "" "Generic type ``IO[AnyStr]`` and its subclasses ``TextIO(IO[str])`` and " "``BinaryIO(IO[bytes])`` represent the types of I/O streams such as returned " "by :func:`open`." msgstr "" -#: ../../library/typing.rst:2736 +#: ../../library/typing.rst:2776 msgid "Functions and decorators" msgstr "函式與裝飾器" -#: ../../library/typing.rst:2740 +#: ../../library/typing.rst:2780 msgid "Cast a value to a type." msgstr "" -#: ../../library/typing.rst:2742 +#: ../../library/typing.rst:2782 msgid "" "This returns the value unchanged. To the type checker this signals that the " "return value has the designated type, but at runtime we intentionally don't " "check anything (we want this to be as fast as possible)." msgstr "" -#: ../../library/typing.rst:2749 +#: ../../library/typing.rst:2789 msgid "" "Ask a static type checker to confirm that *val* has an inferred type of " "*typ*." msgstr "" -#: ../../library/typing.rst:2751 +#: ../../library/typing.rst:2791 msgid "" "At runtime this does nothing: it returns the first argument unchanged with " "no checks or side effects, no matter the actual type of the argument." msgstr "" -#: ../../library/typing.rst:2754 +#: ../../library/typing.rst:2794 msgid "" "When a static type checker encounters a call to ``assert_type()``, it emits " "an error if the value is not of the specified type::" msgstr "" -#: ../../library/typing.rst:2757 +#: ../../library/typing.rst:2797 msgid "" "def greet(name: str) -> None:\n" " assert_type(name, str) # OK, inferred type of `name` is `str`\n" " assert_type(name, int) # type checker error" msgstr "" -#: ../../library/typing.rst:2761 +#: ../../library/typing.rst:2801 msgid "" "This function is useful for ensuring the type checker's understanding of a " "script is in line with the developer's intentions::" msgstr "" -#: ../../library/typing.rst:2764 +#: ../../library/typing.rst:2804 msgid "" "def complex_function(arg: object):\n" " # Do some complex type-narrowing logic,\n" @@ -4344,16 +4443,16 @@ msgid "" " assert_type(arg, int)" msgstr "" -#: ../../library/typing.rst:2775 +#: ../../library/typing.rst:2815 msgid "" "Ask a static type checker to confirm that a line of code is unreachable." msgstr "" -#: ../../library/typing.rst:2777 +#: ../../library/typing.rst:2817 msgid "Example::" msgstr "舉例來說: ::" -#: ../../library/typing.rst:2779 +#: ../../library/typing.rst:2819 msgid "" "def int_or_str(arg: int | str) -> None:\n" " match arg:\n" @@ -4373,14 +4472,14 @@ msgstr "" " case _ as unreachable:\n" " assert_never(unreachable)" -#: ../../library/typing.rst:2788 +#: ../../library/typing.rst:2828 msgid "" "Here, the annotations allow the type checker to infer that the last case can " "never execute, because ``arg`` is either an :class:`int` or a :class:`str`, " "and both options are covered by earlier cases." msgstr "" -#: ../../library/typing.rst:2793 +#: ../../library/typing.rst:2833 msgid "" "If a type checker finds that a call to ``assert_never()`` is reachable, it " "will emit an error. For example, if the type annotation for ``arg`` was " @@ -4390,47 +4489,47 @@ msgid "" "passed in must be the bottom type, :data:`Never`, and nothing else." msgstr "" -#: ../../library/typing.rst:2801 +#: ../../library/typing.rst:2841 msgid "At runtime, this throws an exception when called." msgstr "" -#: ../../library/typing.rst:2804 +#: ../../library/typing.rst:2844 msgid "" "`Unreachable Code and Exhaustiveness Checking `__ has more information about exhaustiveness " "checking with static typing." msgstr "" -#: ../../library/typing.rst:2812 +#: ../../library/typing.rst:2852 msgid "Ask a static type checker to reveal the inferred type of an expression." msgstr "" -#: ../../library/typing.rst:2814 +#: ../../library/typing.rst:2854 msgid "" "When a static type checker encounters a call to this function, it emits a " "diagnostic with the inferred type of the argument. For example::" msgstr "" -#: ../../library/typing.rst:2817 +#: ../../library/typing.rst:2857 msgid "" "x: int = 1\n" "reveal_type(x) # Revealed type is \"builtins.int\"" msgstr "" -#: ../../library/typing.rst:2820 +#: ../../library/typing.rst:2860 msgid "" "This can be useful when you want to debug how your type checker handles a " "particular piece of code." msgstr "" -#: ../../library/typing.rst:2823 +#: ../../library/typing.rst:2863 msgid "" "At runtime, this function prints the runtime type of its argument " "to :data:`sys.stderr` and returns the argument unchanged (allowing the call " "to be used within an expression)::" msgstr "" -#: ../../library/typing.rst:2827 +#: ../../library/typing.rst:2867 msgid "" "x = reveal_type(1) # prints \"Runtime type is int\"\n" "print(x) # prints \"1\"" @@ -4438,13 +4537,13 @@ msgstr "" "x = reveal_type(1) # 印出 \"Runtime type is int\"\n" "print(x) # 印出 \"1\"" -#: ../../library/typing.rst:2830 +#: ../../library/typing.rst:2870 msgid "" "Note that the runtime type may be different from (more or less specific " "than) the type statically inferred by a type checker." msgstr "" -#: ../../library/typing.rst:2833 +#: ../../library/typing.rst:2873 msgid "" "Most type checkers support ``reveal_type()`` anywhere, even if the name is " "not imported from ``typing``. Importing the name from ``typing``, however, " @@ -4452,13 +4551,13 @@ msgid "" "clearly." msgstr "" -#: ../../library/typing.rst:2844 +#: ../../library/typing.rst:2884 msgid "" "Decorator to mark an object as providing :func:`dataclass " "`-like behavior." msgstr "" -#: ../../library/typing.rst:2847 +#: ../../library/typing.rst:2887 msgid "" "``dataclass_transform`` may be used to decorate a class, metaclass, or a " "function that is itself a decorator. The presence of " @@ -4467,11 +4566,11 @@ msgid "" "to :func:`@dataclasses.dataclass `." msgstr "" -#: ../../library/typing.rst:2854 +#: ../../library/typing.rst:2894 msgid "Example usage with a decorator function:" msgstr "" -#: ../../library/typing.rst:2856 +#: ../../library/typing.rst:2896 msgid "" "@dataclass_transform()\n" "def create_model[T](cls: type[T]) -> type[T]:\n" @@ -4493,11 +4592,11 @@ msgstr "" " id: int\n" " name: str" -#: ../../library/typing.rst:2868 +#: ../../library/typing.rst:2908 msgid "On a base class::" msgstr "" -#: ../../library/typing.rst:2870 +#: ../../library/typing.rst:2910 msgid "" "@dataclass_transform()\n" "class ModelBase: ...\n" @@ -4513,11 +4612,11 @@ msgstr "" " id: int\n" " name: str" -#: ../../library/typing.rst:2877 +#: ../../library/typing.rst:2917 msgid "On a metaclass::" msgstr "" -#: ../../library/typing.rst:2879 +#: ../../library/typing.rst:2919 msgid "" "@dataclass_transform()\n" "class ModelMeta(type): ...\n" @@ -4537,7 +4636,7 @@ msgstr "" " id: int\n" " name: str" -#: ../../library/typing.rst:2888 +#: ../../library/typing.rst:2928 msgid "" "The ``CustomerModel`` classes defined above will be treated by type checkers " "similarly to classes created with :func:`@dataclasses.dataclass " @@ -4545,7 +4644,7 @@ msgid "" "classes have ``__init__`` methods that accept ``id`` and ``name``." msgstr "" -#: ../../library/typing.rst:2894 +#: ../../library/typing.rst:2934 msgid "" "The decorated class, metaclass, or function may accept the following bool " "arguments which type checkers will assume have the same effect as they would " @@ -4555,7 +4654,7 @@ msgid "" "arguments (``True`` or ``False``) to be statically evaluated." msgstr "" -#: ../../library/typing.rst:2902 +#: ../../library/typing.rst:2942 msgid "" "The arguments to the ``dataclass_transform`` decorator can be used to " "customize the default behaviors of the decorated class, metaclass, or " @@ -4566,90 +4665,90 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/typing.rst:2906 +#: ../../library/typing.rst:2946 msgid "" "Indicates whether the ``eq`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``True``." msgstr "" -#: ../../library/typing.rst:2911 +#: ../../library/typing.rst:2951 msgid "" "Indicates whether the ``order`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``." msgstr "" -#: ../../library/typing.rst:2916 +#: ../../library/typing.rst:2956 msgid "" "Indicates whether the ``kw_only`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``." msgstr "" -#: ../../library/typing.rst:2921 +#: ../../library/typing.rst:2961 msgid "" "Indicates whether the ``frozen`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``. .. " "versionadded:: 3.12" msgstr "" -#: ../../library/typing.rst:2922 +#: ../../library/typing.rst:2962 msgid "" "Indicates whether the ``frozen`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``." msgstr "" -#: ../../library/typing.rst:2928 +#: ../../library/typing.rst:2968 msgid "" "Specifies a static list of supported classes or functions that describe " "fields, similar to :func:`dataclasses.field`. Defaults to ``()``." msgstr "" -#: ../../library/typing.rst:2934 +#: ../../library/typing.rst:2974 msgid "" "Arbitrary other keyword arguments are accepted in order to allow for " "possible future extensions." msgstr "" -#: ../../library/typing.rst:2938 +#: ../../library/typing.rst:2978 msgid "" "Type checkers recognize the following optional parameters on field " "specifiers:" msgstr "" -#: ../../library/typing.rst:2941 +#: ../../library/typing.rst:2981 msgid "**Recognised parameters for field specifiers**" msgstr "" -#: ../../library/typing.rst:2945 +#: ../../library/typing.rst:2985 msgid "Parameter name" msgstr "" -#: ../../library/typing.rst:2946 +#: ../../library/typing.rst:2986 msgid "Description" msgstr "" -#: ../../library/typing.rst:2947 +#: ../../library/typing.rst:2987 msgid "``init``" msgstr "``init``" -#: ../../library/typing.rst:2948 +#: ../../library/typing.rst:2988 msgid "" "Indicates whether the field should be included in the synthesized " "``__init__`` method. If unspecified, ``init`` defaults to ``True``." msgstr "" -#: ../../library/typing.rst:2951 +#: ../../library/typing.rst:2991 msgid "``default``" msgstr "``default``" -#: ../../library/typing.rst:2952 +#: ../../library/typing.rst:2992 msgid "Provides the default value for the field." msgstr "" -#: ../../library/typing.rst:2953 +#: ../../library/typing.rst:2993 msgid "``default_factory``" msgstr "``default_factory``" -#: ../../library/typing.rst:2954 +#: ../../library/typing.rst:2994 msgid "" "Provides a runtime callback that returns the default value for the field. If " "neither ``default`` nor ``default_factory`` are specified, the field is " @@ -4657,19 +4756,19 @@ msgid "" "is instantiated." msgstr "" -#: ../../library/typing.rst:2959 +#: ../../library/typing.rst:2999 msgid "``factory``" msgstr "``factory``" -#: ../../library/typing.rst:2960 +#: ../../library/typing.rst:3000 msgid "An alias for the ``default_factory`` parameter on field specifiers." msgstr "" -#: ../../library/typing.rst:2961 +#: ../../library/typing.rst:3001 msgid "``kw_only``" msgstr "``kw_only``" -#: ../../library/typing.rst:2962 +#: ../../library/typing.rst:3002 msgid "" "Indicates whether the field should be marked as keyword-only. If ``True``, " "the field will be keyword-only. If ``False``, it will not be keyword-only. " @@ -4679,32 +4778,32 @@ msgid "" "will be used." msgstr "" -#: ../../library/typing.rst:2968 +#: ../../library/typing.rst:3008 msgid "``alias``" msgstr "``alias``" -#: ../../library/typing.rst:2969 +#: ../../library/typing.rst:3009 msgid "" "Provides an alternative name for the field. This alternative name is used in " "the synthesized ``__init__`` method." msgstr "" -#: ../../library/typing.rst:2972 +#: ../../library/typing.rst:3012 msgid "" "At runtime, this decorator records its arguments in the " "``__dataclass_transform__`` attribute on the decorated object. It has no " "other runtime effect." msgstr "" -#: ../../library/typing.rst:2976 +#: ../../library/typing.rst:3016 msgid "See :pep:`681` for more details." msgstr "更多細節請見 :pep:`681`。" -#: ../../library/typing.rst:2984 +#: ../../library/typing.rst:3024 msgid "Decorator for creating overloaded functions and methods." msgstr "" -#: ../../library/typing.rst:2986 +#: ../../library/typing.rst:3026 msgid "" "The ``@overload`` decorator allows describing functions and methods that " "support multiple different combinations of argument types. A series of " @@ -4712,7 +4811,7 @@ msgid "" "``@overload``-decorated definition (for the same function/method)." msgstr "" -#: ../../library/typing.rst:2991 +#: ../../library/typing.rst:3031 msgid "" "``@overload``-decorated definitions are for the benefit of the type checker " "only, since they will be overwritten by the non-``@overload``-decorated " @@ -4722,13 +4821,13 @@ msgid "" "raise :exc:`NotImplementedError`." msgstr "" -#: ../../library/typing.rst:2999 +#: ../../library/typing.rst:3039 msgid "" "An example of overload that gives a more precise type than can be expressed " "using a union or a type variable:" msgstr "" -#: ../../library/typing.rst:3002 +#: ../../library/typing.rst:3042 msgid "" "@overload\n" "def process(response: None) -> None:\n" @@ -4754,24 +4853,24 @@ msgstr "" "def process(response):\n" " ... # 實際的實作在這邊" -#: ../../library/typing.rst:3016 +#: ../../library/typing.rst:3056 msgid "" "See :pep:`484` for more details and comparison with other typing semantics." msgstr "" -#: ../../library/typing.rst:3018 +#: ../../library/typing.rst:3058 msgid "" "Overloaded functions can now be introspected at runtime " "using :func:`get_overloads`." msgstr "" -#: ../../library/typing.rst:3025 +#: ../../library/typing.rst:3065 msgid "" "Return a sequence of :func:`@overload `-decorated definitions for " "*func*." msgstr "" -#: ../../library/typing.rst:3028 +#: ../../library/typing.rst:3068 msgid "" "*func* is the function object for the implementation of the overloaded " "function. For example, given the definition of ``process`` in the " @@ -4781,32 +4880,32 @@ msgid "" "returns an empty sequence." msgstr "" -#: ../../library/typing.rst:3035 +#: ../../library/typing.rst:3075 msgid "" "``get_overloads()`` can be used for introspecting an overloaded function at " "runtime." msgstr "" -#: ../../library/typing.rst:3043 +#: ../../library/typing.rst:3083 msgid "Clear all registered overloads in the internal registry." msgstr "" -#: ../../library/typing.rst:3045 +#: ../../library/typing.rst:3085 msgid "This can be used to reclaim the memory used by the registry." msgstr "" -#: ../../library/typing.rst:3052 +#: ../../library/typing.rst:3092 msgid "Decorator to indicate final methods and final classes." msgstr "" -#: ../../library/typing.rst:3054 +#: ../../library/typing.rst:3094 msgid "" "Decorating a method with ``@final`` indicates to a type checker that the " "method cannot be overridden in a subclass. Decorating a class with " "``@final`` indicates that it cannot be subclassed." msgstr "" -#: ../../library/typing.rst:3060 +#: ../../library/typing.rst:3100 msgid "" "class Base:\n" " @final\n" @@ -4836,7 +4935,7 @@ msgstr "" "class Other(Leaf): # 型別檢查器回報的錯誤\n" " ..." -#: ../../library/typing.rst:3079 +#: ../../library/typing.rst:3119 msgid "" "The decorator will now attempt to set a ``__final__`` attribute to ``True`` " "on the decorated object. Thus, a check like ``if getattr(obj, \"__final__\", " @@ -4846,11 +4945,11 @@ msgid "" "exception." msgstr "" -#: ../../library/typing.rst:3090 +#: ../../library/typing.rst:3130 msgid "Decorator to indicate that annotations are not type hints." msgstr "" -#: ../../library/typing.rst:3092 +#: ../../library/typing.rst:3132 msgid "" "This works as a class or function :term:`decorator`. With a class, it " "applies recursively to all methods and classes defined in that class (but " @@ -4858,40 +4957,40 @@ msgid "" "will ignore all annotations in a function or class with this decorator." msgstr "" -#: ../../library/typing.rst:3098 +#: ../../library/typing.rst:3138 msgid "``@no_type_check`` mutates the decorated object in place." msgstr "" -#: ../../library/typing.rst:3102 +#: ../../library/typing.rst:3142 msgid "Decorator to give another decorator the :func:`no_type_check` effect." msgstr "" -#: ../../library/typing.rst:3104 +#: ../../library/typing.rst:3144 msgid "" "This wraps the decorator with something that wraps the decorated function " "in :func:`no_type_check`." msgstr "" -#: ../../library/typing.rst:3107 +#: ../../library/typing.rst:3147 msgid "" "No type checker ever added support for ``@no_type_check_decorator``. It is " "therefore deprecated, and will be removed in Python 3.15." msgstr "" -#: ../../library/typing.rst:3113 +#: ../../library/typing.rst:3153 msgid "" "Decorator to indicate that a method in a subclass is intended to override a " "method or attribute in a superclass." msgstr "" -#: ../../library/typing.rst:3116 +#: ../../library/typing.rst:3156 msgid "" "Type checkers should emit an error if a method decorated with ``@override`` " "does not, in fact, override anything. This helps prevent bugs that may occur " "when a base class is changed without an equivalent change to a child class." msgstr "" -#: ../../library/typing.rst:3123 +#: ../../library/typing.rst:3163 msgid "" "class Base:\n" " def log_status(self) -> None:\n" @@ -4907,11 +5006,11 @@ msgid "" " ..." msgstr "" -#: ../../library/typing.rst:3138 +#: ../../library/typing.rst:3178 msgid "There is no runtime checking of this property." msgstr "" -#: ../../library/typing.rst:3140 +#: ../../library/typing.rst:3180 msgid "" "The decorator will attempt to set an ``__override__`` attribute to ``True`` " "on the decorated object. Thus, a check like ``if getattr(obj, " @@ -4921,22 +5020,22 @@ msgid "" "without raising an exception." msgstr "" -#: ../../library/typing.rst:3147 +#: ../../library/typing.rst:3187 msgid "See :pep:`698` for more details." msgstr "更多細節請見 :pep:`698`。" -#: ../../library/typing.rst:3154 +#: ../../library/typing.rst:3194 msgid "Decorator to mark a class or function as unavailable at runtime." msgstr "" -#: ../../library/typing.rst:3156 +#: ../../library/typing.rst:3196 msgid "" "This decorator is itself not available at runtime. It is mainly intended to " "mark classes that are defined in type stub files if an implementation " "returns an instance of a private class::" msgstr "" -#: ../../library/typing.rst:3160 +#: ../../library/typing.rst:3200 msgid "" "@type_check_only\n" "class Response: # private or not available at runtime\n" @@ -4946,29 +5045,29 @@ msgid "" "def fetch_response() -> Response: ..." msgstr "" -#: ../../library/typing.rst:3167 +#: ../../library/typing.rst:3207 msgid "" "Note that returning instances of private classes is not recommended. It is " "usually preferable to make such classes public." msgstr "" -#: ../../library/typing.rst:3171 +#: ../../library/typing.rst:3211 msgid "Introspection helpers" msgstr "" -#: ../../library/typing.rst:3175 +#: ../../library/typing.rst:3215 msgid "" "Return a dictionary containing type hints for a function, method, module or " "class object." msgstr "" -#: ../../library/typing.rst:3178 +#: ../../library/typing.rst:3218 msgid "" "This is often the same as ``obj.__annotations__``, but this function makes " "the following changes to the annotations dictionary:" msgstr "" -#: ../../library/typing.rst:3181 +#: ../../library/typing.rst:3221 msgid "" "Forward references encoded as string literals or :class:`ForwardRef` objects " "are handled by evaluating them in *globalns*, *localns*, and (where " @@ -4977,17 +5076,17 @@ msgid "" "inferred from *obj*." msgstr "" -#: ../../library/typing.rst:3186 +#: ../../library/typing.rst:3226 msgid "``None`` is replaced with :class:`types.NoneType`." msgstr "" -#: ../../library/typing.rst:3187 +#: ../../library/typing.rst:3227 msgid "" "If :func:`@no_type_check ` has been applied to *obj*, an " "empty dictionary is returned." msgstr "" -#: ../../library/typing.rst:3189 +#: ../../library/typing.rst:3229 msgid "" "If *obj* is a class ``C``, the function returns a dictionary that merges " "annotations from ``C``'s base classes with those on ``C`` directly. This is " @@ -4997,20 +5096,20 @@ msgid "" "annotations on classes appearing later in the method resolution order." msgstr "" -#: ../../library/typing.rst:3196 +#: ../../library/typing.rst:3236 msgid "" "The function recursively replaces all occurrences of ``Annotated[T, ...]`` " "with ``T``, unless *include_extras* is set to ``True`` " "(see :class:`Annotated` for more information)." msgstr "" -#: ../../library/typing.rst:3200 +#: ../../library/typing.rst:3240 msgid "" "See also :func:`inspect.get_annotations`, a lower-level function that " "returns annotations more directly." msgstr "" -#: ../../library/typing.rst:3205 +#: ../../library/typing.rst:3245 msgid "" "If any forward references in the annotations of *obj* are not resolvable or " "are not valid Python code, this function will raise an exception such " @@ -5019,7 +5118,7 @@ msgid "" "imported under :data:`if TYPE_CHECKING `." msgstr "" -#: ../../library/typing.rst:3211 +#: ../../library/typing.rst:3251 msgid "" "Added ``include_extras`` parameter as part of :pep:`593`. See the " "documentation on :data:`Annotated` for more information." @@ -5027,20 +5126,20 @@ msgstr "" "新增 ``include_extras`` 參數(如 :pep:`593` 中所述)。更多資訊請" "見 :data:`Annotated` 的文件。" -#: ../../library/typing.rst:3215 +#: ../../library/typing.rst:3255 msgid "" "Previously, ``Optional[t]`` was added for function and method annotations if " "a default value equal to ``None`` was set. Now the annotation is returned " "unchanged." msgstr "" -#: ../../library/typing.rst:3222 +#: ../../library/typing.rst:3262 msgid "" "Get the unsubscripted version of a type: for a typing object of the form " "``X[Y, Z, ...]`` return ``X``." msgstr "" -#: ../../library/typing.rst:3225 +#: ../../library/typing.rst:3265 msgid "" "If ``X`` is a typing-module alias for a builtin or :mod:`collections` class, " "it will be normalized to the original class. If ``X`` is an instance " @@ -5048,11 +5147,11 @@ msgid "" "underlying :class:`ParamSpec`. Return ``None`` for unsupported objects." msgstr "" -#: ../../library/typing.rst:3231 ../../library/typing.rst:3255 +#: ../../library/typing.rst:3271 ../../library/typing.rst:3295 msgid "Examples:" msgstr "舉例:" -#: ../../library/typing.rst:3233 +#: ../../library/typing.rst:3273 msgid "" "assert get_origin(str) is None\n" "assert get_origin(Dict[str, int]) is dict\n" @@ -5070,13 +5169,13 @@ msgstr "" "assert get_origin(P.args) is P\n" "assert get_origin(P.kwargs) is P" -#: ../../library/typing.rst:3247 +#: ../../library/typing.rst:3287 msgid "" "Get type arguments with all substitutions performed: for a typing object of " "the form ``X[Y, Z, ...]`` return ``(Y, Z, ...)``." msgstr "" -#: ../../library/typing.rst:3250 +#: ../../library/typing.rst:3290 msgid "" "If ``X`` is a union or :class:`Literal` contained in another generic type, " "the order of ``(Y, Z, ...)`` may be different from the order of the original " @@ -5084,7 +5183,7 @@ msgid "" "objects." msgstr "" -#: ../../library/typing.rst:3257 +#: ../../library/typing.rst:3297 msgid "" "assert get_args(int) == ()\n" "assert get_args(Dict[int, str]) == (int, str)\n" @@ -5094,11 +5193,11 @@ msgstr "" "assert get_args(Dict[int, str]) == (int, str)\n" "assert get_args(Union[int, str]) == (int, str)" -#: ../../library/typing.rst:3267 +#: ../../library/typing.rst:3307 msgid "Return the set of members defined in a :class:`Protocol`." msgstr "" -#: ../../library/typing.rst:3269 +#: ../../library/typing.rst:3309 msgid "" ">>> from typing import Protocol, get_protocol_members\n" ">>> class P(Protocol):\n" @@ -5114,15 +5213,15 @@ msgstr "" ">>> get_protocol_members(P) == frozenset({'a', 'b'})\n" "True" -#: ../../library/typing.rst:3278 +#: ../../library/typing.rst:3318 msgid "Raise :exc:`TypeError` for arguments that are not Protocols." msgstr "" -#: ../../library/typing.rst:3284 +#: ../../library/typing.rst:3324 msgid "Determine if a type is a :class:`Protocol`." msgstr "確定一個型別是否 :class:`Protocol`。" -#: ../../library/typing.rst:3288 +#: ../../library/typing.rst:3328 msgid "" "class P(Protocol):\n" " def a(self) -> str: ...\n" @@ -5138,11 +5237,11 @@ msgstr "" "is_protocol(P) # => True\n" "is_protocol(int) # => False" -#: ../../library/typing.rst:3299 +#: ../../library/typing.rst:3339 msgid "Check if a type is a :class:`TypedDict`." msgstr "" -#: ../../library/typing.rst:3303 +#: ../../library/typing.rst:3343 msgid "" "class Film(TypedDict):\n" " title: str\n" @@ -5156,32 +5255,32 @@ msgid "" "assert not is_typeddict(TypedDict)" msgstr "" -#: ../../library/typing.rst:3320 +#: ../../library/typing.rst:3360 msgid "" "Class used for internal typing representation of string forward references." msgstr "" -#: ../../library/typing.rst:3322 +#: ../../library/typing.rst:3362 msgid "" "For example, ``List[\"SomeClass\"]`` is implicitly transformed into " "``List[ForwardRef(\"SomeClass\")]``. ``ForwardRef`` should not be " "instantiated by a user, but may be used by introspection tools." msgstr "" -#: ../../library/typing.rst:3327 +#: ../../library/typing.rst:3367 msgid "" ":pep:`585` generic types such as ``list[\"SomeClass\"]`` will not be " "implicitly transformed into ``list[ForwardRef(\"SomeClass\")]`` and thus " "will not automatically resolve to ``list[SomeClass]``." msgstr "" -#: ../../library/typing.rst:3335 +#: ../../library/typing.rst:3375 msgid "" "A sentinel object used to indicate that a type parameter has no default " "value. For example:" msgstr "" -#: ../../library/typing.rst:3338 +#: ../../library/typing.rst:3378 msgid "" ">>> T = TypeVar(\"T\")\n" ">>> T.__default__ is typing.NoDefault\n" @@ -5197,17 +5296,17 @@ msgstr "" ">>> S.__default__ is None\n" "True" -#: ../../library/typing.rst:3350 +#: ../../library/typing.rst:3390 msgid "Constant" msgstr "常數" -#: ../../library/typing.rst:3354 +#: ../../library/typing.rst:3394 msgid "" "A special constant that is assumed to be ``True`` by 3rd party static type " "checkers. It is ``False`` at runtime." msgstr "" -#: ../../library/typing.rst:3359 +#: ../../library/typing.rst:3399 msgid "" "if TYPE_CHECKING:\n" " import expensive_mod\n" @@ -5221,7 +5320,7 @@ msgstr "" "def fun(arg: 'expensive_mod.SomeType') -> None:\n" " local_var: expensive_mod.AnotherType = other_fun()" -#: ../../library/typing.rst:3365 +#: ../../library/typing.rst:3405 msgid "" "The first type annotation must be enclosed in quotes, making it a \"forward " "reference\", to hide the ``expensive_mod`` reference from the interpreter " @@ -5229,7 +5328,7 @@ msgid "" "second annotation does not need to be enclosed in quotes." msgstr "" -#: ../../library/typing.rst:3372 +#: ../../library/typing.rst:3412 msgid "" "If ``from __future__ import annotations`` is used, annotations are not " "evaluated at function definition time. Instead, they are stored as strings " @@ -5237,11 +5336,11 @@ msgid "" "annotation (see :pep:`563`)." msgstr "" -#: ../../library/typing.rst:3384 +#: ../../library/typing.rst:3424 msgid "Deprecated aliases" msgstr "棄用的別名" -#: ../../library/typing.rst:3386 +#: ../../library/typing.rst:3426 msgid "" "This module defines several deprecated aliases to pre-existing standard " "library classes. These were originally included in the :mod:`!typing` module " @@ -5250,7 +5349,7 @@ msgid "" "pre-existing classes were enhanced to support ``[]`` (see :pep:`585`)." msgstr "" -#: ../../library/typing.rst:3393 +#: ../../library/typing.rst:3433 msgid "" "The redundant types are deprecated as of Python 3.9. However, while the " "aliases may be removed at some point, removal of these aliases is not " @@ -5258,7 +5357,7 @@ msgid "" "the interpreter for these aliases." msgstr "" -#: ../../library/typing.rst:3398 +#: ../../library/typing.rst:3438 msgid "" "If at some point it is decided to remove these deprecated aliases, a " "deprecation warning will be issued by the interpreter for at least two " @@ -5267,38 +5366,38 @@ msgid "" "3.14." msgstr "" -#: ../../library/typing.rst:3403 +#: ../../library/typing.rst:3443 msgid "" "Type checkers are encouraged to flag uses of the deprecated types if the " "program they are checking targets a minimum Python version of 3.9 or newer." msgstr "" -#: ../../library/typing.rst:3409 +#: ../../library/typing.rst:3449 msgid "Aliases to built-in types" msgstr "內建型別的別名" -#: ../../library/typing.rst:3413 +#: ../../library/typing.rst:3453 msgid "Deprecated alias to :class:`dict`." msgstr "棄用 :class:`dict` 的別名。" -#: ../../library/typing.rst:3415 +#: ../../library/typing.rst:3455 msgid "" "Note that to annotate arguments, it is preferred to use an abstract " "collection type such as :class:`~collections.abc.Mapping` rather than to " "use :class:`dict` or :class:`!typing.Dict`." msgstr "" -#: ../../library/typing.rst:3419 +#: ../../library/typing.rst:3459 msgid "" ":class:`builtins.dict ` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3425 +#: ../../library/typing.rst:3465 msgid "Deprecated alias to :class:`list`." msgstr "棄用 :class:`list` 的別名。" -#: ../../library/typing.rst:3427 +#: ../../library/typing.rst:3467 msgid "" "Note that to annotate arguments, it is preferred to use an abstract " "collection type such as :class:`~collections.abc.Sequence` " @@ -5306,136 +5405,136 @@ msgid "" "or :class:`!typing.List`." msgstr "" -#: ../../library/typing.rst:3432 +#: ../../library/typing.rst:3472 msgid "" ":class:`builtins.list ` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3438 +#: ../../library/typing.rst:3478 msgid "Deprecated alias to :class:`builtins.set `." msgstr "棄用 :class:`builtins.set ` 的別名。" -#: ../../library/typing.rst:3440 +#: ../../library/typing.rst:3480 msgid "" "Note that to annotate arguments, it is preferred to use an abstract " "collection type such as :class:`collections.abc.Set` rather than to " "use :class:`set` or :class:`typing.Set`." msgstr "" -#: ../../library/typing.rst:3444 +#: ../../library/typing.rst:3484 msgid "" ":class:`builtins.set ` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3450 +#: ../../library/typing.rst:3490 msgid "Deprecated alias to :class:`builtins.frozenset `." msgstr "棄用 :class:`builtins.frozenset ` 的別名。" -#: ../../library/typing.rst:3452 +#: ../../library/typing.rst:3492 msgid "" ":class:`builtins.frozenset ` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3459 +#: ../../library/typing.rst:3499 msgid "Deprecated alias for :class:`tuple`." msgstr "棄用 :class:`tuple` 的別名。" -#: ../../library/typing.rst:3461 +#: ../../library/typing.rst:3501 msgid "" ":class:`tuple` and ``Tuple`` are special-cased in the type system; " "see :ref:`annotating-tuples` for more details." msgstr "" -#: ../../library/typing.rst:3464 +#: ../../library/typing.rst:3504 msgid "" ":class:`builtins.tuple ` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3470 +#: ../../library/typing.rst:3510 msgid "Deprecated alias to :class:`type`." msgstr "棄用 :class:`type` 的別名。" -#: ../../library/typing.rst:3472 +#: ../../library/typing.rst:3512 msgid "" "See :ref:`type-of-class-objects` for details on using :class:`type` or " "``typing.Type`` in type annotations." msgstr "" -#: ../../library/typing.rst:3477 +#: ../../library/typing.rst:3517 msgid "" ":class:`builtins.type ` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3484 +#: ../../library/typing.rst:3524 msgid "Aliases to types in :mod:`collections`" msgstr ":mod:`collections` 中型別的別名" -#: ../../library/typing.rst:3488 +#: ../../library/typing.rst:3528 msgid "Deprecated alias to :class:`collections.defaultdict`." msgstr "棄用 :class:`collections.defaultdict` 的別名。" -#: ../../library/typing.rst:3492 +#: ../../library/typing.rst:3532 msgid "" ":class:`collections.defaultdict` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3498 +#: ../../library/typing.rst:3538 msgid "Deprecated alias to :class:`collections.OrderedDict`." msgstr "棄用 :class:`collections.OrderedDict` 的別名。" -#: ../../library/typing.rst:3502 +#: ../../library/typing.rst:3542 msgid "" ":class:`collections.OrderedDict` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3508 +#: ../../library/typing.rst:3548 msgid "Deprecated alias to :class:`collections.ChainMap`." msgstr "棄用 :class:`collections.ChainMap` 的別名。" -#: ../../library/typing.rst:3512 +#: ../../library/typing.rst:3552 msgid "" ":class:`collections.ChainMap` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3518 +#: ../../library/typing.rst:3558 msgid "Deprecated alias to :class:`collections.Counter`." msgstr "棄用 :class:`collections.Counter` 的別名。" -#: ../../library/typing.rst:3522 +#: ../../library/typing.rst:3562 msgid "" ":class:`collections.Counter` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3528 +#: ../../library/typing.rst:3568 msgid "Deprecated alias to :class:`collections.deque`." msgstr "棄用 :class:`collections.deque` 的別名。" -#: ../../library/typing.rst:3532 +#: ../../library/typing.rst:3572 msgid "" ":class:`collections.deque` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3539 +#: ../../library/typing.rst:3579 msgid "Aliases to other concrete types" msgstr "" -#: ../../library/typing.rst:3544 +#: ../../library/typing.rst:3584 msgid "" "Deprecated aliases corresponding to the return types from :func:`re.compile` " "and :func:`re.match`." msgstr "" -#: ../../library/typing.rst:3547 +#: ../../library/typing.rst:3587 msgid "" "These types (and the corresponding functions) are generic " "over :data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or " @@ -5443,29 +5542,29 @@ msgid "" "``Match[bytes]``." msgstr "" -#: ../../library/typing.rst:3552 +#: ../../library/typing.rst:3592 msgid "" "Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3558 +#: ../../library/typing.rst:3598 msgid "Deprecated alias for :class:`str`." msgstr "棄用 :class:`str` 的別名。" -#: ../../library/typing.rst:3560 +#: ../../library/typing.rst:3600 msgid "" "``Text`` is provided to supply a forward compatible path for Python 2 code: " "in Python 2, ``Text`` is an alias for ``unicode``." msgstr "" -#: ../../library/typing.rst:3564 +#: ../../library/typing.rst:3604 msgid "" "Use ``Text`` to indicate that a value must contain a unicode string in a " "manner that is compatible with both Python 2 and Python 3::" msgstr "" -#: ../../library/typing.rst:3567 +#: ../../library/typing.rst:3607 msgid "" "def add_unicode_checkmark(text: Text) -> Text:\n" " return text + u' \\u2713'" @@ -5473,318 +5572,318 @@ msgstr "" "def add_unicode_checkmark(text: Text) -> Text:\n" " return text + u' \\u2713'" -#: ../../library/typing.rst:3572 +#: ../../library/typing.rst:3612 msgid "" "Python 2 is no longer supported, and most type checkers also no longer " "support type checking Python 2 code. Removal of the alias is not currently " "planned, but users are encouraged to use :class:`str` instead of ``Text``." msgstr "" -#: ../../library/typing.rst:3582 +#: ../../library/typing.rst:3622 msgid "Aliases to container ABCs in :mod:`collections.abc`" msgstr ":mod:`collections.abc` 中容器 ABC 的別名" -#: ../../library/typing.rst:3586 +#: ../../library/typing.rst:3626 msgid "Deprecated alias to :class:`collections.abc.Set`." msgstr "棄用 :class:`collections.abc.Set` 的別名。" -#: ../../library/typing.rst:3588 +#: ../../library/typing.rst:3628 msgid "" ":class:`collections.abc.Set` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3594 +#: ../../library/typing.rst:3634 msgid "" "This type represents the types :class:`bytes`, :class:`bytearray`, " "and :class:`memoryview` of byte sequences." msgstr "" -#: ../../library/typing.rst:3597 +#: ../../library/typing.rst:3637 msgid "" "Prefer :class:`collections.abc.Buffer`, or a union like ``bytes | bytearray " "| memoryview``." msgstr "" -#: ../../library/typing.rst:3602 +#: ../../library/typing.rst:3642 msgid "Deprecated alias to :class:`collections.abc.Collection`." msgstr "棄用 :class:`collections.abc.Collection` 的別名。" -#: ../../library/typing.rst:3606 +#: ../../library/typing.rst:3646 msgid "" ":class:`collections.abc.Collection` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3612 +#: ../../library/typing.rst:3652 msgid "Deprecated alias to :class:`collections.abc.Container`." msgstr "棄用 :class:`collections.abc.Container` 的別名。" -#: ../../library/typing.rst:3614 +#: ../../library/typing.rst:3654 msgid "" ":class:`collections.abc.Container` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3620 +#: ../../library/typing.rst:3660 msgid "Deprecated alias to :class:`collections.abc.ItemsView`." msgstr "棄用 :class:`collections.abc.ItemsView` 的別名。" -#: ../../library/typing.rst:3622 +#: ../../library/typing.rst:3662 msgid "" ":class:`collections.abc.ItemsView` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3628 +#: ../../library/typing.rst:3668 msgid "Deprecated alias to :class:`collections.abc.KeysView`." msgstr "棄用 :class:`collections.abc.KeysView` 的別名。" -#: ../../library/typing.rst:3630 +#: ../../library/typing.rst:3670 msgid "" ":class:`collections.abc.KeysView` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3636 +#: ../../library/typing.rst:3676 msgid "Deprecated alias to :class:`collections.abc.Mapping`." msgstr "棄用 :class:`collections.abc.Mapping` 的別名。" -#: ../../library/typing.rst:3638 +#: ../../library/typing.rst:3678 msgid "" ":class:`collections.abc.Mapping` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3644 +#: ../../library/typing.rst:3684 msgid "Deprecated alias to :class:`collections.abc.MappingView`." msgstr "棄用 :class:`collections.abc.MappingView` 的別名。" -#: ../../library/typing.rst:3646 +#: ../../library/typing.rst:3686 msgid "" ":class:`collections.abc.MappingView` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3652 +#: ../../library/typing.rst:3692 msgid "Deprecated alias to :class:`collections.abc.MutableMapping`." msgstr "棄用 :class:`collections.abc.MutableMapping` 的別名。" -#: ../../library/typing.rst:3654 +#: ../../library/typing.rst:3694 msgid "" ":class:`collections.abc.MutableMapping` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3661 +#: ../../library/typing.rst:3701 msgid "Deprecated alias to :class:`collections.abc.MutableSequence`." msgstr "棄用 :class:`collections.abc.MutableSequence` 的別名。" -#: ../../library/typing.rst:3663 +#: ../../library/typing.rst:3703 msgid "" ":class:`collections.abc.MutableSequence` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3670 +#: ../../library/typing.rst:3710 msgid "Deprecated alias to :class:`collections.abc.MutableSet`." msgstr "棄用 :class:`collections.abc.MutableSet` 的別名。" -#: ../../library/typing.rst:3672 +#: ../../library/typing.rst:3712 msgid "" ":class:`collections.abc.MutableSet` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3678 +#: ../../library/typing.rst:3718 msgid "Deprecated alias to :class:`collections.abc.Sequence`." msgstr "棄用 :class:`collections.abc.Sequence` 的別名。" -#: ../../library/typing.rst:3680 +#: ../../library/typing.rst:3720 msgid "" ":class:`collections.abc.Sequence` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3686 +#: ../../library/typing.rst:3726 msgid "Deprecated alias to :class:`collections.abc.ValuesView`." msgstr "棄用 :class:`collections.abc.ValuesView` 的別名。" -#: ../../library/typing.rst:3688 +#: ../../library/typing.rst:3728 msgid "" ":class:`collections.abc.ValuesView` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3695 +#: ../../library/typing.rst:3735 msgid "Aliases to asynchronous ABCs in :mod:`collections.abc`" msgstr ":mod:`collections.abc` 中非同步 ABC 的別名" -#: ../../library/typing.rst:3699 +#: ../../library/typing.rst:3739 msgid "Deprecated alias to :class:`collections.abc.Coroutine`." msgstr "棄用 :class:`collections.abc.Coroutine` 的別名。" -#: ../../library/typing.rst:3701 +#: ../../library/typing.rst:3741 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on " "using :class:`collections.abc.Coroutine` and ``typing.Coroutine`` in type " "annotations." msgstr "" -#: ../../library/typing.rst:3707 +#: ../../library/typing.rst:3747 msgid "" ":class:`collections.abc.Coroutine` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3713 +#: ../../library/typing.rst:3753 msgid "Deprecated alias to :class:`collections.abc.AsyncGenerator`." msgstr "棄用 :class:`collections.abc.AsyncGenerator` 的別名。" -#: ../../library/typing.rst:3715 +#: ../../library/typing.rst:3755 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on " "using :class:`collections.abc.AsyncGenerator` and ``typing.AsyncGenerator`` " "in type annotations." msgstr "" -#: ../../library/typing.rst:3721 +#: ../../library/typing.rst:3761 msgid "" ":class:`collections.abc.AsyncGenerator` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3726 +#: ../../library/typing.rst:3766 msgid "The ``SendType`` parameter now has a default." msgstr "``SendType`` 參數現在有預設值。" -#: ../../library/typing.rst:3731 +#: ../../library/typing.rst:3771 msgid "Deprecated alias to :class:`collections.abc.AsyncIterable`." msgstr "棄用 :class:`collections.abc.AsyncIterable` 的別名。" -#: ../../library/typing.rst:3735 +#: ../../library/typing.rst:3775 msgid "" ":class:`collections.abc.AsyncIterable` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3741 +#: ../../library/typing.rst:3781 msgid "Deprecated alias to :class:`collections.abc.AsyncIterator`." msgstr "棄用 :class:`collections.abc.AsyncIterator` 的別名。" -#: ../../library/typing.rst:3745 +#: ../../library/typing.rst:3785 msgid "" ":class:`collections.abc.AsyncIterator` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3751 +#: ../../library/typing.rst:3791 msgid "Deprecated alias to :class:`collections.abc.Awaitable`." msgstr "棄用 :class:`collections.abc.Awaitable` 的別名。" -#: ../../library/typing.rst:3755 +#: ../../library/typing.rst:3795 msgid "" ":class:`collections.abc.Awaitable` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3762 +#: ../../library/typing.rst:3802 msgid "Aliases to other ABCs in :mod:`collections.abc`" msgstr "" -#: ../../library/typing.rst:3766 +#: ../../library/typing.rst:3806 msgid "Deprecated alias to :class:`collections.abc.Iterable`." msgstr "棄用 :class:`collections.abc.Iterable` 的別名。" -#: ../../library/typing.rst:3768 +#: ../../library/typing.rst:3808 msgid "" ":class:`collections.abc.Iterable` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3774 +#: ../../library/typing.rst:3814 msgid "Deprecated alias to :class:`collections.abc.Iterator`." msgstr "棄用 :class:`collections.abc.Iterator` 的別名。" -#: ../../library/typing.rst:3776 +#: ../../library/typing.rst:3816 msgid "" ":class:`collections.abc.Iterator` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3782 +#: ../../library/typing.rst:3822 msgid "Deprecated alias to :class:`collections.abc.Callable`." msgstr "棄用 :class:`collections.abc.Callable` 的別名。" -#: ../../library/typing.rst:3784 +#: ../../library/typing.rst:3824 msgid "" "See :ref:`annotating-callables` for details on how to " "use :class:`collections.abc.Callable` and ``typing.Callable`` in type " "annotations." msgstr "" -#: ../../library/typing.rst:3787 +#: ../../library/typing.rst:3827 msgid "" ":class:`collections.abc.Callable` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3797 +#: ../../library/typing.rst:3837 msgid "Deprecated alias to :class:`collections.abc.Generator`." msgstr "棄用 :class:`collections.abc.Generator` 的別名。" -#: ../../library/typing.rst:3799 +#: ../../library/typing.rst:3839 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on " "using :class:`collections.abc.Generator` and ``typing.Generator`` in type " "annotations." msgstr "" -#: ../../library/typing.rst:3803 +#: ../../library/typing.rst:3843 msgid "" ":class:`collections.abc.Generator` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3807 +#: ../../library/typing.rst:3847 msgid "Default values for the send and return types were added." msgstr "" -#: ../../library/typing.rst:3812 +#: ../../library/typing.rst:3852 msgid "Deprecated alias to :class:`collections.abc.Hashable`." msgstr "棄用 :class:`collections.abc.Hashable` 的別名。" -#: ../../library/typing.rst:3814 +#: ../../library/typing.rst:3854 msgid "Use :class:`collections.abc.Hashable` directly instead." msgstr "改為直接使用 :class:`collections.abc.Hashable`。" -#: ../../library/typing.rst:3819 +#: ../../library/typing.rst:3859 msgid "Deprecated alias to :class:`collections.abc.Reversible`." msgstr "棄用 :class:`collections.abc.Reversible` 的別名。" -#: ../../library/typing.rst:3821 +#: ../../library/typing.rst:3861 msgid "" ":class:`collections.abc.Reversible` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3827 +#: ../../library/typing.rst:3867 msgid "Deprecated alias to :class:`collections.abc.Sized`." msgstr "棄用 :class:`collections.abc.Sized` 的別名。" -#: ../../library/typing.rst:3829 +#: ../../library/typing.rst:3869 msgid "Use :class:`collections.abc.Sized` directly instead." msgstr "改為直接使用 :class:`collections.abc.Sized`。" -#: ../../library/typing.rst:3835 +#: ../../library/typing.rst:3875 msgid "Aliases to :mod:`contextlib` ABCs" msgstr ":mod:`contextlib` ABC 的別名" -#: ../../library/typing.rst:3839 +#: ../../library/typing.rst:3879 msgid "Deprecated alias to :class:`contextlib.AbstractContextManager`." msgstr "" -#: ../../library/typing.rst:3841 +#: ../../library/typing.rst:3881 msgid "" "The first type parameter, ``T_co``, represents the type returned by " "the :meth:`~object.__enter__` method. The optional second type parameter, " @@ -5792,21 +5891,21 @@ msgid "" "returned by the :meth:`~object.__exit__` method." msgstr "" -#: ../../library/typing.rst:3848 +#: ../../library/typing.rst:3888 msgid "" ":class:`contextlib.AbstractContextManager` now supports subscripting " "(``[]``). See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3853 +#: ../../library/typing.rst:3893 msgid "Added the optional second type parameter, ``ExitT_co``." msgstr "" -#: ../../library/typing.rst:3858 +#: ../../library/typing.rst:3898 msgid "Deprecated alias to :class:`contextlib.AbstractAsyncContextManager`." msgstr "" -#: ../../library/typing.rst:3860 +#: ../../library/typing.rst:3900 msgid "" "The first type parameter, ``T_co``, represents the type returned by " "the :meth:`~object.__aenter__` method. The optional second type parameter, " @@ -5814,21 +5913,21 @@ msgid "" "returned by the :meth:`~object.__aexit__` method." msgstr "" -#: ../../library/typing.rst:3867 +#: ../../library/typing.rst:3907 msgid "" ":class:`contextlib.AbstractAsyncContextManager` now supports subscripting " "(``[]``). See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3872 +#: ../../library/typing.rst:3912 msgid "Added the optional second type parameter, ``AExitT_co``." msgstr "" -#: ../../library/typing.rst:3876 +#: ../../library/typing.rst:3916 msgid "Deprecation Timeline of Major Features" msgstr "主要功能的棄用時程表" -#: ../../library/typing.rst:3878 +#: ../../library/typing.rst:3918 msgid "" "Certain features in ``typing`` are deprecated and may be removed in a future " "version of Python. The following table summarizes major deprecations for " @@ -5836,112 +5935,112 @@ msgid "" "listed." msgstr "" -#: ../../library/typing.rst:3885 +#: ../../library/typing.rst:3925 msgid "Feature" msgstr "" -#: ../../library/typing.rst:3886 +#: ../../library/typing.rst:3926 msgid "Deprecated in" msgstr "棄用於" -#: ../../library/typing.rst:3887 +#: ../../library/typing.rst:3927 msgid "Projected removal" msgstr "" -#: ../../library/typing.rst:3888 +#: ../../library/typing.rst:3928 msgid "PEP/issue" msgstr "" -#: ../../library/typing.rst:3889 +#: ../../library/typing.rst:3929 msgid "``typing`` versions of standard collections" msgstr "" -#: ../../library/typing.rst:3890 ../../library/typing.rst:3894 +#: ../../library/typing.rst:3930 ../../library/typing.rst:3934 msgid "3.9" msgstr "3.9" -#: ../../library/typing.rst:3891 +#: ../../library/typing.rst:3931 msgid "Undecided (see :ref:`deprecated-aliases` for more information)" msgstr "" -#: ../../library/typing.rst:3892 +#: ../../library/typing.rst:3932 msgid ":pep:`585`" msgstr ":pep:`585`" -#: ../../library/typing.rst:3893 +#: ../../library/typing.rst:3933 msgid ":class:`typing.ByteString`" msgstr ":class:`typing.ByteString`" -#: ../../library/typing.rst:3895 +#: ../../library/typing.rst:3935 msgid "3.14" msgstr "3.14" -#: ../../library/typing.rst:3896 +#: ../../library/typing.rst:3936 msgid ":gh:`91896`" msgstr ":gh:`91896`" -#: ../../library/typing.rst:3897 +#: ../../library/typing.rst:3937 msgid ":data:`typing.Text`" msgstr ":data:`typing.Text`" -#: ../../library/typing.rst:3898 +#: ../../library/typing.rst:3938 msgid "3.11" msgstr "3.11" -#: ../../library/typing.rst:3899 ../../library/typing.rst:3903 -#: ../../library/typing.rst:3907 +#: ../../library/typing.rst:3939 ../../library/typing.rst:3943 +#: ../../library/typing.rst:3947 msgid "Undecided" msgstr "" -#: ../../library/typing.rst:3900 +#: ../../library/typing.rst:3940 msgid ":gh:`92332`" msgstr ":gh:`92332`" -#: ../../library/typing.rst:3901 +#: ../../library/typing.rst:3941 msgid ":class:`typing.Hashable` and :class:`typing.Sized`" msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`" -#: ../../library/typing.rst:3902 ../../library/typing.rst:3906 +#: ../../library/typing.rst:3942 ../../library/typing.rst:3946 msgid "3.12" msgstr "3.12" -#: ../../library/typing.rst:3904 +#: ../../library/typing.rst:3944 msgid ":gh:`94309`" msgstr ":gh:`94309`" -#: ../../library/typing.rst:3905 +#: ../../library/typing.rst:3945 msgid ":data:`typing.TypeAlias`" msgstr ":data:`typing.TypeAlias`" -#: ../../library/typing.rst:3908 +#: ../../library/typing.rst:3948 msgid ":pep:`695`" msgstr ":pep:`695`" -#: ../../library/typing.rst:3909 +#: ../../library/typing.rst:3949 msgid ":func:`@typing.no_type_check_decorator `" msgstr ":func:`@typing.no_type_check_decorator `" -#: ../../library/typing.rst:3910 ../../library/typing.rst:3914 +#: ../../library/typing.rst:3950 ../../library/typing.rst:3954 msgid "3.13" msgstr "3.13" -#: ../../library/typing.rst:3911 +#: ../../library/typing.rst:3951 msgid "3.15" msgstr "3.15" -#: ../../library/typing.rst:3912 +#: ../../library/typing.rst:3952 msgid ":gh:`106309`" msgstr ":gh:`106309`" -#: ../../library/typing.rst:3913 +#: ../../library/typing.rst:3953 msgid ":data:`typing.AnyStr`" msgstr ":data:`typing.AnyStr`" -#: ../../library/typing.rst:3915 +#: ../../library/typing.rst:3955 msgid "3.18" msgstr "3.18" -#: ../../library/typing.rst:3916 +#: ../../library/typing.rst:3956 msgid ":gh:`105578`" msgstr ":gh:`105578`" diff --git a/library/wsgiref.po b/library/wsgiref.po index f85700c54f..02456816c1 100644 --- a/library/wsgiref.po +++ b/library/wsgiref.po @@ -842,7 +842,7 @@ msgid "" "streams are stored in the :attr:`stdin`, :attr:`stdout`, :attr:`stderr`, " "and :attr:`environ` attributes." msgstr "" -"這個類別是 :class:`BaseHandler` 的子類別。它透過建構器去覆寫 :meth:`!" +"這個類別是 :class:`BaseHandler` 的子類別。它透過建構函式去覆寫 :meth:`!" "__init__`、:meth:`~BaseHandler.get_stdin`、:meth:`~BaseHandler.get_stderr`、:meth:`~BaseHandler.add_cgi_vars`、:meth:`~BaseHandler._write`、" "和 :meth:`~BaseHandler._flush` 方法來明確提供設置環境與串流。提供的環境與串流" "被儲存在 :attr:`stdin`、:attr:`stdout`、:attr:`stderr`、和 :attr:`environ` 環"