From c5fb0c0ae78ca322b2adc97b6c0c8f746dc136c1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 28 Jul 2025 17:31:41 +0000 Subject: [PATCH 01/13] sync with cpython cdae923f --- library/asyncio-eventloop.po | 650 +++++++++--------- library/multiprocessing.po | 1192 +++++++++++++++++----------------- 2 files changed, 924 insertions(+), 918 deletions(-) diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 26091449c9..a337f0aedd 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-07-28 17:30+0000\n" "PO-Revision-Date: 2022-02-20 12:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -295,8 +295,8 @@ msgid "" msgstr "請注意,使用 :func:`asyncio.run` 時不需要呼叫此函式。" #: ../../library/asyncio-eventloop.rst:177 -#: ../../library/asyncio-eventloop.rst:1320 -#: ../../library/asyncio-eventloop.rst:1769 +#: ../../library/asyncio-eventloop.rst:1326 +#: ../../library/asyncio-eventloop.rst:1775 msgid "Example::" msgstr "範例: ::" @@ -687,8 +687,8 @@ msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" #: ../../library/asyncio-eventloop.rst:437 -#: ../../library/asyncio-eventloop.rst:1230 -#: ../../library/asyncio-eventloop.rst:1247 +#: ../../library/asyncio-eventloop.rst:1236 +#: ../../library/asyncio-eventloop.rst:1253 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." @@ -827,8 +827,8 @@ msgstr "" "*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" #: ../../library/asyncio-eventloop.rst:507 -#: ../../library/asyncio-eventloop.rst:623 -#: ../../library/asyncio-eventloop.rst:871 +#: ../../library/asyncio-eventloop.rst:629 +#: ../../library/asyncio-eventloop.rst:877 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." @@ -848,7 +848,7 @@ msgstr "" "式類似於 *host* 和 *port*。" #: ../../library/asyncio-eventloop.rst:515 -#: ../../library/asyncio-eventloop.rst:967 +#: ../../library/asyncio-eventloop.rst:973 msgid "" "*ssl_handshake_timeout* is (for a TLS connection) the time in seconds to " "wait for the TLS handshake to complete before aborting the connection. " @@ -859,9 +859,9 @@ msgstr "" "秒。" #: ../../library/asyncio-eventloop.rst:519 -#: ../../library/asyncio-eventloop.rst:778 -#: ../../library/asyncio-eventloop.rst:882 -#: ../../library/asyncio-eventloop.rst:971 +#: ../../library/asyncio-eventloop.rst:784 +#: ../../library/asyncio-eventloop.rst:888 +#: ../../library/asyncio-eventloop.rst:977 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " @@ -885,7 +885,7 @@ msgstr "" "包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" #: ../../library/asyncio-eventloop.rst:533 -#: ../../library/asyncio-eventloop.rst:790 +#: ../../library/asyncio-eventloop.rst:796 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "新增 :class:`ProactorEventLoop` 中的 SSL/TLS 支援。" @@ -898,7 +898,7 @@ msgstr "" "socket 選項。" #: ../../library/asyncio-eventloop.rst:542 -#: ../../library/asyncio-eventloop.rst:892 +#: ../../library/asyncio-eventloop.rst:898 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "增加 *ssl_handshake_timeout* 參數。" @@ -927,11 +927,11 @@ msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "更多資訊請見: https://datatracker.ietf.org/doc/html/rfc6555" #: ../../library/asyncio-eventloop.rst:561 -#: ../../library/asyncio-eventloop.rst:687 -#: ../../library/asyncio-eventloop.rst:804 -#: ../../library/asyncio-eventloop.rst:844 -#: ../../library/asyncio-eventloop.rst:896 -#: ../../library/asyncio-eventloop.rst:979 +#: ../../library/asyncio-eventloop.rst:693 +#: ../../library/asyncio-eventloop.rst:810 +#: ../../library/asyncio-eventloop.rst:850 +#: ../../library/asyncio-eventloop.rst:902 +#: ../../library/asyncio-eventloop.rst:985 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "增加 *ssl_shutdown_timeout* 參數。" @@ -967,8 +967,8 @@ msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" #: ../../library/asyncio-eventloop.rst:587 -#: ../../library/asyncio-eventloop.rst:714 -#: ../../library/asyncio-eventloop.rst:863 +#: ../../library/asyncio-eventloop.rst:720 +#: ../../library/asyncio-eventloop.rst:869 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." @@ -977,7 +977,7 @@ msgstr "" "protocol>` 實作。" #: ../../library/asyncio-eventloop.rst:590 -#: ../../library/asyncio-eventloop.rst:669 +#: ../../library/asyncio-eventloop.rst:675 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "成功時回傳 ``(transport, protocol)`` 元組。" @@ -990,7 +990,13 @@ msgstr "" "*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" "綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:598 +#: ../../library/asyncio-eventloop.rst:600 +msgid "" +"On Windows, when using the proactor event loop with ``local_addr=None``, an :" +"exc:`OSError` with :attr:`!errno.WSAEINVAL` will be raised when running it." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:604 msgid "" "*remote_addr*, if given, is a ``(remote_host, remote_port)`` tuple used to " "connect the socket to a remote address. The *remote_host* and *remote_port* " @@ -1000,7 +1006,7 @@ msgstr "" "socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:" "`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:602 +#: ../../library/asyncio-eventloop.rst:608 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -1011,7 +1017,7 @@ msgstr "" "的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" "組常數的整數。" -#: ../../library/asyncio-eventloop.rst:607 +#: ../../library/asyncio-eventloop.rst:613 msgid "" "*reuse_port* tells the kernel to allow this endpoint to be bound to the same " "port as other existing endpoints are bound to, so long as they all set this " @@ -1023,13 +1029,13 @@ msgstr "" "時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" "const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" -#: ../../library/asyncio-eventloop.rst:613 +#: ../../library/asyncio-eventloop.rst:619 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" -#: ../../library/asyncio-eventloop.rst:616 +#: ../../library/asyncio-eventloop.rst:622 msgid "" "*sock* can optionally be specified in order to use a preexisting, already " "connected, :class:`socket.socket` object to be used by the transport. If " @@ -1040,7 +1046,7 @@ msgstr "" "供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" "`None`\\ )。" -#: ../../library/asyncio-eventloop.rst:627 +#: ../../library/asyncio-eventloop.rst:633 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." @@ -1048,7 +1054,7 @@ msgstr "" "請參閱 :ref:`UDP 回應用戶端協定 ` 和 :ref:" "`UDP 回應伺服器協定 ` 範例。" -#: ../../library/asyncio-eventloop.rst:630 +#: ../../library/asyncio-eventloop.rst:636 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." @@ -1056,11 +1062,11 @@ msgstr "" "新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" "*allow_broadcast* 和 *sock* 參數。" -#: ../../library/asyncio-eventloop.rst:634 +#: ../../library/asyncio-eventloop.rst:640 msgid "Added support for Windows." msgstr "新增對於 Windows 的支援。" -#: ../../library/asyncio-eventloop.rst:637 +#: ../../library/asyncio-eventloop.rst:643 msgid "" "The *reuse_address* parameter is no longer supported, as using :ref:`socket." "SO_REUSEADDR ` poses a significant security concern " @@ -1069,7 +1075,7 @@ msgstr "" "不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" "於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" -#: ../../library/asyncio-eventloop.rst:643 +#: ../../library/asyncio-eventloop.rst:649 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " @@ -1078,7 +1084,7 @@ msgstr "" "當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " "socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" -#: ../../library/asyncio-eventloop.rst:647 +#: ../../library/asyncio-eventloop.rst:653 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT ` is set by default " @@ -1304,7 +1310,7 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。所有 TCP 連線都預設有 :" "ref:`socket.TCP_NODELAY ` socket 選項。" -#: ../../library/asyncio-eventloop.rst:808 +#: ../../library/asyncio-eventloop.rst:814 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " @@ -1313,7 +1319,7 @@ msgstr "" ":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" "`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:820 +#: ../../library/asyncio-eventloop.rst:826 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." @@ -1321,7 +1327,7 @@ msgstr "" "類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " "家族。" -#: ../../library/asyncio-eventloop.rst:823 +#: ../../library/asyncio-eventloop.rst:829 msgid "" "*path* is the name of a Unix domain socket, and is required, unless a *sock* " "argument is provided. Abstract Unix sockets, :class:`str`, :class:`bytes`, " @@ -1331,7 +1337,7 @@ msgstr "" "象 Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路" "徑。" -#: ../../library/asyncio-eventloop.rst:828 +#: ../../library/asyncio-eventloop.rst:834 msgid "" "If *cleanup_socket* is true then the Unix socket will automatically be " "removed from the filesystem when the server is closed, unless the socket has " @@ -1340,13 +1346,13 @@ msgstr "" "如果 *cleanup_socket* 為真,則 Unix socket 將在伺服器關閉時自動從檔案系統中刪" "除,除非在建立伺服器後替換了 socket。" -#: ../../library/asyncio-eventloop.rst:832 +#: ../../library/asyncio-eventloop.rst:838 msgid "" "See the documentation of the :meth:`loop.create_server` method for " "information about arguments to this method." msgstr "有關此方法的引數資訊,請參閱 :meth:`loop.create_server` 方法的文件。" -#: ../../library/asyncio-eventloop.rst:839 +#: ../../library/asyncio-eventloop.rst:845 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." @@ -1354,26 +1360,26 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" "個 :class:`~pathlib.Path` 物件。" -#: ../../library/asyncio-eventloop.rst:848 +#: ../../library/asyncio-eventloop.rst:854 msgid "Added the *cleanup_socket* parameter." msgstr "加入 *cleanup_socket* 參數。" -#: ../../library/asyncio-eventloop.rst:856 +#: ../../library/asyncio-eventloop.rst:862 msgid "Wrap an already accepted connection into a transport/protocol pair." msgstr "將已接受的連線包裝成傳輸層/協定對。" -#: ../../library/asyncio-eventloop.rst:858 +#: ../../library/asyncio-eventloop.rst:864 msgid "" "This method can be used by servers that accept connections outside of " "asyncio but that use asyncio to handle them." msgstr "此方法可以由在 asyncio 外接受連線但使用 asyncio 處理連線的伺服器使用。" -#: ../../library/asyncio-eventloop.rst:861 -#: ../../library/asyncio-eventloop.rst:953 +#: ../../library/asyncio-eventloop.rst:867 +#: ../../library/asyncio-eventloop.rst:959 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-eventloop.rst:866 +#: ../../library/asyncio-eventloop.rst:872 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." @@ -1381,13 +1387,13 @@ msgstr "" "*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " "socket 物件。" -#: ../../library/asyncio-eventloop.rst:875 +#: ../../library/asyncio-eventloop.rst:881 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over the " "accepted connections." msgstr "*ssl* 可以設置為 :class:`~ssl.SSLContext` 以在已接受的連線上啟用 SSL。" -#: ../../library/asyncio-eventloop.rst:878 +#: ../../library/asyncio-eventloop.rst:884 msgid "" "*ssl_handshake_timeout* is (for an SSL connection) the time in seconds to " "wait for the SSL handshake to complete before aborting the connection. " @@ -1396,29 +1402,29 @@ msgstr "" "(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" "的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:886 +#: ../../library/asyncio-eventloop.rst:892 msgid "Returns a ``(transport, protocol)`` pair." msgstr "回傳 ``(transport, protocol)`` 對。" -#: ../../library/asyncio-eventloop.rst:900 +#: ../../library/asyncio-eventloop.rst:906 msgid "Transferring files" msgstr "傳輸檔案" -#: ../../library/asyncio-eventloop.rst:906 +#: ../../library/asyncio-eventloop.rst:912 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:909 +#: ../../library/asyncio-eventloop.rst:915 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" -#: ../../library/asyncio-eventloop.rst:911 +#: ../../library/asyncio-eventloop.rst:917 msgid "*file* must be a regular file object opened in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:913 -#: ../../library/asyncio-eventloop.rst:1174 +#: ../../library/asyncio-eventloop.rst:919 +#: ../../library/asyncio-eventloop.rst:1180 msgid "" "*offset* tells from where to start reading the file. If specified, *count* " "is the total number of bytes to transmit as opposed to sending the file " @@ -1430,7 +1436,7 @@ msgstr "" "不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" "用 :meth:`file.tell() ` 取得實際發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:920 +#: ../../library/asyncio-eventloop.rst:926 msgid "" "*fallback* set to ``True`` makes asyncio to manually read and send the file " "when the platform does not support the sendfile system call (e.g. Windows or " @@ -1439,7 +1445,7 @@ msgstr "" "將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:924 +#: ../../library/asyncio-eventloop.rst:930 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." @@ -1447,15 +1453,15 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:931 +#: ../../library/asyncio-eventloop.rst:937 msgid "TLS Upgrade" msgstr "TLS 升級" -#: ../../library/asyncio-eventloop.rst:939 +#: ../../library/asyncio-eventloop.rst:945 msgid "Upgrade an existing transport-based connection to TLS." msgstr "將基於傳輸的現有連線升級到 TLS。" -#: ../../library/asyncio-eventloop.rst:941 +#: ../../library/asyncio-eventloop.rst:947 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " @@ -1464,7 +1470,7 @@ msgstr "" "建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" "作了對於 *transport* 的協定,也實作了對於 *protocol* 的傳輸。" -#: ../../library/asyncio-eventloop.rst:945 +#: ../../library/asyncio-eventloop.rst:951 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1475,13 +1481,13 @@ msgstr "" "*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" "與 *transport* 間歇性地交換額外的 TLS session 封包。" -#: ../../library/asyncio-eventloop.rst:950 +#: ../../library/asyncio-eventloop.rst:956 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:955 +#: ../../library/asyncio-eventloop.rst:961 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." @@ -1489,11 +1495,11 @@ msgstr "" "*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" "`~loop.create_connection` 等方法回傳。" -#: ../../library/asyncio-eventloop.rst:959 +#: ../../library/asyncio-eventloop.rst:965 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" -#: ../../library/asyncio-eventloop.rst:961 +#: ../../library/asyncio-eventloop.rst:967 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." @@ -1501,17 +1507,17 @@ msgstr "" "當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " "``True``。" -#: ../../library/asyncio-eventloop.rst:964 +#: ../../library/asyncio-eventloop.rst:970 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設置或覆蓋將用於匹配目標伺服器憑證的主機名。" -#: ../../library/asyncio-eventloop.rst:984 +#: ../../library/asyncio-eventloop.rst:990 msgid "Watching file descriptors" msgstr "監視檔案描述器" -#: ../../library/asyncio-eventloop.rst:988 +#: ../../library/asyncio-eventloop.rst:994 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." @@ -1519,14 +1525,14 @@ msgstr "" "開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:992 -#: ../../library/asyncio-eventloop.rst:1006 +#: ../../library/asyncio-eventloop.rst:998 +#: ../../library/asyncio-eventloop.rst:1012 msgid "" "Any preexisting callback registered for *fd* is cancelled and replaced by " "*callback*." msgstr "任何預先存在、為 *fd* 註冊的回呼函式將被取消並替換為 *callback*。" -#: ../../library/asyncio-eventloop.rst:997 +#: ../../library/asyncio-eventloop.rst:1003 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." @@ -1534,7 +1540,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1002 +#: ../../library/asyncio-eventloop.rst:1008 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." @@ -1542,8 +1548,8 @@ msgstr "" "開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:1009 -#: ../../library/asyncio-eventloop.rst:1287 +#: ../../library/asyncio-eventloop.rst:1015 +#: ../../library/asyncio-eventloop.rst:1293 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." @@ -1551,7 +1557,7 @@ msgstr "" "使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" -#: ../../library/asyncio-eventloop.rst:1014 +#: ../../library/asyncio-eventloop.rst:1020 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." @@ -1559,7 +1565,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1017 +#: ../../library/asyncio-eventloop.rst:1023 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." @@ -1567,11 +1573,11 @@ msgstr "" "另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的" "一些限制。" -#: ../../library/asyncio-eventloop.rst:1022 +#: ../../library/asyncio-eventloop.rst:1028 msgid "Working with socket objects directly" msgstr "直接使用 socket 物件" -#: ../../library/asyncio-eventloop.rst:1024 +#: ../../library/asyncio-eventloop.rst:1030 msgid "" "In general, protocol implementations that use transport-based APIs such as :" "meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " @@ -1580,10 +1586,10 @@ msgid "" "socket` objects directly is more convenient." msgstr "" "一般情況下,使用基於傳輸的 API(如 :meth:`loop.create_connection` 和 :meth:" -"`loop.create_server`)的協定實作比直接使用 socket 的實作更快。然而在某些情" -"況下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" +"`loop.create_server`)的協定實作比直接使用 socket 的實作更快。然而在某些情況" +"下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" -#: ../../library/asyncio-eventloop.rst:1034 +#: ../../library/asyncio-eventloop.rst:1040 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." @@ -1591,23 +1597,23 @@ msgstr "" "從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" "同步版本。" -#: ../../library/asyncio-eventloop.rst:1037 +#: ../../library/asyncio-eventloop.rst:1043 msgid "Return the received data as a bytes object." msgstr "將接收到的資料作為 bytes 物件回傳。" -#: ../../library/asyncio-eventloop.rst:1039 -#: ../../library/asyncio-eventloop.rst:1054 -#: ../../library/asyncio-eventloop.rst:1066 -#: ../../library/asyncio-eventloop.rst:1079 -#: ../../library/asyncio-eventloop.rst:1095 -#: ../../library/asyncio-eventloop.rst:1111 -#: ../../library/asyncio-eventloop.rst:1122 -#: ../../library/asyncio-eventloop.rst:1149 -#: ../../library/asyncio-eventloop.rst:1188 +#: ../../library/asyncio-eventloop.rst:1045 +#: ../../library/asyncio-eventloop.rst:1060 +#: ../../library/asyncio-eventloop.rst:1072 +#: ../../library/asyncio-eventloop.rst:1085 +#: ../../library/asyncio-eventloop.rst:1101 +#: ../../library/asyncio-eventloop.rst:1117 +#: ../../library/asyncio-eventloop.rst:1128 +#: ../../library/asyncio-eventloop.rst:1155 +#: ../../library/asyncio-eventloop.rst:1194 msgid "*sock* must be a non-blocking socket." msgstr "*sock* 必須是非阻塞 socket。" -#: ../../library/asyncio-eventloop.rst:1041 +#: ../../library/asyncio-eventloop.rst:1047 msgid "" "Even though this method was always documented as a coroutine method, " "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " @@ -1616,7 +1622,7 @@ msgstr "" "儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" "自 Python 3.7 起,這是 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1049 +#: ../../library/asyncio-eventloop.rst:1055 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." @@ -1624,11 +1630,11 @@ msgstr "" "從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " "` 方法。" -#: ../../library/asyncio-eventloop.rst:1052 +#: ../../library/asyncio-eventloop.rst:1058 msgid "Return the number of bytes written to the buffer." msgstr "回傳寫入緩衝區位元組的數目。" -#: ../../library/asyncio-eventloop.rst:1061 +#: ../../library/asyncio-eventloop.rst:1067 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." @@ -1636,11 +1642,11 @@ msgstr "" "從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " "` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1064 +#: ../../library/asyncio-eventloop.rst:1070 msgid "Return a tuple of (received data, remote address)." msgstr "回傳一個元組 (received data, remote address)。" -#: ../../library/asyncio-eventloop.rst:1073 +#: ../../library/asyncio-eventloop.rst:1079 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." @@ -1648,11 +1654,11 @@ msgstr "" "從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." "recvfrom_into() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1077 +#: ../../library/asyncio-eventloop.rst:1083 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "回傳一個元組 (number of bytes received, remote address)。" -#: ../../library/asyncio-eventloop.rst:1086 +#: ../../library/asyncio-eventloop.rst:1092 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." @@ -1660,7 +1666,7 @@ msgstr "" "將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1089 +#: ../../library/asyncio-eventloop.rst:1095 msgid "" "This method continues to send to the socket until either all data in *data* " "has been sent or an error occurs. ``None`` is returned on success. On " @@ -1672,8 +1678,8 @@ msgstr "" "回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" "果有的話)。" -#: ../../library/asyncio-eventloop.rst:1097 -#: ../../library/asyncio-eventloop.rst:1151 +#: ../../library/asyncio-eventloop.rst:1103 +#: ../../library/asyncio-eventloop.rst:1157 msgid "" "Even though the method was always documented as a coroutine method, before " "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " @@ -1682,7 +1688,7 @@ msgstr "" "儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" "從 Python 3.7 開始,這是一個 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1105 +#: ../../library/asyncio-eventloop.rst:1111 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." @@ -1690,20 +1696,20 @@ msgstr "" "從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1109 +#: ../../library/asyncio-eventloop.rst:1115 msgid "Return the number of bytes sent." msgstr "回傳發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:1118 +#: ../../library/asyncio-eventloop.rst:1124 msgid "Connect *sock* to a remote socket at *address*." msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" -#: ../../library/asyncio-eventloop.rst:1120 +#: ../../library/asyncio-eventloop.rst:1126 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1124 +#: ../../library/asyncio-eventloop.rst:1130 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " "check if the *address* is already resolved by calling :func:`socket." @@ -1714,7 +1720,7 @@ msgstr "" "inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." "getaddrinfo` 解析 *address*。" -#: ../../library/asyncio-eventloop.rst:1133 +#: ../../library/asyncio-eventloop.rst:1139 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." @@ -1722,7 +1728,7 @@ msgstr "" ":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " "`。" -#: ../../library/asyncio-eventloop.rst:1140 +#: ../../library/asyncio-eventloop.rst:1146 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." @@ -1730,7 +1736,7 @@ msgstr "" "接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" "法。" -#: ../../library/asyncio-eventloop.rst:1143 +#: ../../library/asyncio-eventloop.rst:1149 msgid "" "The socket must be bound to an address and listening for connections. The " "return value is a pair ``(conn, address)`` where *conn* is a *new* socket " @@ -1741,34 +1747,34 @@ msgstr "" "中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連接" "另一端對應的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:1158 +#: ../../library/asyncio-eventloop.rst:1164 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" -#: ../../library/asyncio-eventloop.rst:1164 +#: ../../library/asyncio-eventloop.rst:1170 msgid "" "Send a file using high-performance :mod:`os.sendfile` if possible. Return " "the total number of bytes sent." msgstr "" "如果可行,使用高性能 :mod:`os.sendfile` 發送檔案。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:1167 +#: ../../library/asyncio-eventloop.rst:1173 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr ":meth:`socket.sendfile() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1169 +#: ../../library/asyncio-eventloop.rst:1175 msgid "" "*sock* must be a non-blocking :const:`socket.SOCK_STREAM` :class:`~socket." "socket`." msgstr "" "*sock* 必須是非阻塞的 :const:`socket.SOCK_STREAM` :class:`~socket.socket`。" -#: ../../library/asyncio-eventloop.rst:1172 +#: ../../library/asyncio-eventloop.rst:1178 msgid "*file* must be a regular file object open in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:1181 +#: ../../library/asyncio-eventloop.rst:1187 msgid "" "*fallback*, when set to ``True``, makes asyncio manually read and send the " "file when the platform does not support the sendfile syscall (e.g. Windows " @@ -1777,7 +1783,7 @@ msgstr "" "當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:1185 +#: ../../library/asyncio-eventloop.rst:1191 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." @@ -1785,19 +1791,19 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:1194 +#: ../../library/asyncio-eventloop.rst:1200 msgid "DNS" msgstr "DNS" -#: ../../library/asyncio-eventloop.rst:1200 +#: ../../library/asyncio-eventloop.rst:1206 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1205 +#: ../../library/asyncio-eventloop.rst:1211 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1208 +#: ../../library/asyncio-eventloop.rst:1214 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1807,7 +1813,7 @@ msgid "" "executor with a larger number of workers." msgstr "" -#: ../../library/asyncio-eventloop.rst:1215 +#: ../../library/asyncio-eventloop.rst:1221 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1818,19 +1824,19 @@ msgstr "" "它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" "協程。" -#: ../../library/asyncio-eventloop.rst:1223 +#: ../../library/asyncio-eventloop.rst:1229 msgid "Working with pipes" msgstr "使用管道" -#: ../../library/asyncio-eventloop.rst:1228 +#: ../../library/asyncio-eventloop.rst:1234 msgid "Register the read end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" -#: ../../library/asyncio-eventloop.rst:1233 +#: ../../library/asyncio-eventloop.rst:1239 msgid "*pipe* is a :term:`file-like object `." msgstr "*pipe* 是 :term:`類檔案物件 `。" -#: ../../library/asyncio-eventloop.rst:1235 +#: ../../library/asyncio-eventloop.rst:1241 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports the :class:" "`ReadTransport` interface and *protocol* is an object instantiated by the " @@ -1839,22 +1845,22 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1239 -#: ../../library/asyncio-eventloop.rst:1256 +#: ../../library/asyncio-eventloop.rst:1245 +#: ../../library/asyncio-eventloop.rst:1262 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" -#: ../../library/asyncio-eventloop.rst:1245 +#: ../../library/asyncio-eventloop.rst:1251 msgid "Register the write end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" -#: ../../library/asyncio-eventloop.rst:1250 +#: ../../library/asyncio-eventloop.rst:1256 msgid "*pipe* is :term:`file-like object `." msgstr "*pipe* 是 :term:`file-like object `。" -#: ../../library/asyncio-eventloop.rst:1252 +#: ../../library/asyncio-eventloop.rst:1258 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports :class:" "`WriteTransport` interface and *protocol* is an object instantiated by the " @@ -1863,7 +1869,7 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1261 +#: ../../library/asyncio-eventloop.rst:1267 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." @@ -1871,20 +1877,20 @@ msgstr "" ":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使用 :" "class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1266 +#: ../../library/asyncio-eventloop.rst:1272 msgid "" "The :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods." msgstr ":meth:`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` 方法。" -#: ../../library/asyncio-eventloop.rst:1271 +#: ../../library/asyncio-eventloop.rst:1277 msgid "Unix signals" msgstr "Unix 訊號" -#: ../../library/asyncio-eventloop.rst:1277 +#: ../../library/asyncio-eventloop.rst:1283 msgid "Set *callback* as the handler for the *signum* signal." msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1279 +#: ../../library/asyncio-eventloop.rst:1285 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " @@ -1895,7 +1901,7 @@ msgstr "" "用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" "件迴圈進行互動。" -#: ../../library/asyncio-eventloop.rst:1284 +#: ../../library/asyncio-eventloop.rst:1290 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." @@ -1903,16 +1909,16 @@ msgstr "" "如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" "出 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:1290 +#: ../../library/asyncio-eventloop.rst:1296 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中叫用。" -#: ../../library/asyncio-eventloop.rst:1295 +#: ../../library/asyncio-eventloop.rst:1301 msgid "Remove the handler for the *sig* signal." msgstr "移除 *sig* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1297 +#: ../../library/asyncio-eventloop.rst:1303 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." @@ -1920,19 +1926,19 @@ msgstr "" "如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " "``False``。" -#: ../../library/asyncio-eventloop.rst:1304 +#: ../../library/asyncio-eventloop.rst:1310 msgid "The :mod:`signal` module." msgstr ":mod:`signal` 模組。" -#: ../../library/asyncio-eventloop.rst:1308 +#: ../../library/asyncio-eventloop.rst:1314 msgid "Executing code in thread or process pools" msgstr "在執行緒池或行程池中執行程式碼" -#: ../../library/asyncio-eventloop.rst:1312 +#: ../../library/asyncio-eventloop.rst:1318 msgid "Arrange for *func* to be called in the specified executor." msgstr "安排在指定的執行器中呼叫 *func*。" -#: ../../library/asyncio-eventloop.rst:1314 +#: ../../library/asyncio-eventloop.rst:1320 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -1941,7 +1947,7 @@ msgid "" "and used by :func:`run_in_executor` if needed." msgstr "" -#: ../../library/asyncio-eventloop.rst:1322 +#: ../../library/asyncio-eventloop.rst:1328 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -1984,7 +1990,7 @@ msgid "" " asyncio.run(main())" msgstr "" -#: ../../library/asyncio-eventloop.rst:1362 +#: ../../library/asyncio-eventloop.rst:1368 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -1996,11 +2002,11 @@ msgstr "" "== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" -#: ../../library/asyncio-eventloop.rst:1367 +#: ../../library/asyncio-eventloop.rst:1373 msgid "This method returns a :class:`asyncio.Future` object." msgstr "此方法回傳 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:1369 +#: ../../library/asyncio-eventloop.rst:1375 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." @@ -2008,7 +2014,7 @@ msgstr "" "使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ 給 *func*。" -#: ../../library/asyncio-eventloop.rst:1372 +#: ../../library/asyncio-eventloop.rst:1378 msgid "" ":meth:`loop.run_in_executor` no longer configures the ``max_workers`` of the " "thread pool executor it creates, instead leaving it up to the thread pool " @@ -2019,7 +2025,7 @@ msgstr "" "``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." "ThreadPoolExecutor`)設定預設值。" -#: ../../library/asyncio-eventloop.rst:1381 +#: ../../library/asyncio-eventloop.rst:1387 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." @@ -2028,26 +2034,26 @@ msgstr "" "將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" "須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1385 +#: ../../library/asyncio-eventloop.rst:1391 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" "*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1391 +#: ../../library/asyncio-eventloop.rst:1397 msgid "Error Handling API" msgstr "錯誤處理 API" -#: ../../library/asyncio-eventloop.rst:1393 +#: ../../library/asyncio-eventloop.rst:1399 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "允許自定義事件迴圈中的例外處理方式。" -#: ../../library/asyncio-eventloop.rst:1397 +#: ../../library/asyncio-eventloop.rst:1403 msgid "Set *handler* as the new event loop exception handler." msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1399 +#: ../../library/asyncio-eventloop.rst:1405 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -2060,7 +2066,7 @@ msgstr "" "圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資訊,請" "參閱 :meth:`call_exception_handler` 文件)。" -#: ../../library/asyncio-eventloop.rst:1407 +#: ../../library/asyncio-eventloop.rst:1413 msgid "" "If the handler is called on behalf of a :class:`~asyncio.Task` or :class:" "`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " @@ -2069,7 +2075,7 @@ msgstr "" "如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" "將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" -#: ../../library/asyncio-eventloop.rst:1413 +#: ../../library/asyncio-eventloop.rst:1419 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." @@ -2077,18 +2083,18 @@ msgstr "" "處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1418 +#: ../../library/asyncio-eventloop.rst:1424 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" "回傳目前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:1425 +#: ../../library/asyncio-eventloop.rst:1431 msgid "Default exception handler." msgstr "預設例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1427 +#: ../../library/asyncio-eventloop.rst:1433 msgid "" "This is called when an exception occurs and no exception handler is set. " "This can be called by a custom exception handler that wants to defer to the " @@ -2097,17 +2103,17 @@ msgstr "" "當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" "以轉由預設處理程式處理。" -#: ../../library/asyncio-eventloop.rst:1431 +#: ../../library/asyncio-eventloop.rst:1437 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" -#: ../../library/asyncio-eventloop.rst:1436 +#: ../../library/asyncio-eventloop.rst:1442 msgid "Call the current event loop exception handler." msgstr "呼叫目前事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1438 +#: ../../library/asyncio-eventloop.rst:1444 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" @@ -2115,55 +2121,55 @@ msgstr "" "*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" "的鍵):" -#: ../../library/asyncio-eventloop.rst:1441 +#: ../../library/asyncio-eventloop.rst:1447 msgid "'message': Error message;" msgstr "'message':錯誤訊息;" -#: ../../library/asyncio-eventloop.rst:1442 +#: ../../library/asyncio-eventloop.rst:1448 msgid "'exception' (optional): Exception object;" msgstr "'exception'(可選):例外物件;" -#: ../../library/asyncio-eventloop.rst:1443 +#: ../../library/asyncio-eventloop.rst:1449 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future'(可選): :class:`asyncio.Future` 實例;" -#: ../../library/asyncio-eventloop.rst:1444 +#: ../../library/asyncio-eventloop.rst:1450 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "'task'(可選): :class:`asyncio.Task` 實例;" -#: ../../library/asyncio-eventloop.rst:1445 +#: ../../library/asyncio-eventloop.rst:1451 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" -#: ../../library/asyncio-eventloop.rst:1446 +#: ../../library/asyncio-eventloop.rst:1452 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" -#: ../../library/asyncio-eventloop.rst:1447 +#: ../../library/asyncio-eventloop.rst:1453 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "'transport'(可選): :ref:`Transport ` 實例;" -#: ../../library/asyncio-eventloop.rst:1448 +#: ../../library/asyncio-eventloop.rst:1454 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "'socket'(可選): :class:`socket.socket` 實例;" -#: ../../library/asyncio-eventloop.rst:1449 +#: ../../library/asyncio-eventloop.rst:1455 msgid "'source_traceback' (optional): Traceback of the source;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1450 +#: ../../library/asyncio-eventloop.rst:1456 msgid "'handle_traceback' (optional): Traceback of the handle;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1451 +#: ../../library/asyncio-eventloop.rst:1457 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "'asyncgen'(可選): 非同步產生器引發" -#: ../../library/asyncio-eventloop.rst:1452 +#: ../../library/asyncio-eventloop.rst:1458 msgid "the exception." msgstr "例外。" -#: ../../library/asyncio-eventloop.rst:1456 +#: ../../library/asyncio-eventloop.rst:1462 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." @@ -2171,15 +2177,15 @@ msgstr "" "此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" "`set_exception_handler` 方法。" -#: ../../library/asyncio-eventloop.rst:1461 +#: ../../library/asyncio-eventloop.rst:1467 msgid "Enabling debug mode" msgstr "啟用除錯模式" -#: ../../library/asyncio-eventloop.rst:1465 +#: ../../library/asyncio-eventloop.rst:1471 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" -#: ../../library/asyncio-eventloop.rst:1467 +#: ../../library/asyncio-eventloop.rst:1473 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." @@ -2187,17 +2193,17 @@ msgstr "" "如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " "``True``,否則為 ``False``。" -#: ../../library/asyncio-eventloop.rst:1473 +#: ../../library/asyncio-eventloop.rst:1479 msgid "Set the debug mode of the event loop." msgstr "設定事件迴圈的除錯模式。" -#: ../../library/asyncio-eventloop.rst:1477 +#: ../../library/asyncio-eventloop.rst:1483 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" -#: ../../library/asyncio-eventloop.rst:1482 +#: ../../library/asyncio-eventloop.rst:1488 msgid "" "This attribute can be used to set the minimum execution duration in seconds " "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " @@ -2206,19 +2212,19 @@ msgstr "" "此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" "後,\"慢\"回呼將被記錄。" -#: ../../library/asyncio-eventloop.rst:1486 +#: ../../library/asyncio-eventloop.rst:1492 msgid "Default value is 100 milliseconds." msgstr "預設值為 100 毫秒" -#: ../../library/asyncio-eventloop.rst:1490 +#: ../../library/asyncio-eventloop.rst:1496 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio 的除錯模式 `。" -#: ../../library/asyncio-eventloop.rst:1494 +#: ../../library/asyncio-eventloop.rst:1500 msgid "Running Subprocesses" msgstr "運行子行程" -#: ../../library/asyncio-eventloop.rst:1496 +#: ../../library/asyncio-eventloop.rst:1502 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " @@ -2228,7 +2234,7 @@ msgstr "" "func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." "create_subprocess_exec` 輔助功能而不是。" -#: ../../library/asyncio-eventloop.rst:1503 +#: ../../library/asyncio-eventloop.rst:1509 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" @@ -2238,26 +2244,26 @@ msgstr "" "`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " "`。" -#: ../../library/asyncio-eventloop.rst:1515 +#: ../../library/asyncio-eventloop.rst:1521 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" -#: ../../library/asyncio-eventloop.rst:1518 +#: ../../library/asyncio-eventloop.rst:1524 msgid "*args* must be a list of strings represented by:" msgstr "*args* 必須是由以下項表示的字串串列:" -#: ../../library/asyncio-eventloop.rst:1520 +#: ../../library/asyncio-eventloop.rst:1526 msgid ":class:`str`;" msgstr ":class:`str`;" -#: ../../library/asyncio-eventloop.rst:1521 +#: ../../library/asyncio-eventloop.rst:1527 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" -#: ../../library/asyncio-eventloop.rst:1524 +#: ../../library/asyncio-eventloop.rst:1530 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " @@ -2266,7 +2272,7 @@ msgstr "" "第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " "``argv``。" -#: ../../library/asyncio-eventloop.rst:1528 +#: ../../library/asyncio-eventloop.rst:1534 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=False`` and the list of strings passed as the first " @@ -2277,7 +2283,7 @@ msgstr "" "字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" "引數,*subprocess_exec* 接受多個字串引數。" -#: ../../library/asyncio-eventloop.rst:1534 +#: ../../library/asyncio-eventloop.rst:1540 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." @@ -2285,67 +2291,67 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" "呼叫物件。" -#: ../../library/asyncio-eventloop.rst:1537 +#: ../../library/asyncio-eventloop.rst:1543 msgid "Other parameters:" msgstr "其他參數:" -#: ../../library/asyncio-eventloop.rst:1539 +#: ../../library/asyncio-eventloop.rst:1545 msgid "*stdin* can be any of these:" msgstr "*stdin* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1541 -#: ../../library/asyncio-eventloop.rst:1552 -#: ../../library/asyncio-eventloop.rst:1562 +#: ../../library/asyncio-eventloop.rst:1547 +#: ../../library/asyncio-eventloop.rst:1558 +#: ../../library/asyncio-eventloop.rst:1568 msgid "a file-like object" msgstr "類檔案物件" -#: ../../library/asyncio-eventloop.rst:1542 +#: ../../library/asyncio-eventloop.rst:1548 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe` 建立的" -#: ../../library/asyncio-eventloop.rst:1543 -#: ../../library/asyncio-eventloop.rst:1553 -#: ../../library/asyncio-eventloop.rst:1563 +#: ../../library/asyncio-eventloop.rst:1549 +#: ../../library/asyncio-eventloop.rst:1559 +#: ../../library/asyncio-eventloop.rst:1569 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," -#: ../../library/asyncio-eventloop.rst:1545 -#: ../../library/asyncio-eventloop.rst:1555 -#: ../../library/asyncio-eventloop.rst:1565 +#: ../../library/asyncio-eventloop.rst:1551 +#: ../../library/asyncio-eventloop.rst:1561 +#: ../../library/asyncio-eventloop.rst:1571 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" -#: ../../library/asyncio-eventloop.rst:1547 -#: ../../library/asyncio-eventloop.rst:1557 -#: ../../library/asyncio-eventloop.rst:1567 +#: ../../library/asyncio-eventloop.rst:1553 +#: ../../library/asyncio-eventloop.rst:1563 +#: ../../library/asyncio-eventloop.rst:1573 msgid "" "the :const:`subprocess.DEVNULL` constant which indicates that the special :" "data:`os.devnull` file will be used" msgstr "" ":const:`subprocess.DEVNULL` 常數,表示將使用特殊的 :data:`os.devnull` 檔案" -#: ../../library/asyncio-eventloop.rst:1550 +#: ../../library/asyncio-eventloop.rst:1556 msgid "*stdout* can be any of these:" msgstr "*stdout* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1560 +#: ../../library/asyncio-eventloop.rst:1566 msgid "*stderr* can be any of these:" msgstr "*stderr* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1569 +#: ../../library/asyncio-eventloop.rst:1575 msgid "" "the :const:`subprocess.STDOUT` constant which will connect the standard " "error stream to the process' standard output stream" msgstr "" ":const:`subprocess.STDOUT` 常數,它將標準錯誤串流連線到行程的標準輸出串流" -#: ../../library/asyncio-eventloop.rst:1572 +#: ../../library/asyncio-eventloop.rst:1578 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " @@ -2355,7 +2361,7 @@ msgstr "" "*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" "外,這些不應該指定。" -#: ../../library/asyncio-eventloop.rst:1577 +#: ../../library/asyncio-eventloop.rst:1583 msgid "" "The ``asyncio`` subprocess API does not support decoding the streams as " "text. :func:`bytes.decode` can be used to convert the bytes returned from " @@ -2364,7 +2370,7 @@ msgstr "" "``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " "將從串流回傳的位元組轉換為文本。" -#: ../../library/asyncio-eventloop.rst:1581 +#: ../../library/asyncio-eventloop.rst:1587 msgid "" "If a file-like object passed as *stdin*, *stdout* or *stderr* represents a " "pipe, then the other side of this pipe should be registered with :meth:" @@ -2375,13 +2381,13 @@ msgstr "" "端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." "connect_read_pipe` 註冊到事件迴圈中。" -#: ../../library/asyncio-eventloop.rst:1586 +#: ../../library/asyncio-eventloop.rst:1592 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" -#: ../../library/asyncio-eventloop.rst:1589 +#: ../../library/asyncio-eventloop.rst:1595 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " @@ -2391,7 +2397,7 @@ msgstr "" "SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" "件。" -#: ../../library/asyncio-eventloop.rst:1598 +#: ../../library/asyncio-eventloop.rst:1604 msgid "" "Create a subprocess from *cmd*, which can be a :class:`str` or a :class:" "`bytes` string encoded to the :ref:`filesystem encoding ` 的 :class:`bytes` 字串。" -#: ../../library/asyncio-eventloop.rst:1603 +#: ../../library/asyncio-eventloop.rst:1609 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." @@ -2408,7 +2414,7 @@ msgstr "" "這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1606 +#: ../../library/asyncio-eventloop.rst:1612 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." @@ -2416,13 +2422,13 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" "件。" -#: ../../library/asyncio-eventloop.rst:1609 +#: ../../library/asyncio-eventloop.rst:1615 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" -#: ../../library/asyncio-eventloop.rst:1612 +#: ../../library/asyncio-eventloop.rst:1618 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " @@ -2432,7 +2438,7 @@ msgstr "" "`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" "的物件。" -#: ../../library/asyncio-eventloop.rst:1617 +#: ../../library/asyncio-eventloop.rst:1623 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -2445,11 +2451,11 @@ msgstr "" "wikipedia.org/wiki/Shell_injection#Shell_injection>`_\\ 風險。可以使用 :func:" "`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" -#: ../../library/asyncio-eventloop.rst:1626 +#: ../../library/asyncio-eventloop.rst:1632 msgid "Callback Handles" msgstr "回呼處理" -#: ../../library/asyncio-eventloop.rst:1630 +#: ../../library/asyncio-eventloop.rst:1636 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." @@ -2457,46 +2463,46 @@ msgstr "" "由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" "器。" -#: ../../library/asyncio-eventloop.rst:1635 +#: ../../library/asyncio-eventloop.rst:1641 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" -#: ../../library/asyncio-eventloop.rst:1642 +#: ../../library/asyncio-eventloop.rst:1648 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" -#: ../../library/asyncio-eventloop.rst:1647 +#: ../../library/asyncio-eventloop.rst:1653 msgid "Return ``True`` if the callback was cancelled." msgstr "如果回呼已被取消,回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1653 +#: ../../library/asyncio-eventloop.rst:1659 msgid "" "A callback wrapper object returned by :meth:`loop.call_later`, and :meth:" "`loop.call_at`." msgstr "由 :meth:`loop.call_later` 和 :meth:`loop.call_at` 回傳的回呼包裝器。" -#: ../../library/asyncio-eventloop.rst:1656 +#: ../../library/asyncio-eventloop.rst:1662 msgid "This class is a subclass of :class:`Handle`." msgstr "這個類別是 :class:`Handle` 的子類別。" -#: ../../library/asyncio-eventloop.rst:1660 +#: ../../library/asyncio-eventloop.rst:1666 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" -#: ../../library/asyncio-eventloop.rst:1662 +#: ../../library/asyncio-eventloop.rst:1668 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:1669 +#: ../../library/asyncio-eventloop.rst:1675 msgid "Server Objects" msgstr "Server 物件" -#: ../../library/asyncio-eventloop.rst:1671 +#: ../../library/asyncio-eventloop.rst:1677 msgid "" "Server objects are created by :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " @@ -2506,11 +2512,11 @@ msgstr "" "create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" "建立。" -#: ../../library/asyncio-eventloop.rst:1675 +#: ../../library/asyncio-eventloop.rst:1681 msgid "Do not instantiate the :class:`Server` class directly." msgstr "請勿直接實例化 :class:`Server` 類別。" -#: ../../library/asyncio-eventloop.rst:1679 +#: ../../library/asyncio-eventloop.rst:1685 msgid "" "*Server* objects are asynchronous context managers. When used in an ``async " "with`` statement, it's guaranteed that the Server object is closed and not " @@ -2519,7 +2525,7 @@ msgstr "" "*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" "完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" -#: ../../library/asyncio-eventloop.rst:1684 +#: ../../library/asyncio-eventloop.rst:1690 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2535,30 +2541,30 @@ msgstr "" "\n" "# 此時 srv 已關閉,不再接受新的連線。" -#: ../../library/asyncio-eventloop.rst:1692 +#: ../../library/asyncio-eventloop.rst:1698 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" -#: ../../library/asyncio-eventloop.rst:1695 +#: ../../library/asyncio-eventloop.rst:1701 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" "此類別在 Python 3.9.11、3.10.3 和 3.11 中以 ``asyncio.Server`` 的形式被公開。" -#: ../../library/asyncio-eventloop.rst:1700 +#: ../../library/asyncio-eventloop.rst:1706 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" -#: ../../library/asyncio-eventloop.rst:1703 +#: ../../library/asyncio-eventloop.rst:1709 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1706 +#: ../../library/asyncio-eventloop.rst:1712 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." @@ -2566,53 +2572,53 @@ msgstr "" "伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" "躍連線)。" -#: ../../library/asyncio-eventloop.rst:1712 +#: ../../library/asyncio-eventloop.rst:1718 msgid "Close all existing incoming client connections." msgstr "關閉所有現有的傳入用戶端連線。" -#: ../../library/asyncio-eventloop.rst:1714 +#: ../../library/asyncio-eventloop.rst:1720 msgid "" "Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1717 +#: ../../library/asyncio-eventloop.rst:1723 msgid "" ":meth:`close` should be called before :meth:`close_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1724 +#: ../../library/asyncio-eventloop.rst:1730 msgid "" "Close all existing incoming client connections immediately, without waiting " "for pending operations to complete." msgstr "立即關閉所有現有的傳入用戶端連線,而不等待待定操作完成。" -#: ../../library/asyncio-eventloop.rst:1727 +#: ../../library/asyncio-eventloop.rst:1733 msgid "" "Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1730 +#: ../../library/asyncio-eventloop.rst:1736 msgid "" ":meth:`close` should be called before :meth:`abort_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1737 +#: ../../library/asyncio-eventloop.rst:1743 msgid "Return the event loop associated with the server object." msgstr "回傳與伺服器物件關聯的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1744 +#: ../../library/asyncio-eventloop.rst:1750 msgid "Start accepting connections." msgstr "開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1746 +#: ../../library/asyncio-eventloop.rst:1752 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" -#: ../../library/asyncio-eventloop.rst:1749 +#: ../../library/asyncio-eventloop.rst:1755 msgid "" "The *start_serving* keyword-only parameter to :meth:`loop.create_server` " "and :meth:`asyncio.start_server` allows creating a Server object that is not " @@ -2625,14 +2631,14 @@ msgstr "" "種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." "serve_forever` 來使 Server 開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1761 +#: ../../library/asyncio-eventloop.rst:1767 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" "開始接受連線,直到協程被取消。取消 ``serve_forever`` 任務會導致伺服器關閉。" -#: ../../library/asyncio-eventloop.rst:1765 +#: ../../library/asyncio-eventloop.rst:1771 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." @@ -2640,7 +2646,7 @@ msgstr "" "如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " "``serve_forever`` 任務。" -#: ../../library/asyncio-eventloop.rst:1771 +#: ../../library/asyncio-eventloop.rst:1777 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2666,24 +2672,24 @@ msgstr "" "\n" "asyncio.run(main('127.0.0.1', 0))" -#: ../../library/asyncio-eventloop.rst:1787 +#: ../../library/asyncio-eventloop.rst:1793 msgid "Return ``True`` if the server is accepting new connections." msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1794 +#: ../../library/asyncio-eventloop.rst:1800 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" -#: ../../library/asyncio-eventloop.rst:1799 +#: ../../library/asyncio-eventloop.rst:1805 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" "伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" -#: ../../library/asyncio-eventloop.rst:1802 +#: ../../library/asyncio-eventloop.rst:1808 msgid "" "Prior to Python 3.7 ``Server.sockets`` used to return an internal list of " "server sockets directly. In 3.7 a copy of that list is returned." @@ -2691,11 +2697,11 @@ msgstr "" "在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" "列。在 3.7 中回傳了該串列的副本。" -#: ../../library/asyncio-eventloop.rst:1812 +#: ../../library/asyncio-eventloop.rst:1818 msgid "Event Loop Implementations" msgstr "事件迴圈實作" -#: ../../library/asyncio-eventloop.rst:1814 +#: ../../library/asyncio-eventloop.rst:1820 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." @@ -2703,17 +2709,17 @@ msgstr "" "asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" "`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1817 +#: ../../library/asyncio-eventloop.rst:1823 msgid "By default asyncio is configured to use :class:`EventLoop`." msgstr "預設情況下,asyncio 被配置為要使用 :class:`EventLoop`。" -#: ../../library/asyncio-eventloop.rst:1822 +#: ../../library/asyncio-eventloop.rst:1828 msgid "" "A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " "module." msgstr "基於 :mod:`selectors` 模組的一個 :class:`AbstractEventLoop` 子類別。" -#: ../../library/asyncio-eventloop.rst:1825 +#: ../../library/asyncio-eventloop.rst:1831 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " @@ -2722,7 +2728,7 @@ msgstr "" "使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" "作: ::" -#: ../../library/asyncio-eventloop.rst:1829 +#: ../../library/asyncio-eventloop.rst:1835 msgid "" "import asyncio\n" "import selectors\n" @@ -2744,7 +2750,7 @@ msgstr "" "\n" "asyncio.set_event_loop_policy(MyPolicy())" -#: ../../library/asyncio-eventloop.rst:1845 +#: ../../library/asyncio-eventloop.rst:1851 msgid "" "A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " "Completion Ports\" (IOCP)." @@ -2752,7 +2758,7 @@ msgstr "" "用於 Windows 的 :class:`AbstractEventLoop` 子類別,使用「I/O 完成埠 (IOCP, I/" "O Completion Ports)」。" -#: ../../library/asyncio-eventloop.rst:1851 +#: ../../library/asyncio-eventloop.rst:1857 msgid "" "`MSDN documentation on I/O Completion Ports `_." @@ -2760,13 +2766,13 @@ msgstr "" "`I/O 完成埠的 MSDN 文件 `_。" -#: ../../library/asyncio-eventloop.rst:1856 +#: ../../library/asyncio-eventloop.rst:1862 msgid "" "An alias to the most efficient available subclass of :class:" "`AbstractEventLoop` for the given platform." msgstr "" -#: ../../library/asyncio-eventloop.rst:1859 +#: ../../library/asyncio-eventloop.rst:1865 msgid "" "It is an alias to :class:`SelectorEventLoop` on Unix and :class:" "`ProactorEventLoop` on Windows." @@ -2774,11 +2780,11 @@ msgstr "" "在 Unix 上是 :class:`SelectorEventLoop` 的別名,在 Windows 上是 :class:" "`ProactorEventLoop` 的別名。" -#: ../../library/asyncio-eventloop.rst:1865 +#: ../../library/asyncio-eventloop.rst:1871 msgid "Abstract base class for asyncio-compliant event loops." msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" -#: ../../library/asyncio-eventloop.rst:1867 +#: ../../library/asyncio-eventloop.rst:1873 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." @@ -2786,11 +2792,11 @@ msgstr "" ":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" "該定義的所有方法。" -#: ../../library/asyncio-eventloop.rst:1873 +#: ../../library/asyncio-eventloop.rst:1879 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-eventloop.rst:1875 +#: ../../library/asyncio-eventloop.rst:1881 msgid "" "Note that all examples in this section **purposefully** show how to use the " "low-level event loop APIs, such as :meth:`loop.run_forever` and :meth:`loop." @@ -2801,11 +2807,11 @@ msgstr "" "`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少需要這" "種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" -#: ../../library/asyncio-eventloop.rst:1885 +#: ../../library/asyncio-eventloop.rst:1891 msgid "Hello World with call_soon()" msgstr "使用 call_soon() 的 Hello World 範例" -#: ../../library/asyncio-eventloop.rst:1887 +#: ../../library/asyncio-eventloop.rst:1893 msgid "" "An example using the :meth:`loop.call_soon` method to schedule a callback. " "The callback displays ``\"Hello World\"`` and then stops the event loop::" @@ -2813,7 +2819,7 @@ msgstr "" "使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " "World\"``,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1891 +#: ../../library/asyncio-eventloop.rst:1897 msgid "" "import asyncio\n" "\n" @@ -2851,18 +2857,18 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1911 +#: ../../library/asyncio-eventloop.rst:1917 msgid "" "A similar :ref:`Hello World ` example created with a coroutine " "and the :func:`run` function." msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`Hello World ` 範例。" -#: ../../library/asyncio-eventloop.rst:1918 +#: ../../library/asyncio-eventloop.rst:1924 msgid "Display the current date with call_later()" msgstr "使用 call_later() 顯示目前日期" -#: ../../library/asyncio-eventloop.rst:1920 +#: ../../library/asyncio-eventloop.rst:1926 msgid "" "An example of a callback displaying the current date every second. The " "callback uses the :meth:`loop.call_later` method to reschedule itself after " @@ -2871,7 +2877,7 @@ msgstr "" "一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " "秒後重新排程自己,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1924 +#: ../../library/asyncio-eventloop.rst:1930 msgid "" "import asyncio\n" "import datetime\n" @@ -2917,7 +2923,7 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1948 +#: ../../library/asyncio-eventloop.rst:1954 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." @@ -2925,11 +2931,11 @@ msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`current date " "` 範例。" -#: ../../library/asyncio-eventloop.rst:1955 +#: ../../library/asyncio-eventloop.rst:1961 msgid "Watch a file descriptor for read events" msgstr "監聽檔案描述器以進行讀取事件" -#: ../../library/asyncio-eventloop.rst:1957 +#: ../../library/asyncio-eventloop.rst:1963 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" @@ -2937,7 +2943,7 @@ msgstr "" "使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" "圈: ::" -#: ../../library/asyncio-eventloop.rst:1960 +#: ../../library/asyncio-eventloop.rst:1966 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -3005,7 +3011,7 @@ msgstr "" " wsock.close()\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1995 +#: ../../library/asyncio-eventloop.rst:2001 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." @@ -3013,7 +3019,7 @@ msgstr "" "使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1999 +#: ../../library/asyncio-eventloop.rst:2005 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." @@ -3021,15 +3027,15 @@ msgstr "" "另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:2007 +#: ../../library/asyncio-eventloop.rst:2013 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" -#: ../../library/asyncio-eventloop.rst:2009 +#: ../../library/asyncio-eventloop.rst:2015 msgid "(This ``signals`` example only works on Unix.)" msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" -#: ../../library/asyncio-eventloop.rst:2011 +#: ../../library/asyncio-eventloop.rst:2017 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" @@ -3037,7 +3043,7 @@ msgstr "" "使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" "data:`SIGTERM` 的處理程式: ::" -#: ../../library/asyncio-eventloop.rst:2014 +#: ../../library/asyncio-eventloop.rst:2020 msgid "" "import asyncio\n" "import functools\n" diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 9c7cbb4de5..c1a61a818f 100644 --- a/library/multiprocessing.po +++ b/library/multiprocessing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-28 00:20+0000\n" +"POT-Creation-Date: 2025-07-28 17:30+0000\n" "PO-Revision-Date: 2018-05-23 16:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -206,11 +206,11 @@ msgid "" "start a process. These *start methods* are" msgstr "" -#: ../../library/multiprocessing.rst:114 +#: ../../library/multiprocessing.rst:116 msgid "*spawn*" msgstr "*spawn*" -#: ../../library/multiprocessing.rst:115 +#: ../../library/multiprocessing.rst:117 msgid "" "The parent process starts a fresh Python interpreter process. The child " "process will only inherit those resources necessary to run the process " @@ -220,16 +220,16 @@ msgid "" "or *forkserver*." msgstr "" -#: ../../library/multiprocessing.rst:122 +#: ../../library/multiprocessing.rst:124 msgid "" "Available on POSIX and Windows platforms. The default on Windows and macOS." msgstr "" -#: ../../library/multiprocessing.rst:124 +#: ../../library/multiprocessing.rst:128 msgid "*fork*" msgstr "*fork*" -#: ../../library/multiprocessing.rst:125 +#: ../../library/multiprocessing.rst:129 msgid "" "The parent process uses :func:`os.fork` to fork the Python interpreter. The " "child process, when it begins, is effectively identical to the parent " @@ -237,19 +237,19 @@ msgid "" "Note that safely forking a multithreaded process is problematic." msgstr "" -#: ../../library/multiprocessing.rst:131 +#: ../../library/multiprocessing.rst:135 msgid "" "Available on POSIX systems. Currently the default on POSIX except macOS." msgstr "" -#: ../../library/multiprocessing.rst:134 +#: ../../library/multiprocessing.rst:138 msgid "" "The default start method will change away from *fork* in Python 3.14. Code " "that requires *fork* should explicitly specify that via :func:`get_context` " "or :func:`set_start_method`." msgstr "" -#: ../../library/multiprocessing.rst:138 +#: ../../library/multiprocessing.rst:142 msgid "" "If Python is able to detect that your process has multiple threads, the :" "func:`os.fork` function that this start method calls internally will raise " @@ -257,11 +257,11 @@ msgid "" "fork` documentation for further explanation." msgstr "" -#: ../../library/multiprocessing.rst:144 +#: ../../library/multiprocessing.rst:150 msgid "*forkserver*" msgstr "*forkserver*" -#: ../../library/multiprocessing.rst:145 +#: ../../library/multiprocessing.rst:151 msgid "" "When the program starts and selects the *forkserver* start method, a server " "process is spawned. From then on, whenever a new process is needed, the " @@ -271,27 +271,27 @@ msgid "" "for it to use :func:`os.fork`. No unnecessary resources are inherited." msgstr "" -#: ../../library/multiprocessing.rst:153 +#: ../../library/multiprocessing.rst:159 msgid "" "Available on POSIX platforms which support passing file descriptors over " "Unix pipes such as Linux." msgstr "" -#: ../../library/multiprocessing.rst:157 +#: ../../library/multiprocessing.rst:163 msgid "" "*spawn* added on all POSIX platforms, and *forkserver* added for some POSIX " "platforms. Child processes no longer inherit all of the parents inheritable " "handles on Windows." msgstr "" -#: ../../library/multiprocessing.rst:165 +#: ../../library/multiprocessing.rst:171 msgid "" "On macOS, the *spawn* start method is now the default. The *fork* start " "method should be considered unsafe as it can lead to crashes of the " "subprocess as macOS system libraries may start threads. See :issue:`33725`." msgstr "" -#: ../../library/multiprocessing.rst:169 +#: ../../library/multiprocessing.rst:175 msgid "" "On POSIX using the *spawn* or *forkserver* start methods will also start a " "*resource tracker* process which tracks the unlinked named system resources " @@ -306,13 +306,13 @@ msgid "" "space in the main memory.)" msgstr "" -#: ../../library/multiprocessing.rst:182 +#: ../../library/multiprocessing.rst:188 msgid "" "To select a start method you use the :func:`set_start_method` in the ``if " "__name__ == '__main__'`` clause of the main module. For example::" msgstr "" -#: ../../library/multiprocessing.rst:186 +#: ../../library/multiprocessing.rst:192 msgid "" "import multiprocessing as mp\n" "\n" @@ -340,19 +340,19 @@ msgstr "" " print(q.get())\n" " p.join()" -#: ../../library/multiprocessing.rst:199 +#: ../../library/multiprocessing.rst:205 msgid "" ":func:`set_start_method` should not be used more than once in the program." msgstr "" -#: ../../library/multiprocessing.rst:202 +#: ../../library/multiprocessing.rst:208 msgid "" "Alternatively, you can use :func:`get_context` to obtain a context object. " "Context objects have the same API as the multiprocessing module, and allow " "one to use multiple start methods in the same program. ::" msgstr "" -#: ../../library/multiprocessing.rst:207 +#: ../../library/multiprocessing.rst:213 msgid "" "import multiprocessing as mp\n" "\n" @@ -380,7 +380,7 @@ msgstr "" " print(q.get())\n" " p.join()" -#: ../../library/multiprocessing.rst:220 +#: ../../library/multiprocessing.rst:226 msgid "" "Note that objects related to one context may not be compatible with " "processes for a different context. In particular, locks created using the " @@ -388,7 +388,7 @@ msgid "" "*forkserver* start methods." msgstr "" -#: ../../library/multiprocessing.rst:225 +#: ../../library/multiprocessing.rst:231 msgid "" "Libraries using :mod:`multiprocessing` or :class:`~concurrent.futures." "ProcessPoolExecutor` should be designed to allow their users to provide " @@ -398,7 +398,7 @@ msgid "" "start method." msgstr "" -#: ../../library/multiprocessing.rst:234 +#: ../../library/multiprocessing.rst:240 msgid "" "The ``'spawn'`` and ``'forkserver'`` start methods generally cannot be used " "with \"frozen\" executables (i.e., binaries produced by packages like " @@ -406,27 +406,27 @@ msgid "" "method may work if code does not use threads." msgstr "" -#: ../../library/multiprocessing.rst:241 +#: ../../library/multiprocessing.rst:247 msgid "Exchanging objects between processes" msgstr "" -#: ../../library/multiprocessing.rst:243 +#: ../../library/multiprocessing.rst:249 msgid "" ":mod:`multiprocessing` supports two types of communication channel between " "processes:" msgstr "" -#: ../../library/multiprocessing.rst:246 +#: ../../library/multiprocessing.rst:252 msgid "**Queues**" msgstr "" -#: ../../library/multiprocessing.rst:248 +#: ../../library/multiprocessing.rst:254 msgid "" "The :class:`Queue` class is a near clone of :class:`queue.Queue`. For " "example::" msgstr "" -#: ../../library/multiprocessing.rst:251 +#: ../../library/multiprocessing.rst:257 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -452,23 +452,23 @@ msgstr "" " print(q.get()) # 印出 \"[42, None, 'hello']\"\n" " p.join()" -#: ../../library/multiprocessing.rst:263 +#: ../../library/multiprocessing.rst:269 msgid "" "Queues are thread and process safe. Any object put into a :mod:" "`~multiprocessing` queue will be serialized." msgstr "" -#: ../../library/multiprocessing.rst:266 +#: ../../library/multiprocessing.rst:272 msgid "**Pipes**" msgstr "" -#: ../../library/multiprocessing.rst:268 +#: ../../library/multiprocessing.rst:274 msgid "" "The :func:`Pipe` function returns a pair of connection objects connected by " "a pipe which by default is duplex (two-way). For example::" msgstr "" -#: ../../library/multiprocessing.rst:271 +#: ../../library/multiprocessing.rst:277 msgid "" "from multiprocessing import Process, Pipe\n" "\n" @@ -496,7 +496,7 @@ msgstr "" " print(parent_conn.recv()) # 印出 \"[42, None, 'hello']\"\n" " p.join()" -#: ../../library/multiprocessing.rst:284 +#: ../../library/multiprocessing.rst:290 msgid "" "The two connection objects returned by :func:`Pipe` represent the two ends " "of the pipe. Each connection object has :meth:`~Connection.send` and :meth:" @@ -506,24 +506,24 @@ msgid "" "corruption from processes using different ends of the pipe at the same time." msgstr "" -#: ../../library/multiprocessing.rst:292 +#: ../../library/multiprocessing.rst:298 msgid "" "The :meth:`~Connection.send` method serializes the object and :meth:" "`~Connection.recv` re-creates the object." msgstr "" -#: ../../library/multiprocessing.rst:296 +#: ../../library/multiprocessing.rst:302 msgid "Synchronization between processes" msgstr "" -#: ../../library/multiprocessing.rst:298 +#: ../../library/multiprocessing.rst:304 msgid "" ":mod:`multiprocessing` contains equivalents of all the synchronization " "primitives from :mod:`threading`. For instance one can use a lock to ensure " "that only one process prints to standard output at a time::" msgstr "" -#: ../../library/multiprocessing.rst:302 +#: ../../library/multiprocessing.rst:308 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -555,40 +555,40 @@ msgstr "" " for num in range(10):\n" " Process(target=f, args=(lock, num)).start()" -#: ../../library/multiprocessing.rst:317 +#: ../../library/multiprocessing.rst:323 msgid "" "Without using the lock output from the different processes is liable to get " "all mixed up." msgstr "" -#: ../../library/multiprocessing.rst:322 +#: ../../library/multiprocessing.rst:328 msgid "Sharing state between processes" msgstr "" -#: ../../library/multiprocessing.rst:324 +#: ../../library/multiprocessing.rst:330 msgid "" "As mentioned above, when doing concurrent programming it is usually best to " "avoid using shared state as far as possible. This is particularly true when " "using multiple processes." msgstr "" -#: ../../library/multiprocessing.rst:328 +#: ../../library/multiprocessing.rst:334 msgid "" "However, if you really do need to use some shared data then :mod:" "`multiprocessing` provides a couple of ways of doing so." msgstr "" -#: ../../library/multiprocessing.rst:331 +#: ../../library/multiprocessing.rst:337 msgid "**Shared memory**" msgstr "" -#: ../../library/multiprocessing.rst:333 +#: ../../library/multiprocessing.rst:339 msgid "" "Data can be stored in a shared memory map using :class:`Value` or :class:" "`Array`. For example, the following code ::" msgstr "" -#: ../../library/multiprocessing.rst:336 +#: ../../library/multiprocessing.rst:342 msgid "" "from multiprocessing import Process, Value, Array\n" "\n" @@ -626,11 +626,11 @@ msgstr "" " print(num.value)\n" " print(arr[:])" -#: ../../library/multiprocessing.rst:354 ../../library/multiprocessing.rst:400 +#: ../../library/multiprocessing.rst:360 ../../library/multiprocessing.rst:406 msgid "will print ::" msgstr "" -#: ../../library/multiprocessing.rst:356 +#: ../../library/multiprocessing.rst:362 msgid "" "3.1415927\n" "[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]" @@ -638,7 +638,7 @@ msgstr "" "3.1415927\n" "[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]" -#: ../../library/multiprocessing.rst:359 +#: ../../library/multiprocessing.rst:365 msgid "" "The ``'d'`` and ``'i'`` arguments used when creating ``num`` and ``arr`` are " "typecodes of the kind used by the :mod:`array` module: ``'d'`` indicates a " @@ -646,25 +646,25 @@ msgid "" "objects will be process and thread-safe." msgstr "" -#: ../../library/multiprocessing.rst:364 +#: ../../library/multiprocessing.rst:370 msgid "" "For more flexibility in using shared memory one can use the :mod:" "`multiprocessing.sharedctypes` module which supports the creation of " "arbitrary ctypes objects allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:368 +#: ../../library/multiprocessing.rst:374 msgid "**Server process**" msgstr "" -#: ../../library/multiprocessing.rst:370 +#: ../../library/multiprocessing.rst:376 msgid "" "A manager object returned by :func:`Manager` controls a server process which " "holds Python objects and allows other processes to manipulate them using " "proxies." msgstr "" -#: ../../library/multiprocessing.rst:374 +#: ../../library/multiprocessing.rst:380 msgid "" "A manager returned by :func:`Manager` will support types :class:`list`, :" "class:`dict`, :class:`~managers.Namespace`, :class:`Lock`, :class:`RLock`, :" @@ -673,7 +673,7 @@ msgid "" "`Array`. For example, ::" msgstr "" -#: ../../library/multiprocessing.rst:380 +#: ../../library/multiprocessing.rst:386 msgid "" "from multiprocessing import Process, Manager\n" "\n" @@ -715,7 +715,7 @@ msgstr "" " print(d)\n" " print(l)" -#: ../../library/multiprocessing.rst:402 +#: ../../library/multiprocessing.rst:408 msgid "" "{0.25: None, 1: '1', '2': 2}\n" "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]" @@ -723,7 +723,7 @@ msgstr "" "{0.25: None, 1: '1', '2': 2}\n" "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]" -#: ../../library/multiprocessing.rst:405 +#: ../../library/multiprocessing.rst:411 msgid "" "Server process managers are more flexible than using shared memory objects " "because they can be made to support arbitrary object types. Also, a single " @@ -731,22 +731,22 @@ msgid "" "They are, however, slower than using shared memory." msgstr "" -#: ../../library/multiprocessing.rst:412 +#: ../../library/multiprocessing.rst:418 msgid "Using a pool of workers" msgstr "" -#: ../../library/multiprocessing.rst:414 +#: ../../library/multiprocessing.rst:420 msgid "" "The :class:`~multiprocessing.pool.Pool` class represents a pool of worker " "processes. It has methods which allows tasks to be offloaded to the worker " "processes in a few different ways." msgstr "" -#: ../../library/multiprocessing.rst:418 +#: ../../library/multiprocessing.rst:424 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/multiprocessing.rst:420 +#: ../../library/multiprocessing.rst:426 msgid "" "from multiprocessing import Pool, TimeoutError\n" "import time\n" @@ -795,13 +795,13 @@ msgid "" " print(\"Now the pool is closed and no longer available\")" msgstr "" -#: ../../library/multiprocessing.rst:462 +#: ../../library/multiprocessing.rst:468 msgid "" "Note that the methods of a pool should only ever be used by the process " "which created it." msgstr "" -#: ../../library/multiprocessing.rst:467 +#: ../../library/multiprocessing.rst:473 msgid "" "Functionality within this package requires that the ``__main__`` module be " "importable by the children. This is covered in :ref:`multiprocessing-" @@ -810,7 +810,7 @@ msgid "" "work in the interactive interpreter. For example::" msgstr "" -#: ../../library/multiprocessing.rst:473 +#: ../../library/multiprocessing.rst:479 msgid "" ">>> from multiprocessing import Pool\n" ">>> p = Pool(5)\n" @@ -852,35 +852,35 @@ msgstr "" "AttributeError: Can't get attribute 'f' on )>" -#: ../../library/multiprocessing.rst:490 +#: ../../library/multiprocessing.rst:496 msgid "" "(If you try this it will actually output three full tracebacks interleaved " "in a semi-random fashion, and then you may have to stop the parent process " "somehow.)" msgstr "" -#: ../../library/multiprocessing.rst:496 +#: ../../library/multiprocessing.rst:502 msgid "Reference" msgstr "" -#: ../../library/multiprocessing.rst:498 +#: ../../library/multiprocessing.rst:504 msgid "" "The :mod:`multiprocessing` package mostly replicates the API of the :mod:" "`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:503 +#: ../../library/multiprocessing.rst:509 msgid ":class:`Process` and exceptions" msgstr ":class:`Process` 與例外" -#: ../../library/multiprocessing.rst:508 +#: ../../library/multiprocessing.rst:514 msgid "" "Process objects represent activity that is run in a separate process. The :" "class:`Process` class has equivalents of all the methods of :class:" "`threading.Thread`." msgstr "" -#: ../../library/multiprocessing.rst:512 +#: ../../library/multiprocessing.rst:518 msgid "" "The constructor should always be called with keyword arguments. *group* " "should always be ``None``; it exists solely for compatibility with :class:" @@ -894,21 +894,21 @@ msgid "" "creating process." msgstr "" -#: ../../library/multiprocessing.rst:523 +#: ../../library/multiprocessing.rst:529 msgid "" "By default, no arguments are passed to *target*. The *args* argument, which " "defaults to ``()``, can be used to specify a list or tuple of the arguments " "to pass to *target*." msgstr "" -#: ../../library/multiprocessing.rst:527 +#: ../../library/multiprocessing.rst:533 msgid "" "If a subclass overrides the constructor, it must make sure it invokes the " "base class constructor (``super().__init__()``) before doing anything else " "to the process." msgstr "" -#: ../../library/multiprocessing.rst:533 +#: ../../library/multiprocessing.rst:539 msgid "" "In general, all arguments to :class:`Process` must be picklable. This is " "frequently observed when trying to create a :class:`Process` or use a :class:" @@ -916,7 +916,7 @@ msgid "" "*target* function." msgstr "" -#: ../../library/multiprocessing.rst:538 +#: ../../library/multiprocessing.rst:544 msgid "" "Passing a callable object defined in the current REPL session causes the " "child process to die via an uncaught :exc:`AttributeError` exception when " @@ -924,11 +924,11 @@ msgid "" "order to be loaded during unpickling." msgstr "" -#: ../../library/multiprocessing.rst:543 +#: ../../library/multiprocessing.rst:549 msgid "Example of this uncatchable error from the child::" msgstr "" -#: ../../library/multiprocessing.rst:545 +#: ../../library/multiprocessing.rst:551 msgid "" ">>> import multiprocessing as mp\n" ">>> def knigit():\n" @@ -958,7 +958,7 @@ msgstr "" "" -#: ../../library/multiprocessing.rst:558 +#: ../../library/multiprocessing.rst:564 msgid "" "See :ref:`multiprocessing-programming-spawn`. While this restriction is not " "true if using the ``\"fork\"`` start method, as of Python ``3.14`` that is " @@ -966,15 +966,15 @@ msgid "" "methods`. See also :gh:`132898`." msgstr "" -#: ../../library/multiprocessing.rst:564 +#: ../../library/multiprocessing.rst:570 msgid "Added the *daemon* parameter." msgstr "新增 *daemon* 參數。" -#: ../../library/multiprocessing.rst:569 +#: ../../library/multiprocessing.rst:575 msgid "Method representing the process's activity." msgstr "" -#: ../../library/multiprocessing.rst:571 +#: ../../library/multiprocessing.rst:577 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 target " @@ -982,17 +982,17 @@ msgid "" "*args* and *kwargs* arguments, respectively." msgstr "" -#: ../../library/multiprocessing.rst:576 +#: ../../library/multiprocessing.rst:582 msgid "" "Using a list or tuple as the *args* argument passed to :class:`Process` " "achieves the same effect." msgstr "" -#: ../../library/multiprocessing.rst:579 +#: ../../library/multiprocessing.rst:585 msgid "Example::" msgstr "範例: ::" -#: ../../library/multiprocessing.rst:581 +#: ../../library/multiprocessing.rst:587 msgid "" ">>> from multiprocessing import Process\n" ">>> p = Process(target=print, args=[1])\n" @@ -1010,17 +1010,17 @@ msgstr "" ">>> p.run()\n" "1" -#: ../../library/multiprocessing.rst:591 +#: ../../library/multiprocessing.rst:597 msgid "Start the process's activity." msgstr "" -#: ../../library/multiprocessing.rst:593 +#: ../../library/multiprocessing.rst:599 msgid "" "This must be called at most once per process object. It arranges for the " "object's :meth:`run` method to be invoked in a separate process." msgstr "" -#: ../../library/multiprocessing.rst:598 +#: ../../library/multiprocessing.rst:604 msgid "" "If the optional argument *timeout* is ``None`` (the default), the method " "blocks until the process whose :meth:`join` method is called terminates. If " @@ -1030,23 +1030,23 @@ msgid "" "terminated." msgstr "" -#: ../../library/multiprocessing.rst:605 +#: ../../library/multiprocessing.rst:611 msgid "A process can be joined many times." msgstr "" -#: ../../library/multiprocessing.rst:607 +#: ../../library/multiprocessing.rst:613 msgid "" "A process cannot join itself because this would cause a deadlock. It is an " "error to attempt to join a process before it has been started." msgstr "" -#: ../../library/multiprocessing.rst:612 +#: ../../library/multiprocessing.rst:618 msgid "" "The process's name. The name is a string used for identification purposes " "only. It has no semantics. Multiple processes may be given the same name." msgstr "" -#: ../../library/multiprocessing.rst:616 +#: ../../library/multiprocessing.rst:622 msgid "" "The initial name is set by the constructor. If no explicit name is provided " "to the constructor, a name of the form 'Process-N\\ :sub:`1`:N\\ :sub:" @@ -1054,33 +1054,33 @@ msgid "" "child of its parent." msgstr "" -#: ../../library/multiprocessing.rst:623 +#: ../../library/multiprocessing.rst:629 msgid "Return whether the process is alive." msgstr "" -#: ../../library/multiprocessing.rst:625 +#: ../../library/multiprocessing.rst:631 msgid "" "Roughly, a process object is alive from the moment the :meth:`start` method " "returns until the child process terminates." msgstr "" -#: ../../library/multiprocessing.rst:630 +#: ../../library/multiprocessing.rst:636 msgid "" "The process's daemon flag, a Boolean value. This must be set before :meth:" "`start` is called." msgstr "" -#: ../../library/multiprocessing.rst:633 +#: ../../library/multiprocessing.rst:639 msgid "The initial value is inherited from the creating process." msgstr "" -#: ../../library/multiprocessing.rst:635 +#: ../../library/multiprocessing.rst:641 msgid "" "When a process exits, it attempts to terminate all of its daemonic child " "processes." msgstr "" -#: ../../library/multiprocessing.rst:638 +#: ../../library/multiprocessing.rst:644 msgid "" "Note that a daemonic process is not allowed to create child processes. " "Otherwise a daemonic process would leave its children orphaned if it gets " @@ -1089,92 +1089,92 @@ msgid "" "(and not joined) if non-daemonic processes have exited." msgstr "" -#: ../../library/multiprocessing.rst:644 +#: ../../library/multiprocessing.rst:650 msgid "" "In addition to the :class:`threading.Thread` API, :class:`Process` objects " "also support the following attributes and methods:" msgstr "" -#: ../../library/multiprocessing.rst:649 +#: ../../library/multiprocessing.rst:655 msgid "" "Return the process ID. Before the process is spawned, this will be ``None``." msgstr "" -#: ../../library/multiprocessing.rst:654 +#: ../../library/multiprocessing.rst:660 msgid "" "The child's exit code. This will be ``None`` if the process has not yet " "terminated." msgstr "" -#: ../../library/multiprocessing.rst:657 +#: ../../library/multiprocessing.rst:663 msgid "" "If the child's :meth:`run` method returned normally, the exit code will be " "0. If it terminated via :func:`sys.exit` with an integer argument *N*, the " "exit code will be *N*." msgstr "" -#: ../../library/multiprocessing.rst:661 +#: ../../library/multiprocessing.rst:667 msgid "" "If the child terminated due to an exception not caught within :meth:`run`, " "the exit code will be 1. If it was terminated by signal *N*, the exit code " "will be the negative value *-N*." msgstr "" -#: ../../library/multiprocessing.rst:667 +#: ../../library/multiprocessing.rst:673 msgid "The process's authentication key (a byte string)." msgstr "" -#: ../../library/multiprocessing.rst:669 +#: ../../library/multiprocessing.rst:675 msgid "" "When :mod:`multiprocessing` is initialized the main process is assigned a " "random string using :func:`os.urandom`." msgstr "" -#: ../../library/multiprocessing.rst:672 +#: ../../library/multiprocessing.rst:678 msgid "" "When a :class:`Process` object is created, it will inherit the " "authentication key of its parent process, although this may be changed by " "setting :attr:`authkey` to another byte string." msgstr "" -#: ../../library/multiprocessing.rst:676 +#: ../../library/multiprocessing.rst:682 msgid "See :ref:`multiprocessing-auth-keys`." msgstr "參閱 :ref:`multiprocessing-auth-keys`。" -#: ../../library/multiprocessing.rst:680 +#: ../../library/multiprocessing.rst:686 msgid "" "A numeric handle of a system object which will become \"ready\" when the " "process ends." msgstr "" -#: ../../library/multiprocessing.rst:683 +#: ../../library/multiprocessing.rst:689 msgid "" "You can use this value if you want to wait on several events at once using :" "func:`multiprocessing.connection.wait`. Otherwise calling :meth:`join` is " "simpler." msgstr "" -#: ../../library/multiprocessing.rst:687 +#: ../../library/multiprocessing.rst:693 msgid "" "On Windows, this is an OS handle usable with the ``WaitForSingleObject`` and " "``WaitForMultipleObjects`` family of API calls. On POSIX, this is a file " "descriptor usable with primitives from the :mod:`select` module." msgstr "" -#: ../../library/multiprocessing.rst:695 +#: ../../library/multiprocessing.rst:701 msgid "" "Terminate the process. On POSIX this is done using the :py:const:`~signal." "SIGTERM` signal; on Windows :c:func:`!TerminateProcess` is used. Note that " "exit handlers and finally clauses, etc., will not be executed." msgstr "" -#: ../../library/multiprocessing.rst:699 +#: ../../library/multiprocessing.rst:705 msgid "" "Note that descendant processes of the process will *not* be terminated -- " "they will simply become orphaned." msgstr "" -#: ../../library/multiprocessing.rst:704 +#: ../../library/multiprocessing.rst:710 msgid "" "If this method is used when the associated process is using a pipe or queue " "then the pipe or queue is liable to become corrupted and may become unusable " @@ -1183,11 +1183,11 @@ msgid "" "deadlock." msgstr "" -#: ../../library/multiprocessing.rst:712 +#: ../../library/multiprocessing.rst:718 msgid "Same as :meth:`terminate` but using the ``SIGKILL`` signal on POSIX." msgstr "" -#: ../../library/multiprocessing.rst:718 +#: ../../library/multiprocessing.rst:724 msgid "" "Close the :class:`Process` object, releasing all resources associated with " "it. :exc:`ValueError` is raised if the underlying process is still " @@ -1195,18 +1195,18 @@ msgid "" "attributes of the :class:`Process` object will raise :exc:`ValueError`." msgstr "" -#: ../../library/multiprocessing.rst:726 +#: ../../library/multiprocessing.rst:732 msgid "" "Note that the :meth:`start`, :meth:`join`, :meth:`is_alive`, :meth:" "`terminate` and :attr:`exitcode` methods should only be called by the " "process that created the process object." msgstr "" -#: ../../library/multiprocessing.rst:730 +#: ../../library/multiprocessing.rst:736 msgid "Example usage of some of the methods of :class:`Process`:" msgstr "" -#: ../../library/multiprocessing.rst:732 +#: ../../library/multiprocessing.rst:738 msgid "" ">>> import multiprocessing, time, signal\n" ">>> mp_context = multiprocessing.get_context('spawn')\n" @@ -1238,48 +1238,48 @@ msgstr "" ">>> p.exitcode == -signal.SIGTERM\n" "True" -#: ../../library/multiprocessing.rst:751 +#: ../../library/multiprocessing.rst:757 msgid "The base class of all :mod:`multiprocessing` exceptions." msgstr "" -#: ../../library/multiprocessing.rst:755 +#: ../../library/multiprocessing.rst:761 msgid "" "Exception raised by :meth:`Connection.recv_bytes_into` when the supplied " "buffer object is too small for the message read." msgstr "" -#: ../../library/multiprocessing.rst:758 +#: ../../library/multiprocessing.rst:764 msgid "" "If ``e`` is an instance of :exc:`BufferTooShort` then ``e.args[0]`` will " "give the message as a byte string." msgstr "" -#: ../../library/multiprocessing.rst:763 +#: ../../library/multiprocessing.rst:769 msgid "Raised when there is an authentication error." msgstr "" -#: ../../library/multiprocessing.rst:767 +#: ../../library/multiprocessing.rst:773 msgid "Raised by methods with a timeout when the timeout expires." msgstr "" -#: ../../library/multiprocessing.rst:770 +#: ../../library/multiprocessing.rst:776 msgid "Pipes and Queues" msgstr "" -#: ../../library/multiprocessing.rst:772 +#: ../../library/multiprocessing.rst:778 msgid "" "When using multiple processes, one generally uses message passing for " "communication between processes and avoids having to use any synchronization " "primitives like locks." msgstr "" -#: ../../library/multiprocessing.rst:776 +#: ../../library/multiprocessing.rst:782 msgid "" "For passing messages one can use :func:`Pipe` (for a connection between two " "processes) or a queue (which allows multiple producers and consumers)." msgstr "" -#: ../../library/multiprocessing.rst:779 +#: ../../library/multiprocessing.rst:785 msgid "" "The :class:`Queue`, :class:`SimpleQueue` and :class:`JoinableQueue` types " "are multi-producer, multi-consumer :abbr:`FIFO (first-in, first-out)` queues " @@ -1289,7 +1289,7 @@ msgid "" "Queue` class." msgstr "" -#: ../../library/multiprocessing.rst:786 +#: ../../library/multiprocessing.rst:792 msgid "" "If you use :class:`JoinableQueue` then you **must** call :meth:" "`JoinableQueue.task_done` for each task removed from the queue or else the " @@ -1297,7 +1297,7 @@ msgid "" "overflow, raising an exception." msgstr "" -#: ../../library/multiprocessing.rst:791 +#: ../../library/multiprocessing.rst:797 msgid "" "One difference from other Python queue implementations, is that :mod:" "`multiprocessing` queues serializes all objects that are put into them " @@ -1305,20 +1305,20 @@ msgid "" "object that does not share memory with the original object." msgstr "" -#: ../../library/multiprocessing.rst:796 +#: ../../library/multiprocessing.rst:802 msgid "" "Note that one can also create a shared queue by using a manager object -- " "see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:801 +#: ../../library/multiprocessing.rst:807 msgid "" ":mod:`multiprocessing` uses the usual :exc:`queue.Empty` and :exc:`queue." "Full` exceptions to signal a timeout. They are not available in the :mod:" "`multiprocessing` namespace so you need to import them from :mod:`queue`." msgstr "" -#: ../../library/multiprocessing.rst:808 +#: ../../library/multiprocessing.rst:814 msgid "" "When an object is put on a queue, the object is pickled and a background " "thread later flushes the pickled data to an underlying pipe. This has some " @@ -1327,14 +1327,14 @@ msgid "" "a queue created with a :ref:`manager `." msgstr "" -#: ../../library/multiprocessing.rst:815 +#: ../../library/multiprocessing.rst:821 msgid "" "After putting an object on an empty queue there may be an infinitesimal " "delay before the queue's :meth:`~Queue.empty` method returns :const:`False` " "and :meth:`~Queue.get_nowait` can return without raising :exc:`queue.Empty`." msgstr "" -#: ../../library/multiprocessing.rst:820 +#: ../../library/multiprocessing.rst:826 msgid "" "If multiple processes are enqueuing objects, it is possible for the objects " "to be received at the other end out-of-order. However, objects enqueued by " @@ -1342,7 +1342,7 @@ msgid "" "other." msgstr "" -#: ../../library/multiprocessing.rst:827 +#: ../../library/multiprocessing.rst:833 msgid "" "If a process is killed using :meth:`Process.terminate` or :func:`os.kill` " "while it is trying to use a :class:`Queue`, then the data in the queue is " @@ -1350,7 +1350,7 @@ msgid "" "exception when it tries to use the queue later on." msgstr "" -#: ../../library/multiprocessing.rst:834 +#: ../../library/multiprocessing.rst:840 msgid "" "As mentioned above, if a child process has put items on a queue (and it has " "not used :meth:`JoinableQueue.cancel_join_thread ` flag or :envvar:`PYTHON_CPU_COUNT` as this is merely a wrapper around " "the :mod:`os` cpu count APIs." msgstr "" -#: ../../library/multiprocessing.rst:1075 +#: ../../library/multiprocessing.rst:1081 msgid "" "Return the :class:`Process` object corresponding to the current process." msgstr "" -#: ../../library/multiprocessing.rst:1077 +#: ../../library/multiprocessing.rst:1083 msgid "An analogue of :func:`threading.current_thread`." msgstr "" -#: ../../library/multiprocessing.rst:1081 +#: ../../library/multiprocessing.rst:1087 msgid "" "Return the :class:`Process` object corresponding to the parent process of " "the :func:`current_process`. For the main process, ``parent_process`` will " "be ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1089 +#: ../../library/multiprocessing.rst:1095 msgid "" "Add support for when a program which uses :mod:`multiprocessing` has been " "frozen to produce an executable. (Has been tested with **py2exe**, " "**PyInstaller** and **cx_Freeze**.)" msgstr "" -#: ../../library/multiprocessing.rst:1093 +#: ../../library/multiprocessing.rst:1099 msgid "" "One needs to call this function straight after the ``if __name__ == " "'__main__'`` line of the main module. For example::" msgstr "" -#: ../../library/multiprocessing.rst:1096 +#: ../../library/multiprocessing.rst:1102 msgid "" "from multiprocessing import Process, freeze_support\n" "\n" @@ -1710,13 +1710,13 @@ msgstr "" " freeze_support()\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:1105 +#: ../../library/multiprocessing.rst:1111 msgid "" "If the ``freeze_support()`` line is omitted then trying to run the frozen " "executable will raise :exc:`RuntimeError`." msgstr "" -#: ../../library/multiprocessing.rst:1108 +#: ../../library/multiprocessing.rst:1114 msgid "" "Calling ``freeze_support()`` has no effect when the start method is not " "*spawn*. In addition, if the module is being run normally by the Python " @@ -1724,7 +1724,7 @@ msgid "" "no effect." msgstr "" -#: ../../library/multiprocessing.rst:1115 +#: ../../library/multiprocessing.rst:1121 msgid "" "Returns a list of the supported start methods, the first of which is the " "default. The possible start methods are ``'fork'``, ``'spawn'`` and " @@ -1732,13 +1732,13 @@ msgid "" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1124 +#: ../../library/multiprocessing.rst:1130 msgid "" "Return a context object which has the same attributes as the :mod:" "`multiprocessing` module." msgstr "" -#: ../../library/multiprocessing.rst:1127 +#: ../../library/multiprocessing.rst:1133 msgid "" "If *method* is ``None`` then the default context is returned. Note that if " "the global start method has not been set, this will set it to the default " @@ -1747,11 +1747,11 @@ msgid "" "is not available. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1138 +#: ../../library/multiprocessing.rst:1144 msgid "Return the name of start method used for starting processes." msgstr "" -#: ../../library/multiprocessing.rst:1140 +#: ../../library/multiprocessing.rst:1146 msgid "" "If the global start method has not been set and *allow_none* is ``False``, " "then the start method is set to the default and the name is returned. If the " @@ -1759,43 +1759,43 @@ msgid "" "returned." msgstr "" -#: ../../library/multiprocessing.rst:1145 +#: ../../library/multiprocessing.rst:1151 msgid "" "The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'`` or " "``None``. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1152 +#: ../../library/multiprocessing.rst:1158 msgid "" "On macOS, the *spawn* start method is now the default. The *fork* start " "method should be considered unsafe as it can lead to crashes of the " "subprocess. See :issue:`33725`." msgstr "" -#: ../../library/multiprocessing.rst:1158 +#: ../../library/multiprocessing.rst:1164 msgid "" "Set the path of the Python interpreter to use when starting a child process. " "(By default :data:`sys.executable` is used). Embedders will probably need " "to do some thing like ::" msgstr "" -#: ../../library/multiprocessing.rst:1162 +#: ../../library/multiprocessing.rst:1168 msgid "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" msgstr "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" -#: ../../library/multiprocessing.rst:1164 +#: ../../library/multiprocessing.rst:1170 msgid "before they can create child processes." msgstr "" -#: ../../library/multiprocessing.rst:1166 +#: ../../library/multiprocessing.rst:1172 msgid "Now supported on POSIX when the ``'spawn'`` start method is used." msgstr "" -#: ../../library/multiprocessing.rst:1169 +#: ../../library/multiprocessing.rst:1175 msgid "Accepts a :term:`path-like object`." msgstr "接受一個\\ :term:`類路徑物件 `。" -#: ../../library/multiprocessing.rst:1174 +#: ../../library/multiprocessing.rst:1180 msgid "" "Set a list of module names for the forkserver main process to attempt to " "import so that their already imported state is inherited by forked " @@ -1804,19 +1804,19 @@ msgid "" "process." msgstr "" -#: ../../library/multiprocessing.rst:1180 +#: ../../library/multiprocessing.rst:1186 msgid "" "For this to work, it must be called before the forkserver process has been " "launched (before creating a :class:`Pool` or starting a :class:`Process`)." msgstr "" -#: ../../library/multiprocessing.rst:1183 +#: ../../library/multiprocessing.rst:1189 msgid "" "Only meaningful when using the ``'forkserver'`` start method. See :ref:" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1190 +#: ../../library/multiprocessing.rst:1196 msgid "" "Set the method which should be used to start child processes. The *method* " "argument can be ``'fork'``, ``'spawn'`` or ``'forkserver'``. Raises :exc:" @@ -1826,17 +1826,17 @@ msgid "" "then the context is set to the default context." msgstr "" -#: ../../library/multiprocessing.rst:1197 +#: ../../library/multiprocessing.rst:1203 msgid "" "Note that this should be called at most once, and it should be protected " "inside the ``if __name__ == '__main__'`` clause of the main module." msgstr "" -#: ../../library/multiprocessing.rst:1201 +#: ../../library/multiprocessing.rst:1207 msgid "See :ref:`multiprocessing-start-methods`." msgstr "參閱 :ref:`multiprocessing-start-methods`。" -#: ../../library/multiprocessing.rst:1207 +#: ../../library/multiprocessing.rst:1213 msgid "" ":mod:`multiprocessing` contains no analogues of :func:`threading." "active_count`, :func:`threading.enumerate`, :func:`threading.settrace`, :" @@ -1844,75 +1844,75 @@ msgid "" "local`." msgstr "" -#: ../../library/multiprocessing.rst:1214 +#: ../../library/multiprocessing.rst:1220 msgid "Connection Objects" msgstr "" -#: ../../library/multiprocessing.rst:1218 +#: ../../library/multiprocessing.rst:1224 msgid "" "Connection objects allow the sending and receiving of picklable objects or " "strings. They can be thought of as message oriented connected sockets." msgstr "" -#: ../../library/multiprocessing.rst:1221 +#: ../../library/multiprocessing.rst:1227 msgid "" "Connection objects are usually created using :func:`Pipe ` -- see also :ref:`multiprocessing-listeners-clients`." msgstr "" -#: ../../library/multiprocessing.rst:1229 +#: ../../library/multiprocessing.rst:1235 msgid "" "Send an object to the other end of the connection which should be read " "using :meth:`recv`." msgstr "" -#: ../../library/multiprocessing.rst:1232 +#: ../../library/multiprocessing.rst:1238 msgid "" "The object must be picklable. Very large pickles (approximately 32 MiB+, " "though it depends on the OS) may raise a :exc:`ValueError` exception." msgstr "" -#: ../../library/multiprocessing.rst:1237 +#: ../../library/multiprocessing.rst:1243 msgid "" "Return an object sent from the other end of the connection using :meth:" "`send`. Blocks until there is something to receive. Raises :exc:`EOFError` " "if there is nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1244 +#: ../../library/multiprocessing.rst:1250 msgid "Return the file descriptor or handle used by the connection." msgstr "" -#: ../../library/multiprocessing.rst:1248 +#: ../../library/multiprocessing.rst:1254 msgid "Close the connection." msgstr "" -#: ../../library/multiprocessing.rst:1250 +#: ../../library/multiprocessing.rst:1256 msgid "This is called automatically when the connection is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:1254 +#: ../../library/multiprocessing.rst:1260 msgid "Return whether there is any data available to be read." msgstr "" -#: ../../library/multiprocessing.rst:1256 +#: ../../library/multiprocessing.rst:1262 msgid "" "If *timeout* is not specified then it will return immediately. If *timeout* " "is a number then this specifies the maximum time in seconds to block. If " "*timeout* is ``None`` then an infinite timeout is used." msgstr "" -#: ../../library/multiprocessing.rst:1260 +#: ../../library/multiprocessing.rst:1266 msgid "" "Note that multiple connection objects may be polled at once by using :func:" "`multiprocessing.connection.wait`." msgstr "" -#: ../../library/multiprocessing.rst:1265 +#: ../../library/multiprocessing.rst:1271 msgid "Send byte data from a :term:`bytes-like object` as a complete message." msgstr "" -#: ../../library/multiprocessing.rst:1267 +#: ../../library/multiprocessing.rst:1273 msgid "" "If *offset* is given then data is read from that position in *buffer*. If " "*size* is given then that many bytes will be read from buffer. Very large " @@ -1920,7 +1920,7 @@ msgid "" "exc:`ValueError` exception" msgstr "" -#: ../../library/multiprocessing.rst:1274 +#: ../../library/multiprocessing.rst:1280 msgid "" "Return a complete message of byte data sent from the other end of the " "connection as a string. Blocks until there is something to receive. Raises :" @@ -1928,19 +1928,19 @@ msgid "" "closed." msgstr "" -#: ../../library/multiprocessing.rst:1279 +#: ../../library/multiprocessing.rst:1285 msgid "" "If *maxlength* is specified and the message is longer than *maxlength* then :" "exc:`OSError` is raised and the connection will no longer be readable." msgstr "" -#: ../../library/multiprocessing.rst:1283 +#: ../../library/multiprocessing.rst:1289 msgid "" "This function used to raise :exc:`IOError`, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/multiprocessing.rst:1290 +#: ../../library/multiprocessing.rst:1296 msgid "" "Read into *buffer* a complete message of byte data sent from the other end " "of the connection and return the number of bytes in the message. Blocks " @@ -1948,38 +1948,38 @@ msgid "" "nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1296 +#: ../../library/multiprocessing.rst:1302 msgid "" "*buffer* must be a writable :term:`bytes-like object`. If *offset* is given " "then the message will be written into the buffer from that position. Offset " "must be a non-negative integer less than the length of *buffer* (in bytes)." msgstr "" -#: ../../library/multiprocessing.rst:1301 +#: ../../library/multiprocessing.rst:1307 msgid "" "If the buffer is too short then a :exc:`BufferTooShort` exception is raised " "and the complete message is available as ``e.args[0]`` where ``e`` is the " "exception instance." msgstr "" -#: ../../library/multiprocessing.rst:1305 +#: ../../library/multiprocessing.rst:1311 msgid "" "Connection objects themselves can now be transferred between processes " "using :meth:`Connection.send` and :meth:`Connection.recv`." msgstr "" -#: ../../library/multiprocessing.rst:1309 +#: ../../library/multiprocessing.rst:1315 msgid "" "Connection objects also now support the context management protocol -- see :" "ref:`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "connection object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:1313 +#: ../../library/multiprocessing.rst:1319 msgid "For example:" msgstr "舉例來說:" -#: ../../library/multiprocessing.rst:1315 +#: ../../library/multiprocessing.rst:1321 msgid "" ">>> from multiprocessing import Pipe\n" ">>> a, b = Pipe()\n" @@ -2015,14 +2015,14 @@ msgstr "" ">>> arr2\n" "array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])" -#: ../../library/multiprocessing.rst:1338 +#: ../../library/multiprocessing.rst:1344 msgid "" "The :meth:`Connection.recv` method automatically unpickles the data it " "receives, which can be a security risk unless you can trust the process " "which sent the message." msgstr "" -#: ../../library/multiprocessing.rst:1342 +#: ../../library/multiprocessing.rst:1348 msgid "" "Therefore, unless the connection object was produced using :func:`Pipe` you " "should only use the :meth:`~Connection.recv` and :meth:`~Connection.send` " @@ -2030,73 +2030,73 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:1349 +#: ../../library/multiprocessing.rst:1355 msgid "" "If a process is killed while it is trying to read or write to a pipe then " "the data in the pipe is likely to become corrupted, because it may become " "impossible to be sure where the message boundaries lie." msgstr "" -#: ../../library/multiprocessing.rst:1355 +#: ../../library/multiprocessing.rst:1361 msgid "Synchronization primitives" msgstr "" -#: ../../library/multiprocessing.rst:1359 +#: ../../library/multiprocessing.rst:1365 msgid "" "Generally synchronization primitives are not as necessary in a multiprocess " "program as they are in a multithreaded program. See the documentation for :" "mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:1363 +#: ../../library/multiprocessing.rst:1369 msgid "" "Note that one can also create synchronization primitives by using a manager " "object -- see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:1368 +#: ../../library/multiprocessing.rst:1374 msgid "A barrier object: a clone of :class:`threading.Barrier`." msgstr "" -#: ../../library/multiprocessing.rst:1374 +#: ../../library/multiprocessing.rst:1380 msgid "" "A bounded semaphore object: a close analog of :class:`threading." "BoundedSemaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1377 -#: ../../library/multiprocessing.rst:1515 +#: ../../library/multiprocessing.rst:1383 +#: ../../library/multiprocessing.rst:1521 msgid "" "A solitary difference from its close analog exists: its ``acquire`` method's " "first argument is named *block*, as is consistent with :meth:`Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1381 +#: ../../library/multiprocessing.rst:1387 msgid "" "On macOS, this is indistinguishable from :class:`Semaphore` because " "``sem_getvalue()`` is not implemented on that platform." msgstr "" -#: ../../library/multiprocessing.rst:1386 +#: ../../library/multiprocessing.rst:1392 msgid "A condition variable: an alias for :class:`threading.Condition`." msgstr "" -#: ../../library/multiprocessing.rst:1388 +#: ../../library/multiprocessing.rst:1394 msgid "" "If *lock* is specified then it should be a :class:`Lock` or :class:`RLock` " "object from :mod:`multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:1391 -#: ../../library/multiprocessing.rst:1929 +#: ../../library/multiprocessing.rst:1397 +#: ../../library/multiprocessing.rst:1935 msgid "The :meth:`~threading.Condition.wait_for` method was added." msgstr "" -#: ../../library/multiprocessing.rst:1396 +#: ../../library/multiprocessing.rst:1402 msgid "A clone of :class:`threading.Event`." msgstr "" -#: ../../library/multiprocessing.rst:1401 +#: ../../library/multiprocessing.rst:1407 msgid "" "A non-recursive lock object: a close analog of :class:`threading.Lock`. Once " "a process or thread has acquired a lock, subsequent attempts to acquire it " @@ -2107,25 +2107,25 @@ msgid "" "as noted." msgstr "" -#: ../../library/multiprocessing.rst:1409 +#: ../../library/multiprocessing.rst:1415 msgid "" "Note that :class:`Lock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.Lock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1413 +#: ../../library/multiprocessing.rst:1419 msgid "" ":class:`Lock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1418 -#: ../../library/multiprocessing.rst:1469 +#: ../../library/multiprocessing.rst:1424 +#: ../../library/multiprocessing.rst:1475 msgid "Acquire a lock, blocking or non-blocking." msgstr "" -#: ../../library/multiprocessing.rst:1420 +#: ../../library/multiprocessing.rst:1426 msgid "" "With the *block* argument set to ``True`` (the default), the method call " "will block until the lock is in an unlocked state, then set it to locked and " @@ -2133,14 +2133,14 @@ msgid "" "that in :meth:`threading.Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1425 +#: ../../library/multiprocessing.rst:1431 msgid "" "With the *block* argument set to ``False``, the method call does not block. " "If the lock is currently in a locked state, return ``False``; otherwise set " "the lock to a locked state and return ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1429 +#: ../../library/multiprocessing.rst:1435 msgid "" "When invoked with a positive, floating-point value for *timeout*, block for " "at most the number of seconds specified by *timeout* as long as the lock can " @@ -2154,19 +2154,19 @@ msgid "" "acquired or ``False`` if the timeout period has elapsed." msgstr "" -#: ../../library/multiprocessing.rst:1444 +#: ../../library/multiprocessing.rst:1450 msgid "" "Release a lock. This can be called from any process or thread, not only the " "process or thread which originally acquired the lock." msgstr "" -#: ../../library/multiprocessing.rst:1447 +#: ../../library/multiprocessing.rst:1453 msgid "" "Behavior is the same as in :meth:`threading.Lock.release` except that when " "invoked on an unlocked lock, a :exc:`ValueError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:1453 +#: ../../library/multiprocessing.rst:1459 msgid "" "A recursive lock object: a close analog of :class:`threading.RLock`. A " "recursive lock must be released by the process or thread that acquired it. " @@ -2175,20 +2175,20 @@ msgid "" "release it once for each time it has been acquired." msgstr "" -#: ../../library/multiprocessing.rst:1459 +#: ../../library/multiprocessing.rst:1465 msgid "" "Note that :class:`RLock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.RLock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1463 +#: ../../library/multiprocessing.rst:1469 msgid "" ":class:`RLock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1471 +#: ../../library/multiprocessing.rst:1477 msgid "" "When invoked with the *block* argument set to ``True``, block until the lock " "is in an unlocked state (not owned by any process or thread) unless the lock " @@ -2201,7 +2201,7 @@ msgid "" "itself." msgstr "" -#: ../../library/multiprocessing.rst:1481 +#: ../../library/multiprocessing.rst:1487 msgid "" "When invoked with the *block* argument set to ``False``, do not block. If " "the lock has already been acquired (and thus is owned) by another process or " @@ -2212,14 +2212,14 @@ msgid "" "a return value of ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1489 +#: ../../library/multiprocessing.rst:1495 msgid "" "Use and behaviors of the *timeout* argument are the same as in :meth:`Lock." "acquire`. Note that some of these behaviors of *timeout* differ from the " "implemented behaviors in :meth:`threading.RLock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1496 +#: ../../library/multiprocessing.rst:1502 msgid "" "Release a lock, decrementing the recursion level. If after the decrement " "the recursion level is zero, reset the lock to unlocked (not owned by any " @@ -2229,7 +2229,7 @@ msgid "" "locked and owned by the calling process or thread." msgstr "" -#: ../../library/multiprocessing.rst:1504 +#: ../../library/multiprocessing.rst:1510 msgid "" "Only call this method when the calling process or thread owns the lock. An :" "exc:`AssertionError` is raised if this method is called by a process or " @@ -2238,17 +2238,17 @@ msgid "" "from the implemented behavior in :meth:`threading.RLock.release`." msgstr "" -#: ../../library/multiprocessing.rst:1513 +#: ../../library/multiprocessing.rst:1519 msgid "A semaphore object: a close analog of :class:`threading.Semaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1520 +#: ../../library/multiprocessing.rst:1526 msgid "" "On macOS, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with a " "timeout will emulate that function's behavior using a sleeping loop." msgstr "" -#: ../../library/multiprocessing.rst:1525 +#: ../../library/multiprocessing.rst:1531 msgid "" "Some of this package's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the :mod:" @@ -2257,32 +2257,32 @@ msgid "" "additional information." msgstr "" -#: ../../library/multiprocessing.rst:1533 +#: ../../library/multiprocessing.rst:1539 msgid "Shared :mod:`ctypes` Objects" msgstr "共享的 :mod:`ctypes` 物件" -#: ../../library/multiprocessing.rst:1535 +#: ../../library/multiprocessing.rst:1541 msgid "" "It is possible to create shared objects using shared memory which can be " "inherited by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1540 +#: ../../library/multiprocessing.rst:1546 msgid "" "Return a :mod:`ctypes` object allocated from shared memory. By default the " "return value is actually a synchronized wrapper for the object. The object " "itself can be accessed via the *value* attribute of a :class:`Value`." msgstr "" -#: ../../library/multiprocessing.rst:1544 -#: ../../library/multiprocessing.rst:1631 +#: ../../library/multiprocessing.rst:1550 +#: ../../library/multiprocessing.rst:1637 msgid "" "*typecode_or_type* determines the type of the returned object: it is either " "a ctypes type or a one character typecode of the kind used by the :mod:" "`array` module. *\\*args* is passed on to the constructor for the type." msgstr "" -#: ../../library/multiprocessing.rst:1548 +#: ../../library/multiprocessing.rst:1554 msgid "" "If *lock* is ``True`` (the default) then a new recursive lock object is " "created to synchronize access to the value. If *lock* is a :class:`Lock` " @@ -2292,24 +2292,24 @@ msgid "" "\"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1555 +#: ../../library/multiprocessing.rst:1561 msgid "" "Operations like ``+=`` which involve a read and write are not atomic. So " "if, for instance, you want to atomically increment a shared value it is " "insufficient to just do ::" msgstr "" -#: ../../library/multiprocessing.rst:1559 +#: ../../library/multiprocessing.rst:1565 msgid "counter.value += 1" msgstr "counter.value += 1" -#: ../../library/multiprocessing.rst:1561 +#: ../../library/multiprocessing.rst:1567 msgid "" "Assuming the associated lock is recursive (which it is by default) you can " "instead do ::" msgstr "" -#: ../../library/multiprocessing.rst:1564 +#: ../../library/multiprocessing.rst:1570 msgid "" "with counter.get_lock():\n" " counter.value += 1" @@ -2317,19 +2317,19 @@ msgstr "" "with counter.get_lock():\n" " counter.value += 1" -#: ../../library/multiprocessing.rst:1567 -#: ../../library/multiprocessing.rst:1657 -#: ../../library/multiprocessing.rst:1672 +#: ../../library/multiprocessing.rst:1573 +#: ../../library/multiprocessing.rst:1663 +#: ../../library/multiprocessing.rst:1678 msgid "Note that *lock* is a keyword-only argument." msgstr "" -#: ../../library/multiprocessing.rst:1571 +#: ../../library/multiprocessing.rst:1577 msgid "" "Return a ctypes array allocated from shared memory. By default the return " "value is actually a synchronized wrapper for the array." msgstr "" -#: ../../library/multiprocessing.rst:1574 +#: ../../library/multiprocessing.rst:1580 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a ctypes type or a one character typecode of the kind " @@ -2339,7 +2339,7 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1581 +#: ../../library/multiprocessing.rst:1587 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`Lock` or :class:" @@ -2349,28 +2349,28 @@ msgid "" "safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1588 +#: ../../library/multiprocessing.rst:1594 msgid "Note that *lock* is a keyword only argument." msgstr "" -#: ../../library/multiprocessing.rst:1590 +#: ../../library/multiprocessing.rst:1596 msgid "" "Note that an array of :data:`ctypes.c_char` has *value* and *raw* attributes " "which allow one to use it to store and retrieve strings." msgstr "" -#: ../../library/multiprocessing.rst:1595 +#: ../../library/multiprocessing.rst:1601 msgid "The :mod:`multiprocessing.sharedctypes` module" msgstr ":mod:`multiprocessing.sharedctypes` 模組" -#: ../../library/multiprocessing.rst:1600 +#: ../../library/multiprocessing.rst:1606 msgid "" "The :mod:`multiprocessing.sharedctypes` module provides functions for " "allocating :mod:`ctypes` objects from shared memory which can be inherited " "by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1606 +#: ../../library/multiprocessing.rst:1612 msgid "" "Although it is possible to store a pointer in shared memory remember that " "this will refer to a location in the address space of a specific process. " @@ -2379,11 +2379,11 @@ msgid "" "may cause a crash." msgstr "" -#: ../../library/multiprocessing.rst:1614 +#: ../../library/multiprocessing.rst:1620 msgid "Return a ctypes array allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1616 +#: ../../library/multiprocessing.rst:1622 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a ctypes type or a one character typecode of the kind " @@ -2393,40 +2393,40 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1623 +#: ../../library/multiprocessing.rst:1629 msgid "" "Note that setting and getting an element is potentially non-atomic -- use :" "func:`Array` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1629 +#: ../../library/multiprocessing.rst:1635 msgid "Return a ctypes object allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1635 +#: ../../library/multiprocessing.rst:1641 msgid "" "Note that setting and getting the value is potentially non-atomic -- use :" "func:`Value` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1639 +#: ../../library/multiprocessing.rst:1645 msgid "" "Note that an array of :data:`ctypes.c_char` has ``value`` and ``raw`` " "attributes which allow one to use it to store and retrieve strings -- see " "documentation for :mod:`ctypes`." msgstr "" -#: ../../library/multiprocessing.rst:1645 +#: ../../library/multiprocessing.rst:1651 msgid "" "The same as :func:`RawArray` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "array." msgstr "" -#: ../../library/multiprocessing.rst:1649 -#: ../../library/multiprocessing.rst:1665 +#: ../../library/multiprocessing.rst:1655 +#: ../../library/multiprocessing.rst:1671 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`~multiprocessing." @@ -2436,113 +2436,113 @@ msgid "" "not necessarily be \"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1667 msgid "" "The same as :func:`RawValue` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "object." msgstr "" -#: ../../library/multiprocessing.rst:1676 +#: ../../library/multiprocessing.rst:1682 msgid "" "Return a ctypes object allocated from shared memory which is a copy of the " "ctypes object *obj*." msgstr "" -#: ../../library/multiprocessing.rst:1681 +#: ../../library/multiprocessing.rst:1687 msgid "" "Return a process-safe wrapper object for a ctypes object which uses *lock* " "to synchronize access. If *lock* is ``None`` (the default) then a :class:" "`multiprocessing.RLock` object is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:1685 +#: ../../library/multiprocessing.rst:1691 msgid "" "A synchronized wrapper will have two methods in addition to those of the " "object it wraps: :meth:`get_obj` returns the wrapped object and :meth:" "`get_lock` returns the lock object used for synchronization." msgstr "" -#: ../../library/multiprocessing.rst:1689 +#: ../../library/multiprocessing.rst:1695 msgid "" "Note that accessing the ctypes object through the wrapper can be a lot " "slower than accessing the raw ctypes object." msgstr "" -#: ../../library/multiprocessing.rst:1692 +#: ../../library/multiprocessing.rst:1698 msgid "Synchronized objects support the :term:`context manager` protocol." msgstr "" -#: ../../library/multiprocessing.rst:1696 +#: ../../library/multiprocessing.rst:1702 msgid "" "The table below compares the syntax for creating shared ctypes objects from " "shared memory with the normal ctypes syntax. (In the table ``MyStruct`` is " "some subclass of :class:`ctypes.Structure`.)" msgstr "" -#: ../../library/multiprocessing.rst:1701 +#: ../../library/multiprocessing.rst:1707 msgid "ctypes" msgstr "ctypes" -#: ../../library/multiprocessing.rst:1701 +#: ../../library/multiprocessing.rst:1707 msgid "sharedctypes using type" msgstr "" -#: ../../library/multiprocessing.rst:1701 +#: ../../library/multiprocessing.rst:1707 msgid "sharedctypes using typecode" msgstr "" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1709 msgid "c_double(2.4)" msgstr "c_double(2.4)" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1709 msgid "RawValue(c_double, 2.4)" msgstr "RawValue(c_double, 2.4)" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1709 msgid "RawValue('d', 2.4)" msgstr "RawValue('d', 2.4)" -#: ../../library/multiprocessing.rst:1704 +#: ../../library/multiprocessing.rst:1710 msgid "MyStruct(4, 6)" msgstr "MyStruct(4, 6)" -#: ../../library/multiprocessing.rst:1704 +#: ../../library/multiprocessing.rst:1710 msgid "RawValue(MyStruct, 4, 6)" msgstr "RawValue(MyStruct, 4, 6)" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1711 msgid "(c_short * 7)()" msgstr "(c_short * 7)()" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1711 msgid "RawArray(c_short, 7)" msgstr "RawArray(c_short, 7)" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1711 msgid "RawArray('h', 7)" msgstr "RawArray('h', 7)" -#: ../../library/multiprocessing.rst:1706 +#: ../../library/multiprocessing.rst:1712 msgid "(c_int * 3)(9, 2, 8)" msgstr "(c_int * 3)(9, 2, 8)" -#: ../../library/multiprocessing.rst:1706 +#: ../../library/multiprocessing.rst:1712 msgid "RawArray(c_int, (9, 2, 8))" msgstr "RawArray(c_int, (9, 2, 8))" -#: ../../library/multiprocessing.rst:1706 +#: ../../library/multiprocessing.rst:1712 msgid "RawArray('i', (9, 2, 8))" msgstr "RawArray('i', (9, 2, 8))" -#: ../../library/multiprocessing.rst:1710 +#: ../../library/multiprocessing.rst:1716 msgid "" "Below is an example where a number of ctypes objects are modified by a child " "process::" msgstr "" -#: ../../library/multiprocessing.rst:1713 +#: ../../library/multiprocessing.rst:1719 msgid "" "from multiprocessing import Process, Lock\n" "from multiprocessing.sharedctypes import Value, Array\n" @@ -2608,11 +2608,11 @@ msgstr "" " print(s.value)\n" " print([(a.x, a.y) for a in A])" -#: ../../library/multiprocessing.rst:1748 +#: ../../library/multiprocessing.rst:1754 msgid "The results printed are ::" msgstr "" -#: ../../library/multiprocessing.rst:1750 +#: ../../library/multiprocessing.rst:1756 msgid "" "49\n" "0.1111111111111111\n" @@ -2624,11 +2624,11 @@ msgstr "" "HELLO WORLD\n" "[(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)]" -#: ../../library/multiprocessing.rst:1761 +#: ../../library/multiprocessing.rst:1767 msgid "Managers" msgstr "" -#: ../../library/multiprocessing.rst:1763 +#: ../../library/multiprocessing.rst:1769 msgid "" "Managers provide a way to create data which can be shared between different " "processes, including sharing over a network between processes running on " @@ -2637,7 +2637,7 @@ msgid "" "proxies." msgstr "" -#: ../../library/multiprocessing.rst:1772 +#: ../../library/multiprocessing.rst:1778 msgid "" "Returns a started :class:`~multiprocessing.managers.SyncManager` object " "which can be used for sharing objects between processes. The returned " @@ -2645,31 +2645,31 @@ msgid "" "will create shared objects and return corresponding proxies." msgstr "" -#: ../../library/multiprocessing.rst:1780 +#: ../../library/multiprocessing.rst:1786 msgid "" "Manager processes will be shutdown as soon as they are garbage collected or " "their parent process exits. The manager classes are defined in the :mod:" "`multiprocessing.managers` module:" msgstr "" -#: ../../library/multiprocessing.rst:1786 +#: ../../library/multiprocessing.rst:1792 msgid "Create a BaseManager object." msgstr "建立一個 BaseManager 物件。" -#: ../../library/multiprocessing.rst:1788 +#: ../../library/multiprocessing.rst:1794 msgid "" "Once created one should call :meth:`start` or ``get_server()." "serve_forever()`` to ensure that the manager object refers to a started " "manager process." msgstr "" -#: ../../library/multiprocessing.rst:1791 +#: ../../library/multiprocessing.rst:1797 msgid "" "*address* is the address on which the manager process listens for new " "connections. If *address* is ``None`` then an arbitrary one is chosen." msgstr "" -#: ../../library/multiprocessing.rst:1794 +#: ../../library/multiprocessing.rst:1800 msgid "" "*authkey* is the authentication key which will be used to check the validity " "of incoming connections to the server process. If *authkey* is ``None`` " @@ -2677,19 +2677,19 @@ msgid "" "it must be a byte string." msgstr "" -#: ../../library/multiprocessing.rst:1799 +#: ../../library/multiprocessing.rst:1805 msgid "" "*serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or " "``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization)." msgstr "" -#: ../../library/multiprocessing.rst:1802 +#: ../../library/multiprocessing.rst:1808 msgid "" "*ctx* is a context object, or ``None`` (use the current context). See the :" "func:`get_context` function." msgstr "" -#: ../../library/multiprocessing.rst:1805 +#: ../../library/multiprocessing.rst:1811 msgid "" "*shutdown_timeout* is a timeout in seconds used to wait until the process " "used by the manager completes in the :meth:`shutdown` method. If the " @@ -2697,24 +2697,24 @@ msgid "" "also times out, the process is killed." msgstr "" -#: ../../library/multiprocessing.rst:1810 +#: ../../library/multiprocessing.rst:1816 msgid "Added the *shutdown_timeout* parameter." msgstr "新增 *shutdown_timeout* 參數。" -#: ../../library/multiprocessing.rst:1815 +#: ../../library/multiprocessing.rst:1821 msgid "" "Start a subprocess to start the manager. If *initializer* is not ``None`` " "then the subprocess will call ``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:1820 +#: ../../library/multiprocessing.rst:1826 msgid "" "Returns a :class:`Server` object which represents the actual server under " "the control of the Manager. The :class:`Server` object supports the :meth:" "`serve_forever` method::" msgstr "" -#: ../../library/multiprocessing.rst:1824 +#: ../../library/multiprocessing.rst:1830 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> manager = BaseManager(address=('', 50000), authkey=b'abc')\n" @@ -2726,15 +2726,15 @@ msgstr "" ">>> server = manager.get_server()\n" ">>> server.serve_forever()" -#: ../../library/multiprocessing.rst:1829 +#: ../../library/multiprocessing.rst:1835 msgid ":class:`Server` additionally has an :attr:`address` attribute." msgstr "" -#: ../../library/multiprocessing.rst:1833 +#: ../../library/multiprocessing.rst:1839 msgid "Connect a local manager object to a remote manager process::" msgstr "" -#: ../../library/multiprocessing.rst:1835 +#: ../../library/multiprocessing.rst:1841 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" @@ -2744,29 +2744,29 @@ msgstr "" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" ">>> m.connect()" -#: ../../library/multiprocessing.rst:1841 +#: ../../library/multiprocessing.rst:1847 msgid "" "Stop the process used by the manager. This is only available if :meth:" "`start` has been used to start the server process." msgstr "" -#: ../../library/multiprocessing.rst:1844 +#: ../../library/multiprocessing.rst:1850 msgid "This can be called multiple times." msgstr "" -#: ../../library/multiprocessing.rst:1848 +#: ../../library/multiprocessing.rst:1854 msgid "" "A classmethod which can be used for registering a type or callable with the " "manager class." msgstr "" -#: ../../library/multiprocessing.rst:1851 +#: ../../library/multiprocessing.rst:1857 msgid "" "*typeid* is a \"type identifier\" which is used to identify a particular " "type of shared object. This must be a string." msgstr "" -#: ../../library/multiprocessing.rst:1854 +#: ../../library/multiprocessing.rst:1860 msgid "" "*callable* is a callable used for creating objects for this type " "identifier. If a manager instance will be connected to the server using " @@ -2774,14 +2774,14 @@ msgid "" "then this can be left as ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1860 +#: ../../library/multiprocessing.rst:1866 msgid "" "*proxytype* is a subclass of :class:`BaseProxy` which is used to create " "proxies for shared objects with this *typeid*. If ``None`` then a proxy " "class is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:1864 +#: ../../library/multiprocessing.rst:1870 msgid "" "*exposed* is used to specify a sequence of method names which proxies for " "this typeid should be allowed to access using :meth:`BaseProxy." @@ -2792,7 +2792,7 @@ msgid "" "method and whose name does not begin with ``'_'``.)" msgstr "" -#: ../../library/multiprocessing.rst:1873 +#: ../../library/multiprocessing.rst:1879 msgid "" "*method_to_typeid* is a mapping used to specify the return type of those " "exposed methods which should return a proxy. It maps method names to typeid " @@ -2802,22 +2802,22 @@ msgid "" "returned by the method will be copied by value." msgstr "" -#: ../../library/multiprocessing.rst:1880 +#: ../../library/multiprocessing.rst:1886 msgid "" "*create_method* determines whether a method should be created with name " "*typeid* which can be used to tell the server process to create a new shared " "object and return a proxy for it. By default it is ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1884 +#: ../../library/multiprocessing.rst:1890 msgid ":class:`BaseManager` instances also have one read-only property:" msgstr "" -#: ../../library/multiprocessing.rst:1888 +#: ../../library/multiprocessing.rst:1894 msgid "The address used by the manager." msgstr "" -#: ../../library/multiprocessing.rst:1890 +#: ../../library/multiprocessing.rst:1896 msgid "" "Manager objects support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` starts the server " @@ -2825,121 +2825,121 @@ msgid "" "object. :meth:`~contextmanager.__exit__` calls :meth:`shutdown`." msgstr "" -#: ../../library/multiprocessing.rst:1896 +#: ../../library/multiprocessing.rst:1902 msgid "" "In previous versions :meth:`~contextmanager.__enter__` did not start the " "manager's server process if it was not already started." msgstr "" -#: ../../library/multiprocessing.rst:1901 +#: ../../library/multiprocessing.rst:1907 msgid "" "A subclass of :class:`BaseManager` which can be used for the synchronization " "of processes. Objects of this type are returned by :func:`multiprocessing." "Manager`." msgstr "" -#: ../../library/multiprocessing.rst:1905 +#: ../../library/multiprocessing.rst:1911 msgid "" "Its methods create and return :ref:`multiprocessing-proxy_objects` for a " "number of commonly used data types to be synchronized across processes. This " "notably includes shared lists and dictionaries." msgstr "" -#: ../../library/multiprocessing.rst:1911 +#: ../../library/multiprocessing.rst:1917 msgid "" "Create a shared :class:`threading.Barrier` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1918 +#: ../../library/multiprocessing.rst:1924 msgid "" "Create a shared :class:`threading.BoundedSemaphore` object and return a " "proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1923 +#: ../../library/multiprocessing.rst:1929 msgid "" "Create a shared :class:`threading.Condition` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1926 +#: ../../library/multiprocessing.rst:1932 msgid "" "If *lock* is supplied then it should be a proxy for a :class:`threading." "Lock` or :class:`threading.RLock` object." msgstr "" -#: ../../library/multiprocessing.rst:1934 +#: ../../library/multiprocessing.rst:1940 msgid "" "Create a shared :class:`threading.Event` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1938 +#: ../../library/multiprocessing.rst:1944 msgid "" "Create a shared :class:`threading.Lock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1942 +#: ../../library/multiprocessing.rst:1948 msgid "Create a shared :class:`Namespace` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1946 +#: ../../library/multiprocessing.rst:1952 msgid "Create a shared :class:`queue.Queue` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1950 +#: ../../library/multiprocessing.rst:1956 msgid "" "Create a shared :class:`threading.RLock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1954 +#: ../../library/multiprocessing.rst:1960 msgid "" "Create a shared :class:`threading.Semaphore` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1959 +#: ../../library/multiprocessing.rst:1965 msgid "Create an array and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1963 +#: ../../library/multiprocessing.rst:1969 msgid "" "Create an object with a writable ``value`` attribute and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:1970 +#: ../../library/multiprocessing.rst:1976 msgid "Create a shared :class:`dict` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1975 +#: ../../library/multiprocessing.rst:1981 msgid "Create a shared :class:`list` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:1977 +#: ../../library/multiprocessing.rst:1983 msgid "" "Shared objects are capable of being nested. For example, a shared container " "object such as a shared list can contain other shared objects which will all " "be managed and synchronized by the :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:1984 +#: ../../library/multiprocessing.rst:1990 msgid "A type that can register with :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:1986 +#: ../../library/multiprocessing.rst:1992 msgid "" "A namespace object has no public methods, but does have writable attributes. " "Its representation shows the values of its attributes." msgstr "" -#: ../../library/multiprocessing.rst:1989 +#: ../../library/multiprocessing.rst:1995 msgid "" "However, when using a proxy for a namespace object, an attribute beginning " "with ``'_'`` will be an attribute of the proxy and not an attribute of the " "referent:" msgstr "" -#: ../../library/multiprocessing.rst:1993 +#: ../../library/multiprocessing.rst:1999 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -2951,18 +2951,18 @@ msgid "" "Namespace(x=10, y='hello')" msgstr "" -#: ../../library/multiprocessing.rst:2006 +#: ../../library/multiprocessing.rst:2012 msgid "Customized managers" msgstr "" -#: ../../library/multiprocessing.rst:2008 +#: ../../library/multiprocessing.rst:2014 msgid "" "To create one's own manager, one creates a subclass of :class:`BaseManager` " "and uses the :meth:`~BaseManager.register` classmethod to register new types " "or callables with the manager class. For example::" msgstr "" -#: ../../library/multiprocessing.rst:2012 +#: ../../library/multiprocessing.rst:2018 msgid "" "from multiprocessing.managers import BaseManager\n" "\n" @@ -3002,23 +3002,23 @@ msgstr "" " print(maths.add(4, 3)) # 印出 7\n" " print(maths.mul(7, 8)) # 印出 56" -#: ../../library/multiprocessing.rst:2033 +#: ../../library/multiprocessing.rst:2039 msgid "Using a remote manager" msgstr "" -#: ../../library/multiprocessing.rst:2035 +#: ../../library/multiprocessing.rst:2041 msgid "" "It is possible to run a manager server on one machine and have clients use " "it from other machines (assuming that the firewalls involved allow it)." msgstr "" -#: ../../library/multiprocessing.rst:2038 +#: ../../library/multiprocessing.rst:2044 msgid "" "Running the following commands creates a server for a single shared queue " "which remote clients can access::" msgstr "" -#: ../../library/multiprocessing.rst:2041 +#: ../../library/multiprocessing.rst:2047 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> from queue import Queue\n" @@ -3038,11 +3038,11 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2050 +#: ../../library/multiprocessing.rst:2056 msgid "One client can access the server as follows::" msgstr "" -#: ../../library/multiprocessing.rst:2052 +#: ../../library/multiprocessing.rst:2058 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3062,11 +3062,11 @@ msgstr "" ">>> queue = m.get_queue()\n" ">>> queue.put('hello')" -#: ../../library/multiprocessing.rst:2060 +#: ../../library/multiprocessing.rst:2066 msgid "Another client can also use it::" msgstr "" -#: ../../library/multiprocessing.rst:2062 +#: ../../library/multiprocessing.rst:2068 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3088,13 +3088,13 @@ msgstr "" ">>> queue.get()\n" "'hello'" -#: ../../library/multiprocessing.rst:2071 +#: ../../library/multiprocessing.rst:2077 msgid "" "Local processes can also access that queue, using the code from above on the " "client to access it remotely::" msgstr "" -#: ../../library/multiprocessing.rst:2074 +#: ../../library/multiprocessing.rst:2080 msgid "" ">>> from multiprocessing import Process, Queue\n" ">>> from multiprocessing.managers import BaseManager\n" @@ -3134,18 +3134,18 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2096 +#: ../../library/multiprocessing.rst:2102 msgid "Proxy Objects" msgstr "" -#: ../../library/multiprocessing.rst:2098 +#: ../../library/multiprocessing.rst:2104 msgid "" "A proxy is an object which *refers* to a shared object which lives " "(presumably) in a different process. The shared object is said to be the " "*referent* of the proxy. Multiple proxy objects may have the same referent." msgstr "" -#: ../../library/multiprocessing.rst:2102 +#: ../../library/multiprocessing.rst:2108 msgid "" "A proxy object has methods which invoke corresponding methods of its " "referent (although not every method of the referent will necessarily be " @@ -3153,7 +3153,7 @@ msgid "" "its referent can:" msgstr "" -#: ../../library/multiprocessing.rst:2106 +#: ../../library/multiprocessing.rst:2112 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3179,14 +3179,14 @@ msgstr "" ">>> l[2:5]\n" "[4, 9, 16]" -#: ../../library/multiprocessing.rst:2120 +#: ../../library/multiprocessing.rst:2126 msgid "" "Notice that applying :func:`str` to a proxy will return the representation " "of the referent, whereas applying :func:`repr` will return the " "representation of the proxy." msgstr "" -#: ../../library/multiprocessing.rst:2124 +#: ../../library/multiprocessing.rst:2130 msgid "" "An important feature of proxy objects is that they are picklable so they can " "be passed between processes. As such, a referent can contain :ref:" @@ -3194,7 +3194,7 @@ msgid "" "lists, dicts, and other :ref:`multiprocessing-proxy_objects`:" msgstr "" -#: ../../library/multiprocessing.rst:2129 +#: ../../library/multiprocessing.rst:2135 msgid "" ">>> a = manager.list()\n" ">>> b = manager.list()\n" @@ -3206,11 +3206,11 @@ msgid "" "['hello'] ['hello']" msgstr "" -#: ../../library/multiprocessing.rst:2140 +#: ../../library/multiprocessing.rst:2146 msgid "Similarly, dict and list proxies may be nested inside one another::" msgstr "" -#: ../../library/multiprocessing.rst:2142 +#: ../../library/multiprocessing.rst:2148 msgid "" ">>> l_outer = manager.list([ manager.dict() for i in range(2) ])\n" ">>> d_first_inner = l_outer[0]\n" @@ -3234,7 +3234,7 @@ msgstr "" ">>> print(l_outer[1])\n" "{'c': 3, 'z': 26}" -#: ../../library/multiprocessing.rst:2153 +#: ../../library/multiprocessing.rst:2159 msgid "" "If standard (non-proxy) :class:`list` or :class:`dict` objects are contained " "in a referent, modifications to those mutable values will not be propagated " @@ -3245,7 +3245,7 @@ msgid "" "assign the modified value to the container proxy::" msgstr "" -#: ../../library/multiprocessing.rst:2161 +#: ../../library/multiprocessing.rst:2167 msgid "" "# create a list proxy and append a mutable object (a dictionary)\n" "lproxy = manager.list()\n" @@ -3259,20 +3259,20 @@ msgid "" "lproxy[0] = d" msgstr "" -#: ../../library/multiprocessing.rst:2172 +#: ../../library/multiprocessing.rst:2178 msgid "" "This approach is perhaps less convenient than employing nested :ref:" "`multiprocessing-proxy_objects` for most use cases but also demonstrates a " "level of control over the synchronization." msgstr "" -#: ../../library/multiprocessing.rst:2178 +#: ../../library/multiprocessing.rst:2184 msgid "" "The proxy types in :mod:`multiprocessing` do nothing to support comparisons " "by value. So, for instance, we have:" msgstr "" -#: ../../library/multiprocessing.rst:2181 +#: ../../library/multiprocessing.rst:2187 msgid "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" @@ -3280,48 +3280,48 @@ msgstr "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" -#: ../../library/multiprocessing.rst:2186 +#: ../../library/multiprocessing.rst:2192 msgid "" "One should just use a copy of the referent instead when making comparisons." msgstr "" -#: ../../library/multiprocessing.rst:2190 +#: ../../library/multiprocessing.rst:2196 msgid "Proxy objects are instances of subclasses of :class:`BaseProxy`." msgstr "" -#: ../../library/multiprocessing.rst:2194 +#: ../../library/multiprocessing.rst:2200 msgid "Call and return the result of a method of the proxy's referent." msgstr "" -#: ../../library/multiprocessing.rst:2196 +#: ../../library/multiprocessing.rst:2202 msgid "" "If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2198 +#: ../../library/multiprocessing.rst:2204 msgid "proxy._callmethod(methodname, args, kwds)" msgstr "proxy._callmethod(methodname, args, kwds)" -#: ../../library/multiprocessing.rst:2200 +#: ../../library/multiprocessing.rst:2206 msgid "will evaluate the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2202 +#: ../../library/multiprocessing.rst:2208 msgid "getattr(obj, methodname)(*args, **kwds)" msgstr "getattr(obj, methodname)(*args, **kwds)" -#: ../../library/multiprocessing.rst:2204 +#: ../../library/multiprocessing.rst:2210 msgid "in the manager's process." msgstr "" -#: ../../library/multiprocessing.rst:2206 +#: ../../library/multiprocessing.rst:2212 msgid "" "The returned value will be a copy of the result of the call or a proxy to a " "new shared object -- see documentation for the *method_to_typeid* argument " "of :meth:`BaseManager.register`." msgstr "" -#: ../../library/multiprocessing.rst:2210 +#: ../../library/multiprocessing.rst:2216 msgid "" "If an exception is raised by the call, then is re-raised by :meth:" "`_callmethod`. If some other exception is raised in the manager's process " @@ -3329,17 +3329,17 @@ msgid "" "meth:`_callmethod`." msgstr "" -#: ../../library/multiprocessing.rst:2215 +#: ../../library/multiprocessing.rst:2221 msgid "" "Note in particular that an exception will be raised if *methodname* has not " "been *exposed*." msgstr "" -#: ../../library/multiprocessing.rst:2218 +#: ../../library/multiprocessing.rst:2224 msgid "An example of the usage of :meth:`_callmethod`:" msgstr "" -#: ../../library/multiprocessing.rst:2220 +#: ../../library/multiprocessing.rst:2226 msgid "" ">>> l = manager.list(range(10))\n" ">>> l._callmethod('__len__')\n" @@ -3361,69 +3361,69 @@ msgstr "" "...\n" "IndexError: list index out of range" -#: ../../library/multiprocessing.rst:2234 +#: ../../library/multiprocessing.rst:2240 msgid "Return a copy of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2236 +#: ../../library/multiprocessing.rst:2242 msgid "If the referent is unpicklable then this will raise an exception." msgstr "" -#: ../../library/multiprocessing.rst:2240 +#: ../../library/multiprocessing.rst:2246 msgid "Return a representation of the proxy object." msgstr "" -#: ../../library/multiprocessing.rst:2244 +#: ../../library/multiprocessing.rst:2250 msgid "Return the representation of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2248 +#: ../../library/multiprocessing.rst:2254 msgid "Cleanup" msgstr "" -#: ../../library/multiprocessing.rst:2250 +#: ../../library/multiprocessing.rst:2256 msgid "" "A proxy object uses a weakref callback so that when it gets garbage " "collected it deregisters itself from the manager which owns its referent." msgstr "" -#: ../../library/multiprocessing.rst:2253 +#: ../../library/multiprocessing.rst:2259 msgid "" "A shared object gets deleted from the manager process when there are no " "longer any proxies referring to it." msgstr "" -#: ../../library/multiprocessing.rst:2258 +#: ../../library/multiprocessing.rst:2264 msgid "Process Pools" msgstr "" -#: ../../library/multiprocessing.rst:2263 +#: ../../library/multiprocessing.rst:2269 msgid "" "One can create a pool of processes which will carry out tasks submitted to " "it with the :class:`Pool` class." msgstr "" -#: ../../library/multiprocessing.rst:2268 +#: ../../library/multiprocessing.rst:2274 msgid "" "A process pool object which controls a pool of worker processes to which " "jobs can be submitted. It supports asynchronous results with timeouts and " "callbacks and has a parallel map implementation." msgstr "" -#: ../../library/multiprocessing.rst:2272 +#: ../../library/multiprocessing.rst:2278 msgid "" "*processes* is the number of worker processes to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2275 -#: ../../library/multiprocessing.rst:2839 +#: ../../library/multiprocessing.rst:2281 +#: ../../library/multiprocessing.rst:2845 msgid "" "If *initializer* is not ``None`` then each worker process will call " "``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:2278 +#: ../../library/multiprocessing.rst:2284 msgid "" "*maxtasksperchild* is the number of tasks a worker process can complete " "before it will exit and be replaced with a fresh worker process, to enable " @@ -3431,7 +3431,7 @@ msgid "" "which means worker processes will live as long as the pool." msgstr "" -#: ../../library/multiprocessing.rst:2283 +#: ../../library/multiprocessing.rst:2289 msgid "" "*context* can be used to specify the context used for starting the worker " "processes. Usually a pool is created using the function :func:" @@ -3439,13 +3439,13 @@ msgid "" "both cases *context* is set appropriately." msgstr "" -#: ../../library/multiprocessing.rst:2289 +#: ../../library/multiprocessing.rst:2295 msgid "" "Note that the methods of the pool object should only be called by the " "process which created the pool." msgstr "" -#: ../../library/multiprocessing.rst:2293 +#: ../../library/multiprocessing.rst:2299 msgid "" ":class:`multiprocessing.pool` objects have internal resources that need to " "be properly managed (like any other resource) by using the pool as a context " @@ -3453,28 +3453,28 @@ msgid "" "to do this can lead to the process hanging on finalization." msgstr "" -#: ../../library/multiprocessing.rst:2298 +#: ../../library/multiprocessing.rst:2304 msgid "" "Note that it is **not correct** to rely on the garbage collector to destroy " "the pool as CPython does not assure that the finalizer of the pool will be " "called (see :meth:`object.__del__` for more information)." msgstr "" -#: ../../library/multiprocessing.rst:2302 +#: ../../library/multiprocessing.rst:2308 msgid "Added the *maxtasksperchild* parameter." msgstr "新增 *maxtasksperchild* 參數。" -#: ../../library/multiprocessing.rst:2305 +#: ../../library/multiprocessing.rst:2311 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/multiprocessing.rst:2308 +#: ../../library/multiprocessing.rst:2314 msgid "" "*processes* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" -#: ../../library/multiprocessing.rst:2314 +#: ../../library/multiprocessing.rst:2320 msgid "" "Worker processes within a :class:`Pool` typically live for the complete " "duration of the Pool's work queue. A frequent pattern found in other systems " @@ -3485,7 +3485,7 @@ msgid "" "ability to the end user." msgstr "" -#: ../../library/multiprocessing.rst:2324 +#: ../../library/multiprocessing.rst:2330 msgid "" "Call *func* with arguments *args* and keyword arguments *kwds*. It blocks " "until the result is ready. Given this blocks, :meth:`apply_async` is better " @@ -3493,14 +3493,14 @@ msgid "" "executed in one of the workers of the pool." msgstr "" -#: ../../library/multiprocessing.rst:2331 +#: ../../library/multiprocessing.rst:2337 msgid "" "A variant of the :meth:`apply` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2334 -#: ../../library/multiprocessing.rst:2365 +#: ../../library/multiprocessing.rst:2340 +#: ../../library/multiprocessing.rst:2371 msgid "" "If *callback* is specified then it should be a callable which accepts a " "single argument. When the result becomes ready *callback* is applied to it, " @@ -3508,60 +3508,60 @@ msgid "" "applied instead." msgstr "" -#: ../../library/multiprocessing.rst:2339 -#: ../../library/multiprocessing.rst:2370 +#: ../../library/multiprocessing.rst:2345 +#: ../../library/multiprocessing.rst:2376 msgid "" "If *error_callback* is specified then it should be a callable which accepts " "a single argument. If the target function fails, then the *error_callback* " "is called with the exception instance." msgstr "" -#: ../../library/multiprocessing.rst:2343 -#: ../../library/multiprocessing.rst:2374 +#: ../../library/multiprocessing.rst:2349 +#: ../../library/multiprocessing.rst:2380 msgid "" "Callbacks should complete immediately since otherwise the thread which " "handles the results will get blocked." msgstr "" -#: ../../library/multiprocessing.rst:2348 +#: ../../library/multiprocessing.rst:2354 msgid "" "A parallel equivalent of the :func:`map` built-in function (it supports only " "one *iterable* argument though, for multiple iterables see :meth:`starmap`). " "It blocks until the result is ready." msgstr "" -#: ../../library/multiprocessing.rst:2352 +#: ../../library/multiprocessing.rst:2358 msgid "" "This method chops the iterable into a number of chunks which it submits to " "the process pool as separate tasks. The (approximate) size of these chunks " "can be specified by setting *chunksize* to a positive integer." msgstr "" -#: ../../library/multiprocessing.rst:2356 +#: ../../library/multiprocessing.rst:2362 msgid "" "Note that it may cause high memory usage for very long iterables. Consider " "using :meth:`imap` or :meth:`imap_unordered` with explicit *chunksize* " "option for better efficiency." msgstr "" -#: ../../library/multiprocessing.rst:2362 +#: ../../library/multiprocessing.rst:2368 msgid "" "A variant of the :meth:`.map` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2379 +#: ../../library/multiprocessing.rst:2385 msgid "A lazier version of :meth:`.map`." msgstr "" -#: ../../library/multiprocessing.rst:2381 +#: ../../library/multiprocessing.rst:2387 msgid "" "The *chunksize* argument is the same as the one used by the :meth:`.map` " "method. For very long iterables using a large value for *chunksize* can " "make the job complete **much** faster than using the default value of ``1``." msgstr "" -#: ../../library/multiprocessing.rst:2386 +#: ../../library/multiprocessing.rst:2392 msgid "" "Also if *chunksize* is ``1`` then the :meth:`!next` method of the iterator " "returned by the :meth:`imap` method has an optional *timeout* parameter: " @@ -3569,65 +3569,65 @@ msgid "" "result cannot be returned within *timeout* seconds." msgstr "" -#: ../../library/multiprocessing.rst:2393 +#: ../../library/multiprocessing.rst:2399 msgid "" "The same as :meth:`imap` except that the ordering of the results from the " "returned iterator should be considered arbitrary. (Only when there is only " "one worker process is the order guaranteed to be \"correct\".)" msgstr "" -#: ../../library/multiprocessing.rst:2399 +#: ../../library/multiprocessing.rst:2405 msgid "" "Like :meth:`~multiprocessing.pool.Pool.map` except that the elements of the " "*iterable* are expected to be iterables that are unpacked as arguments." msgstr "" -#: ../../library/multiprocessing.rst:2403 +#: ../../library/multiprocessing.rst:2409 msgid "" "Hence an *iterable* of ``[(1,2), (3, 4)]`` results in ``[func(1,2), " "func(3,4)]``." msgstr "" -#: ../../library/multiprocessing.rst:2410 +#: ../../library/multiprocessing.rst:2416 msgid "" "A combination of :meth:`starmap` and :meth:`map_async` that iterates over " "*iterable* of iterables and calls *func* with the iterables unpacked. " "Returns a result object." msgstr "" -#: ../../library/multiprocessing.rst:2418 +#: ../../library/multiprocessing.rst:2424 msgid "" "Prevents any more tasks from being submitted to the pool. Once all the " "tasks have been completed the worker processes will exit." msgstr "" -#: ../../library/multiprocessing.rst:2423 +#: ../../library/multiprocessing.rst:2429 msgid "" "Stops the worker processes immediately without completing outstanding work. " "When the pool object is garbage collected :meth:`terminate` will be called " "immediately." msgstr "" -#: ../../library/multiprocessing.rst:2429 +#: ../../library/multiprocessing.rst:2435 msgid "" "Wait for the worker processes to exit. One must call :meth:`close` or :meth:" "`terminate` before using :meth:`join`." msgstr "" -#: ../../library/multiprocessing.rst:2432 +#: ../../library/multiprocessing.rst:2438 msgid "" "Pool objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the pool " "object, and :meth:`~contextmanager.__exit__` calls :meth:`terminate`." msgstr "" -#: ../../library/multiprocessing.rst:2440 +#: ../../library/multiprocessing.rst:2446 msgid "" "The class of the result returned by :meth:`Pool.apply_async` and :meth:`Pool." "map_async`." msgstr "" -#: ../../library/multiprocessing.rst:2445 +#: ../../library/multiprocessing.rst:2451 msgid "" "Return the result when it arrives. If *timeout* is not ``None`` and the " "result does not arrive within *timeout* seconds then :exc:`multiprocessing." @@ -3635,31 +3635,31 @@ msgid "" "exception will be reraised by :meth:`get`." msgstr "" -#: ../../library/multiprocessing.rst:2452 +#: ../../library/multiprocessing.rst:2458 msgid "Wait until the result is available or until *timeout* seconds pass." msgstr "" -#: ../../library/multiprocessing.rst:2456 +#: ../../library/multiprocessing.rst:2462 msgid "Return whether the call has completed." msgstr "" -#: ../../library/multiprocessing.rst:2460 +#: ../../library/multiprocessing.rst:2466 msgid "" "Return whether the call completed without raising an exception. Will raise :" "exc:`ValueError` if the result is not ready." msgstr "" -#: ../../library/multiprocessing.rst:2463 +#: ../../library/multiprocessing.rst:2469 msgid "" "If the result is not ready, :exc:`ValueError` is raised instead of :exc:" "`AssertionError`." msgstr "" -#: ../../library/multiprocessing.rst:2467 +#: ../../library/multiprocessing.rst:2473 msgid "The following example demonstrates the use of a pool::" msgstr "" -#: ../../library/multiprocessing.rst:2469 +#: ../../library/multiprocessing.rst:2475 msgid "" "from multiprocessing import Pool\n" "import time\n" @@ -3687,17 +3687,17 @@ msgid "" "TimeoutError" msgstr "" -#: ../../library/multiprocessing.rst:2494 +#: ../../library/multiprocessing.rst:2500 msgid "Listeners and Clients" msgstr "" -#: ../../library/multiprocessing.rst:2499 +#: ../../library/multiprocessing.rst:2505 msgid "" "Usually message passing between processes is done using queues or by using :" "class:`~Connection` objects returned by :func:`~multiprocessing.Pipe`." msgstr "" -#: ../../library/multiprocessing.rst:2503 +#: ../../library/multiprocessing.rst:2509 msgid "" "However, the :mod:`multiprocessing.connection` module allows some extra " "flexibility. It basically gives a high level message oriented API for " @@ -3706,46 +3706,46 @@ msgid "" "multiple connections at the same time." msgstr "" -#: ../../library/multiprocessing.rst:2512 +#: ../../library/multiprocessing.rst:2518 msgid "" "Send a randomly generated message to the other end of the connection and " "wait for a reply." msgstr "" -#: ../../library/multiprocessing.rst:2515 +#: ../../library/multiprocessing.rst:2521 msgid "" "If the reply matches the digest of the message using *authkey* as the key " "then a welcome message is sent to the other end of the connection. " "Otherwise :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2521 +#: ../../library/multiprocessing.rst:2527 msgid "" "Receive a message, calculate the digest of the message using *authkey* as " "the key, and then send the digest back." msgstr "" -#: ../../library/multiprocessing.rst:2524 +#: ../../library/multiprocessing.rst:2530 msgid "" "If a welcome message is not received, then :exc:`~multiprocessing." "AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2529 +#: ../../library/multiprocessing.rst:2535 msgid "" "Attempt to set up a connection to the listener which is using address " "*address*, returning a :class:`~Connection`." msgstr "" -#: ../../library/multiprocessing.rst:2532 +#: ../../library/multiprocessing.rst:2538 msgid "" "The type of the connection is determined by *family* argument, but this can " "generally be omitted since it can usually be inferred from the format of " "*address*. (See :ref:`multiprocessing-address-formats`)" msgstr "" -#: ../../library/multiprocessing.rst:2536 -#: ../../library/multiprocessing.rst:2571 +#: ../../library/multiprocessing.rst:2542 +#: ../../library/multiprocessing.rst:2577 msgid "" "If *authkey* is given and not ``None``, it should be a byte string and will " "be used as the secret key for an HMAC-based authentication challenge. No " @@ -3754,26 +3754,26 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:2544 +#: ../../library/multiprocessing.rst:2550 msgid "" "A wrapper for a bound socket or Windows named pipe which is 'listening' for " "connections." msgstr "" -#: ../../library/multiprocessing.rst:2547 +#: ../../library/multiprocessing.rst:2553 msgid "" "*address* is the address to be used by the bound socket or named pipe of the " "listener object." msgstr "" -#: ../../library/multiprocessing.rst:2552 +#: ../../library/multiprocessing.rst:2558 msgid "" "If an address of '0.0.0.0' is used, the address will not be a connectable " "end point on Windows. If you require a connectable end-point, you should use " "'127.0.0.1'." msgstr "" -#: ../../library/multiprocessing.rst:2556 +#: ../../library/multiprocessing.rst:2562 msgid "" "*family* is the type of socket (or named pipe) to use. This can be one of " "the strings ``'AF_INET'`` (for a TCP socket), ``'AF_UNIX'`` (for a Unix " @@ -3787,49 +3787,49 @@ msgid "" "using :func:`tempfile.mkstemp`." msgstr "" -#: ../../library/multiprocessing.rst:2567 +#: ../../library/multiprocessing.rst:2573 msgid "" "If the listener object uses a socket then *backlog* (1 by default) is passed " "to the :meth:`~socket.socket.listen` method of the socket once it has been " "bound." msgstr "" -#: ../../library/multiprocessing.rst:2579 +#: ../../library/multiprocessing.rst:2585 msgid "" "Accept a connection on the bound socket or named pipe of the listener object " "and return a :class:`~Connection` object. If authentication is attempted and " "fails, then :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2586 +#: ../../library/multiprocessing.rst:2592 msgid "" "Close the bound socket or named pipe of the listener object. This is called " "automatically when the listener is garbage collected. However it is " "advisable to call it explicitly." msgstr "" -#: ../../library/multiprocessing.rst:2590 +#: ../../library/multiprocessing.rst:2596 msgid "Listener objects have the following read-only properties:" msgstr "" -#: ../../library/multiprocessing.rst:2594 +#: ../../library/multiprocessing.rst:2600 msgid "The address which is being used by the Listener object." msgstr "" -#: ../../library/multiprocessing.rst:2598 +#: ../../library/multiprocessing.rst:2604 msgid "" "The address from which the last accepted connection came. If this is " "unavailable then it is ``None``." msgstr "" -#: ../../library/multiprocessing.rst:2601 +#: ../../library/multiprocessing.rst:2607 msgid "" "Listener objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "listener object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:2608 +#: ../../library/multiprocessing.rst:2614 msgid "" "Wait till an object in *object_list* is ready. Returns the list of those " "objects in *object_list* which are ready. If *timeout* is a float then the " @@ -3838,32 +3838,32 @@ msgid "" "zero timeout." msgstr "" -#: ../../library/multiprocessing.rst:2614 +#: ../../library/multiprocessing.rst:2620 msgid "" "For both POSIX and Windows, an object can appear in *object_list* if it is" msgstr "" -#: ../../library/multiprocessing.rst:2617 +#: ../../library/multiprocessing.rst:2623 msgid "a readable :class:`~multiprocessing.connection.Connection` object;" msgstr "" -#: ../../library/multiprocessing.rst:2618 +#: ../../library/multiprocessing.rst:2624 msgid "a connected and readable :class:`socket.socket` object; or" msgstr "" -#: ../../library/multiprocessing.rst:2619 +#: ../../library/multiprocessing.rst:2625 msgid "" "the :attr:`~multiprocessing.Process.sentinel` attribute of a :class:" "`~multiprocessing.Process` object." msgstr "" -#: ../../library/multiprocessing.rst:2622 +#: ../../library/multiprocessing.rst:2628 msgid "" "A connection or socket object is ready when there is data available to be " "read from it, or the other end has been closed." msgstr "" -#: ../../library/multiprocessing.rst:2625 +#: ../../library/multiprocessing.rst:2631 msgid "" "**POSIX**: ``wait(object_list, timeout)`` almost equivalent ``select." "select(object_list, [], [], timeout)``. The difference is that, if :func:" @@ -3871,7 +3871,7 @@ msgid "" "an error number of ``EINTR``, whereas :func:`wait` will not." msgstr "" -#: ../../library/multiprocessing.rst:2631 +#: ../../library/multiprocessing.rst:2637 msgid "" "**Windows**: An item in *object_list* must either be an integer handle which " "is waitable (according to the definition used by the documentation of the " @@ -3881,18 +3881,18 @@ msgid "" "handles.)" msgstr "" -#: ../../library/multiprocessing.rst:2641 +#: ../../library/multiprocessing.rst:2647 msgid "**Examples**" msgstr "" -#: ../../library/multiprocessing.rst:2643 +#: ../../library/multiprocessing.rst:2649 msgid "" "The following server code creates a listener which uses ``'secret " "password'`` as an authentication key. It then waits for a connection and " "sends some data to the client::" msgstr "" -#: ../../library/multiprocessing.rst:2647 +#: ../../library/multiprocessing.rst:2653 msgid "" "from multiprocessing.connection import Listener\n" "from array import array\n" @@ -3910,13 +3910,13 @@ msgid "" " conn.send_bytes(array('i', [42, 1729]))" msgstr "" -#: ../../library/multiprocessing.rst:2662 +#: ../../library/multiprocessing.rst:2668 msgid "" "The following code connects to the server and receives some data from the " "server::" msgstr "" -#: ../../library/multiprocessing.rst:2665 +#: ../../library/multiprocessing.rst:2671 msgid "" "from multiprocessing.connection import Client\n" "from array import array\n" @@ -3946,13 +3946,13 @@ msgstr "" " print(conn.recv_bytes_into(arr)) # => 8\n" " print(arr) # => array('i', [42, 1729, 0, 0, 0])" -#: ../../library/multiprocessing.rst:2679 +#: ../../library/multiprocessing.rst:2685 msgid "" "The following code uses :func:`~multiprocessing.connection.wait` to wait for " "messages from multiple processes at once::" msgstr "" -#: ../../library/multiprocessing.rst:2682 +#: ../../library/multiprocessing.rst:2688 msgid "" "from multiprocessing import Process, Pipe, current_process\n" "from multiprocessing.connection import wait\n" @@ -3986,23 +3986,23 @@ msgid "" " print(msg)" msgstr "" -#: ../../library/multiprocessing.rst:2717 +#: ../../library/multiprocessing.rst:2723 msgid "Address Formats" msgstr "" -#: ../../library/multiprocessing.rst:2719 +#: ../../library/multiprocessing.rst:2725 msgid "" "An ``'AF_INET'`` address is a tuple of the form ``(hostname, port)`` where " "*hostname* is a string and *port* is an integer." msgstr "" -#: ../../library/multiprocessing.rst:2722 +#: ../../library/multiprocessing.rst:2728 msgid "" "An ``'AF_UNIX'`` address is a string representing a filename on the " "filesystem." msgstr "" -#: ../../library/multiprocessing.rst:2725 +#: ../../library/multiprocessing.rst:2731 msgid "" "An ``'AF_PIPE'`` address is a string of the form :samp:`r'\\\\\\\\\\\\.\\" "\\pipe\\\\\\\\{PipeName}'`. To use :func:`Client` to connect to a named " @@ -4011,17 +4011,17 @@ msgid "" "instead." msgstr "" -#: ../../library/multiprocessing.rst:2730 +#: ../../library/multiprocessing.rst:2736 msgid "" "Note that any string beginning with two backslashes is assumed by default to " "be an ``'AF_PIPE'`` address rather than an ``'AF_UNIX'`` address." msgstr "" -#: ../../library/multiprocessing.rst:2737 +#: ../../library/multiprocessing.rst:2743 msgid "Authentication keys" msgstr "" -#: ../../library/multiprocessing.rst:2739 +#: ../../library/multiprocessing.rst:2745 msgid "" "When one uses :meth:`Connection.recv `, the data received " "is automatically unpickled. Unfortunately unpickling data from an untrusted " @@ -4029,7 +4029,7 @@ msgid "" "use the :mod:`hmac` module to provide digest authentication." msgstr "" -#: ../../library/multiprocessing.rst:2745 +#: ../../library/multiprocessing.rst:2751 msgid "" "An authentication key is a byte string which can be thought of as a " "password: once a connection is established both ends will demand proof that " @@ -4037,7 +4037,7 @@ msgid "" "using the same key does **not** involve sending the key over the connection.)" msgstr "" -#: ../../library/multiprocessing.rst:2751 +#: ../../library/multiprocessing.rst:2757 msgid "" "If authentication is requested but no authentication key is specified then " "the return value of ``current_process().authkey`` is used (see :class:" @@ -4048,17 +4048,17 @@ msgid "" "setting up connections between themselves." msgstr "" -#: ../../library/multiprocessing.rst:2759 +#: ../../library/multiprocessing.rst:2765 msgid "" "Suitable authentication keys can also be generated by using :func:`os." "urandom`." msgstr "" -#: ../../library/multiprocessing.rst:2763 +#: ../../library/multiprocessing.rst:2769 msgid "Logging" msgstr "" -#: ../../library/multiprocessing.rst:2765 +#: ../../library/multiprocessing.rst:2771 msgid "" "Some support for logging is available. Note, however, that the :mod:" "`logging` package does not use process shared locks so it is possible " @@ -4066,27 +4066,27 @@ msgid "" "mixed up." msgstr "" -#: ../../library/multiprocessing.rst:2772 +#: ../../library/multiprocessing.rst:2778 msgid "" "Returns the logger used by :mod:`multiprocessing`. If necessary, a new one " "will be created." msgstr "" -#: ../../library/multiprocessing.rst:2775 +#: ../../library/multiprocessing.rst:2781 msgid "" "When first created the logger has level :const:`logging.NOTSET` and no " "default handler. Messages sent to this logger will not by default propagate " "to the root logger." msgstr "" -#: ../../library/multiprocessing.rst:2779 +#: ../../library/multiprocessing.rst:2785 msgid "" "Note that on Windows child processes will only inherit the level of the " "parent process's logger -- any other customization of the logger will not be " "inherited." msgstr "" -#: ../../library/multiprocessing.rst:2786 +#: ../../library/multiprocessing.rst:2792 msgid "" "This function performs a call to :func:`get_logger` but in addition to " "returning the logger created by get_logger, it adds a handler which sends " @@ -4095,11 +4095,11 @@ msgid "" "``level`` argument." msgstr "" -#: ../../library/multiprocessing.rst:2792 +#: ../../library/multiprocessing.rst:2798 msgid "Below is an example session with logging turned on::" msgstr "" -#: ../../library/multiprocessing.rst:2794 +#: ../../library/multiprocessing.rst:2800 msgid "" ">>> import multiprocessing, logging\n" ">>> logger = multiprocessing.log_to_stderr()\n" @@ -4127,21 +4127,21 @@ msgstr "" "[INFO/MainProcess] sending shutdown message to manager\n" "[INFO/SyncManager-...] manager exiting with exitcode 0" -#: ../../library/multiprocessing.rst:2807 +#: ../../library/multiprocessing.rst:2813 msgid "For a full table of logging levels, see the :mod:`logging` module." msgstr "" -#: ../../library/multiprocessing.rst:2811 +#: ../../library/multiprocessing.rst:2817 msgid "The :mod:`multiprocessing.dummy` module" msgstr ":mod:`multiprocessing.dummy` 模組" -#: ../../library/multiprocessing.rst:2816 +#: ../../library/multiprocessing.rst:2822 msgid "" ":mod:`multiprocessing.dummy` replicates the API of :mod:`multiprocessing` " "but is no more than a wrapper around the :mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:2821 +#: ../../library/multiprocessing.rst:2827 msgid "" "In particular, the ``Pool`` function provided by :mod:`multiprocessing." "dummy` returns an instance of :class:`ThreadPool`, which is a subclass of :" @@ -4149,7 +4149,7 @@ msgid "" "worker threads rather than worker processes." msgstr "" -#: ../../library/multiprocessing.rst:2829 +#: ../../library/multiprocessing.rst:2835 msgid "" "A thread pool object which controls a pool of worker threads to which jobs " "can be submitted. :class:`ThreadPool` instances are fully interface " @@ -4159,18 +4159,18 @@ msgid "" "pool.Pool.terminate` manually." msgstr "" -#: ../../library/multiprocessing.rst:2836 +#: ../../library/multiprocessing.rst:2842 msgid "" "*processes* is the number of worker threads to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2842 +#: ../../library/multiprocessing.rst:2848 msgid "" "Unlike :class:`Pool`, *maxtasksperchild* and *context* cannot be provided." msgstr "" -#: ../../library/multiprocessing.rst:2846 +#: ../../library/multiprocessing.rst:2852 msgid "" "A :class:`ThreadPool` shares the same interface as :class:`Pool`, which is " "designed around a pool of processes and predates the introduction of the :" @@ -4180,7 +4180,7 @@ msgid "" "is not understood by any other libraries." msgstr "" -#: ../../library/multiprocessing.rst:2853 +#: ../../library/multiprocessing.rst:2859 msgid "" "Users should generally prefer to use :class:`concurrent.futures." "ThreadPoolExecutor`, which has a simpler interface that was designed around " @@ -4189,69 +4189,69 @@ msgid "" "`asyncio`." msgstr "" -#: ../../library/multiprocessing.rst:2863 +#: ../../library/multiprocessing.rst:2869 msgid "Programming guidelines" msgstr "" -#: ../../library/multiprocessing.rst:2865 +#: ../../library/multiprocessing.rst:2871 msgid "" "There are certain guidelines and idioms which should be adhered to when " "using :mod:`multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:2870 +#: ../../library/multiprocessing.rst:2876 msgid "All start methods" msgstr "" -#: ../../library/multiprocessing.rst:2872 +#: ../../library/multiprocessing.rst:2878 msgid "The following applies to all start methods." msgstr "" -#: ../../library/multiprocessing.rst:2874 +#: ../../library/multiprocessing.rst:2880 msgid "Avoid shared state" msgstr "" -#: ../../library/multiprocessing.rst:2876 +#: ../../library/multiprocessing.rst:2882 msgid "" "As far as possible one should try to avoid shifting large amounts of data " "between processes." msgstr "" -#: ../../library/multiprocessing.rst:2879 +#: ../../library/multiprocessing.rst:2885 msgid "" "It is probably best to stick to using queues or pipes for communication " "between processes rather than using the lower level synchronization " "primitives." msgstr "" -#: ../../library/multiprocessing.rst:2883 +#: ../../library/multiprocessing.rst:2889 msgid "Picklability" msgstr "" -#: ../../library/multiprocessing.rst:2885 +#: ../../library/multiprocessing.rst:2891 msgid "Ensure that the arguments to the methods of proxies are picklable." msgstr "" -#: ../../library/multiprocessing.rst:2887 +#: ../../library/multiprocessing.rst:2893 msgid "Thread safety of proxies" msgstr "" -#: ../../library/multiprocessing.rst:2889 +#: ../../library/multiprocessing.rst:2895 msgid "" "Do not use a proxy object from more than one thread unless you protect it " "with a lock." msgstr "" -#: ../../library/multiprocessing.rst:2892 +#: ../../library/multiprocessing.rst:2898 msgid "" "(There is never a problem with different processes using the *same* proxy.)" msgstr "" -#: ../../library/multiprocessing.rst:2894 +#: ../../library/multiprocessing.rst:2900 msgid "Joining zombie processes" msgstr "" -#: ../../library/multiprocessing.rst:2896 +#: ../../library/multiprocessing.rst:2902 msgid "" "On POSIX when a process finishes but has not been joined it becomes a " "zombie. There should never be very many because each time a new process " @@ -4262,11 +4262,11 @@ msgid "" "explicitly join all the processes that you start." msgstr "" -#: ../../library/multiprocessing.rst:2904 +#: ../../library/multiprocessing.rst:2910 msgid "Better to inherit than pickle/unpickle" msgstr "" -#: ../../library/multiprocessing.rst:2906 +#: ../../library/multiprocessing.rst:2912 msgid "" "When using the *spawn* or *forkserver* start methods many types from :mod:" "`multiprocessing` need to be picklable so that child processes can use " @@ -4276,11 +4276,11 @@ msgid "" "inherit it from an ancestor process." msgstr "" -#: ../../library/multiprocessing.rst:2914 +#: ../../library/multiprocessing.rst:2920 msgid "Avoid terminating processes" msgstr "" -#: ../../library/multiprocessing.rst:2916 +#: ../../library/multiprocessing.rst:2922 msgid "" "Using the :meth:`Process.terminate ` " "method to stop a process is liable to cause any shared resources (such as " @@ -4288,18 +4288,18 @@ msgid "" "become broken or unavailable to other processes." msgstr "" -#: ../../library/multiprocessing.rst:2922 +#: ../../library/multiprocessing.rst:2928 msgid "" "Therefore it is probably best to only consider using :meth:`Process." "terminate ` on processes which never use " "any shared resources." msgstr "" -#: ../../library/multiprocessing.rst:2926 +#: ../../library/multiprocessing.rst:2932 msgid "Joining processes that use queues" msgstr "" -#: ../../library/multiprocessing.rst:2928 +#: ../../library/multiprocessing.rst:2934 msgid "" "Bear in mind that a process that has put items in a queue will wait before " "terminating until all the buffered items are fed by the \"feeder\" thread to " @@ -4308,7 +4308,7 @@ msgid "" "queue to avoid this behaviour.)" msgstr "" -#: ../../library/multiprocessing.rst:2934 +#: ../../library/multiprocessing.rst:2940 msgid "" "This means that whenever you use a queue you need to make sure that all " "items which have been put on the queue will eventually be removed before the " @@ -4317,11 +4317,11 @@ msgid "" "processes will be joined automatically." msgstr "" -#: ../../library/multiprocessing.rst:2940 +#: ../../library/multiprocessing.rst:2946 msgid "An example which will deadlock is the following::" msgstr "" -#: ../../library/multiprocessing.rst:2942 +#: ../../library/multiprocessing.rst:2948 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -4336,17 +4336,17 @@ msgid "" " obj = queue.get()" msgstr "" -#: ../../library/multiprocessing.rst:2954 +#: ../../library/multiprocessing.rst:2960 msgid "" "A fix here would be to swap the last two lines (or simply remove the ``p." "join()`` line)." msgstr "" -#: ../../library/multiprocessing.rst:2957 +#: ../../library/multiprocessing.rst:2963 msgid "Explicitly pass resources to child processes" msgstr "" -#: ../../library/multiprocessing.rst:2959 +#: ../../library/multiprocessing.rst:2965 msgid "" "On POSIX using the *fork* start method, a child process can make use of a " "shared resource created in a parent process using a global resource. " @@ -4354,7 +4354,7 @@ msgid "" "for the child process." msgstr "" -#: ../../library/multiprocessing.rst:2964 +#: ../../library/multiprocessing.rst:2970 msgid "" "Apart from making the code (potentially) compatible with Windows and the " "other start methods this also ensures that as long as the child process is " @@ -4363,11 +4363,11 @@ msgid "" "collected in the parent process." msgstr "" -#: ../../library/multiprocessing.rst:2971 +#: ../../library/multiprocessing.rst:2977 msgid "So for instance ::" msgstr "" -#: ../../library/multiprocessing.rst:2973 +#: ../../library/multiprocessing.rst:2979 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4389,11 +4389,11 @@ msgstr "" " for i in range(10):\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:2983 +#: ../../library/multiprocessing.rst:2989 msgid "should be rewritten as ::" msgstr "" -#: ../../library/multiprocessing.rst:2985 +#: ../../library/multiprocessing.rst:2991 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4415,25 +4415,25 @@ msgstr "" " for i in range(10):\n" " Process(target=f, args=(lock,)).start()" -#: ../../library/multiprocessing.rst:2995 +#: ../../library/multiprocessing.rst:3001 msgid "Beware of replacing :data:`sys.stdin` with a \"file like object\"" msgstr "" -#: ../../library/multiprocessing.rst:2997 +#: ../../library/multiprocessing.rst:3003 msgid ":mod:`multiprocessing` originally unconditionally called::" msgstr "" -#: ../../library/multiprocessing.rst:2999 +#: ../../library/multiprocessing.rst:3005 msgid "os.close(sys.stdin.fileno())" msgstr "os.close(sys.stdin.fileno())" -#: ../../library/multiprocessing.rst:3001 +#: ../../library/multiprocessing.rst:3007 msgid "" "in the :meth:`multiprocessing.Process._bootstrap` method --- this resulted " "in issues with processes-in-processes. This has been changed to::" msgstr "" -#: ../../library/multiprocessing.rst:3004 +#: ../../library/multiprocessing.rst:3010 msgid "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" @@ -4441,7 +4441,7 @@ msgstr "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" -#: ../../library/multiprocessing.rst:3007 +#: ../../library/multiprocessing.rst:3013 msgid "" "Which solves the fundamental issue of processes colliding with each other " "resulting in a bad file descriptor error, but introduces a potential danger " @@ -4451,14 +4451,14 @@ msgid "" "data being flushed to the object multiple times, resulting in corruption." msgstr "" -#: ../../library/multiprocessing.rst:3014 +#: ../../library/multiprocessing.rst:3020 msgid "" "If you write a file-like object and implement your own caching, you can make " "it fork-safe by storing the pid whenever you append to the cache, and " "discarding the cache when the pid changes. For example::" msgstr "" -#: ../../library/multiprocessing.rst:3018 +#: ../../library/multiprocessing.rst:3024 msgid "" "@property\n" "def cache(self):\n" @@ -4476,26 +4476,26 @@ msgstr "" " self._cache = []\n" " return self._cache" -#: ../../library/multiprocessing.rst:3026 +#: ../../library/multiprocessing.rst:3032 msgid "" "For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`" msgstr "" -#: ../../library/multiprocessing.rst:3029 +#: ../../library/multiprocessing.rst:3038 msgid "The *spawn* and *forkserver* start methods" msgstr "" -#: ../../library/multiprocessing.rst:3031 +#: ../../library/multiprocessing.rst:3040 msgid "" "There are a few extra restrictions which don't apply to the *fork* start " "method." msgstr "" -#: ../../library/multiprocessing.rst:3034 +#: ../../library/multiprocessing.rst:3043 msgid "More picklability" msgstr "" -#: ../../library/multiprocessing.rst:3036 +#: ../../library/multiprocessing.rst:3045 msgid "" "Ensure that all arguments to :class:`~multiprocessing.Process` are " "picklable. Also, if you subclass ``Process.__init__``, you must make sure " @@ -4503,11 +4503,11 @@ msgid "" "` method is called." msgstr "" -#: ../../library/multiprocessing.rst:3041 +#: ../../library/multiprocessing.rst:3050 msgid "Global variables" msgstr "" -#: ../../library/multiprocessing.rst:3043 +#: ../../library/multiprocessing.rst:3052 msgid "" "Bear in mind that if code run in a child process tries to access a global " "variable, then the value it sees (if any) may not be the same as the value " @@ -4515,30 +4515,30 @@ msgid "" "Process.start>` was called." msgstr "" -#: ../../library/multiprocessing.rst:3048 +#: ../../library/multiprocessing.rst:3057 msgid "" "However, global variables which are just module level constants cause no " "problems." msgstr "" -#: ../../library/multiprocessing.rst:3053 +#: ../../library/multiprocessing.rst:3062 msgid "Safe importing of main module" msgstr "" -#: ../../library/multiprocessing.rst:3055 +#: ../../library/multiprocessing.rst:3064 msgid "" "Make sure that the main module can be safely imported by a new Python " "interpreter without causing unintended side effects (such as starting a new " "process)." msgstr "" -#: ../../library/multiprocessing.rst:3059 +#: ../../library/multiprocessing.rst:3068 msgid "" "For example, using the *spawn* or *forkserver* start method running the " "following module would fail with a :exc:`RuntimeError`::" msgstr "" -#: ../../library/multiprocessing.rst:3063 +#: ../../library/multiprocessing.rst:3072 msgid "" "from multiprocessing import Process\n" "\n" @@ -4556,13 +4556,13 @@ msgstr "" "p = Process(target=foo)\n" "p.start()" -#: ../../library/multiprocessing.rst:3071 +#: ../../library/multiprocessing.rst:3080 msgid "" "Instead one should protect the \"entry point\" of the program by using ``if " "__name__ == '__main__':`` as follows::" msgstr "" -#: ../../library/multiprocessing.rst:3074 +#: ../../library/multiprocessing.rst:3083 msgid "" "from multiprocessing import Process, freeze_support, set_start_method\n" "\n" @@ -4586,33 +4586,33 @@ msgstr "" " p = Process(target=foo)\n" " p.start()" -#: ../../library/multiprocessing.rst:3085 +#: ../../library/multiprocessing.rst:3094 msgid "" "(The ``freeze_support()`` line can be omitted if the program will be run " "normally instead of frozen.)" msgstr "" -#: ../../library/multiprocessing.rst:3088 +#: ../../library/multiprocessing.rst:3097 msgid "" "This allows the newly spawned Python interpreter to safely import the module " "and then run the module's ``foo()`` function." msgstr "" -#: ../../library/multiprocessing.rst:3091 +#: ../../library/multiprocessing.rst:3100 msgid "" "Similar restrictions apply if a pool or manager is created in the main " "module." msgstr "" -#: ../../library/multiprocessing.rst:3098 +#: ../../library/multiprocessing.rst:3107 msgid "Examples" msgstr "範例" -#: ../../library/multiprocessing.rst:3100 +#: ../../library/multiprocessing.rst:3109 msgid "Demonstration of how to create and use customized managers and proxies:" msgstr "" -#: ../../library/multiprocessing.rst:3102 +#: ../../library/multiprocessing.rst:3111 msgid "" "from multiprocessing import freeze_support\n" "from multiprocessing.managers import BaseManager, BaseProxy\n" @@ -4706,11 +4706,11 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3106 +#: ../../library/multiprocessing.rst:3115 msgid "Using :class:`~multiprocessing.pool.Pool`:" msgstr "使用 :class:`~multiprocessing.pool.Pool`:" -#: ../../library/multiprocessing.rst:3108 +#: ../../library/multiprocessing.rst:3117 msgid "" "import multiprocessing\n" "import time\n" @@ -4870,13 +4870,13 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3112 +#: ../../library/multiprocessing.rst:3121 msgid "" "An example showing how to use queues to feed tasks to a collection of worker " "processes and collect the results:" msgstr "" -#: ../../library/multiprocessing.rst:3115 +#: ../../library/multiprocessing.rst:3124 msgid "" "import time\n" "import random\n" From d66eab695676d15f87140fb8373b631a16b6bb72 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 30 Jul 2025 00:19:50 +0000 Subject: [PATCH 02/13] sync with cpython d61f8b84 --- library/array.po | 142 ++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/library/array.po b/library/array.po index c9aa3ec262..746000dca2 100644 --- a/library/array.po +++ b/library/array.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-07-30 00:18+0000\n" "PO-Revision-Date: 2021-11-23 18:40+0800\n" "Last-Translator: Benson Chen \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -123,6 +123,10 @@ msgstr "Py_UCS4" msgid "4" msgstr "4" +#: ../../library/array.rst:27 +msgid "\\(2)" +msgstr "" + #: ../../library/array.rst:29 msgid "``'h'``" msgstr "``'h'``" @@ -230,7 +234,7 @@ msgstr "" msgid "Please migrate to ``'w'`` typecode." msgstr "" -#: ../../library/array.rst:64 +#: ../../library/array.rst:67 msgid "" "The actual representation of values is determined by the machine " "architecture (strictly speaking, by the C implementation). The actual size " @@ -239,30 +243,30 @@ msgstr "" "實際上數值的表示方法是被機器的架構所決定(更精準地說,被 C 的實作方法決定)。" "實際的大小可以透過 :attr:`array.itemsize` 屬性存取。" -#: ../../library/array.rst:68 +#: ../../library/array.rst:71 msgid "The module defines the following item:" msgstr "這個模組定義了以下項目:" -#: ../../library/array.rst:73 +#: ../../library/array.rst:76 msgid "A string with all available type codes." msgstr "一個包含所有可用的 type codes 的字串。" -#: ../../library/array.rst:76 +#: ../../library/array.rst:79 msgid "The module defines the following type:" msgstr "這個模組定義了下方的型別:" -#: ../../library/array.rst:81 +#: ../../library/array.rst:84 msgid "" "A new array whose items are restricted by *typecode*, and initialized from " -"the optional *initializer* value, which must be a :class:`bytes` " -"or :class:`bytearray` object, a Unicode string, or iterable over elements of " -"the appropriate type." +"the optional *initializer* value, which must be a :class:`bytes` or :class:" +"`bytearray` object, a Unicode string, or iterable over elements of the " +"appropriate type." msgstr "" "一個新的陣列中的元素被 *typecode* 限制,並由選用的 *initializer* 參數初始化," "*initializer* 必須是一個 :class:`bytes` 或 :class:`bytearray` 物件、一個 " "Unicode 字串或包含適當型別元素的可疊代物件 (iterable)。" -#: ../../library/array.rst:86 +#: ../../library/array.rst:89 msgid "" "If given a :class:`bytes` or :class:`bytearray` object, the initializer is " "passed to the new array's :meth:`frombytes` method; if given a Unicode " @@ -275,7 +279,7 @@ msgstr "" "方法;其他情況時, 一個 initializer 的可疊代物件將被傳入 :meth:`extend` 方法" "之中來將初始項目新增至陣列。" -#: ../../library/array.rst:93 +#: ../../library/array.rst:96 msgid "" "Array objects support the ordinary sequence operations of indexing, slicing, " "concatenation, and multiplication. When using slice assignment, the " @@ -290,7 +294,7 @@ msgstr "" "了緩衝區介面,可以在任何支援 :term:`bytes-like objects ` " "的地方使用。" -#: ../../library/array.rst:99 +#: ../../library/array.rst:102 msgid "" "Raises an :ref:`auditing event ` ``array.__new__`` with arguments " "``typecode``, ``initializer``." @@ -298,19 +302,19 @@ msgstr "" "引發\\ :ref:`稽核事件 (auditing event) ` ``array.__new__`` 並附帶引" "數 ``typecode``、``initializer``。" -#: ../../library/array.rst:104 +#: ../../library/array.rst:107 msgid "The typecode character used to create the array." msgstr "typecode 字元被用在建立陣列時。" -#: ../../library/array.rst:109 +#: ../../library/array.rst:112 msgid "The length in bytes of one array item in the internal representation." msgstr "陣列當中的一個元素在內部需要的位元組長度。" -#: ../../library/array.rst:114 +#: ../../library/array.rst:117 msgid "Append a new item with value *x* to the end of the array." msgstr "新增一個元素 *x* 到陣列的最尾端。" -#: ../../library/array.rst:119 +#: ../../library/array.rst:122 msgid "" "Return a tuple ``(address, length)`` giving the current memory address and " "the length in elements of the buffer used to hold array's contents. The " @@ -327,7 +331,7 @@ msgstr "" "用,例如 :c:func:`!ioctl` 指令。只要陣列存在且沒有使用任何更改長度的操作時," "回傳的數值就有效。" -#: ../../library/array.rst:129 +#: ../../library/array.rst:132 msgid "" "When using array objects from code written in C or C++ (the only way to " "effectively make use of this information), it makes more sense to use the " @@ -339,67 +343,66 @@ msgstr "" "適當的做法是使用陣列物件支援的緩衝區介面。這個方法維護了向後兼容性,並應該在" "新的程式碼中避免。關於緩衝區介面的文件在\\ :ref:`bufferobjects`。" -#: ../../library/array.rst:138 +#: ../../library/array.rst:141 msgid "" "\"Byteswap\" all items of the array. This is only supported for values " -"which are 1, 2, 4, or 8 bytes in size; for other types of " -"values, :exc:`RuntimeError` is raised. It is useful when reading data from " -"a file written on a machine with a different byte order." +"which are 1, 2, 4, or 8 bytes in size; for other types of values, :exc:" +"`RuntimeError` is raised. It is useful when reading data from a file " +"written on a machine with a different byte order." msgstr "" "\"Byteswap\" 所有陣列中的物件。這只有支援物件長度為 1、2、4 或 8 位元組的陣" "列,其他型別的值會導致 :exc:`RuntimeError`。這在從機器讀取位元順序不同的檔案" "時很有用。" -#: ../../library/array.rst:146 +#: ../../library/array.rst:149 msgid "Return the number of occurrences of *x* in the array." msgstr "回傳 *x* 在陣列中出現了幾次。" -#: ../../library/array.rst:151 +#: ../../library/array.rst:154 msgid "" "Append items from *iterable* to the end of the array. If *iterable* is " -"another array, it must have *exactly* the same type code; if " -"not, :exc:`TypeError` will be raised. If *iterable* is not an array, it " -"must be iterable and its elements must be the right type to be appended to " -"the array." +"another array, it must have *exactly* the same type code; if not, :exc:" +"`TypeError` will be raised. If *iterable* is not an array, it must be " +"iterable and its elements must be the right type to be appended to the array." msgstr "" "從 *iterable* 中新增元素到陣列的尾端,如果 *iterable* 是另一個陣列,它必須有" "完全相同的 type code,如果不同會導致 :exc:`TypeError`。如果 *iterable* 不是一" "個陣列,它必須可以被疊代 (iterable) 且其中的元素必須是可以被加入陣列中的正確" "型別。" -#: ../../library/array.rst:159 +#: ../../library/array.rst:162 msgid "" "Appends items from the :term:`bytes-like object`, interpreting its content " -"as an array of machine values (as if it had been read from a file using " -"the :meth:`fromfile` method)." +"as an array of machine values (as if it had been read from a file using the :" +"meth:`fromfile` method)." msgstr "" "從 :term:`bytes-like object` 中新增元素。讀取時會將其內容當作一個機器數值組成" "的陣列(就像從檔案中使用 :meth:`fromfile` 方法讀出的資料)。" -#: ../../library/array.rst:163 +#: ../../library/array.rst:166 msgid ":meth:`!fromstring` is renamed to :meth:`frombytes` for clarity." msgstr "將 :meth:`!fromstring` 更名為 :meth:`frombytes`,使其更加清晰易懂。" -#: ../../library/array.rst:169 +#: ../../library/array.rst:172 msgid "" "Read *n* items (as machine values) from the :term:`file object` *f* and " -"append them to the end of the array. If less than *n* items are " -"available, :exc:`EOFError` is raised, but the items that were available are " -"still inserted into the array." +"append them to the end of the array. If less than *n* items are available, :" +"exc:`EOFError` is raised, but the items that were available are still " +"inserted into the array." msgstr "" "從 :term:`file object` *f* 讀取 *n* 個元素(作為機器數值),接著將這些元素加" "入陣列的最尾端。如果只有少於 *n* 個有效的元素會導致 :exc:`EOFError`,但有效的" "元素仍然會被加入陣列中。" -#: ../../library/array.rst:177 +#: ../../library/array.rst:180 msgid "" -"Append items from the list. This is equivalent to ``for x in list: " -"a.append(x)`` except that if there is a type error, the array is unchanged." +"Append items from the list. This is equivalent to ``for x in list: a." +"append(x)`` except that if there is a type error, the array is unchanged." msgstr "" "從 list 中新增元素。這等價於 ``for x in list: a.append(x)``,除了有型別錯誤產" "生時,陣列會保持原狀不會被更改。" -#: ../../library/array.rst:183 +#: ../../library/array.rst:186 msgid "" "Extends this array with data from the given Unicode string. The array must " "have type code ``'u'`` or ``'w'``; otherwise a :exc:`ValueError` is raised. " @@ -407,32 +410,32 @@ msgid "" "an array of some other type." msgstr "" "用給定的 Unicode 字串擴展這個陣列。陣列的 type code 必須是 ``u`` 或 ``'w'``;" -"其他的型別會導致 :exc:`ValueError` 被引發。使用 " -"``array.frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他" -"型別的陣列。" +"其他的型別會導致 :exc:`ValueError` 被引發。使用 ``array." +"frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他型別的陣" +"列。" -#: ../../library/array.rst:191 +#: ../../library/array.rst:194 msgid "" "Return the smallest *i* such that *i* is the index of the first occurrence " "of *x* in the array. The optional arguments *start* and *stop* can be " -"specified to search for *x* within a subsection of the array. " -"Raise :exc:`ValueError` if *x* is not found." +"specified to search for *x* within a subsection of the array. Raise :exc:" +"`ValueError` if *x* is not found." msgstr "" "回傳 *i* 的最小數值,使得 *i* 成為陣列之中第一次出現 *x* 的索引。選擇性的引" "數 *start* 及 *stop* 則可以被用來在指定的陣列空間中搜尋 *x*。如果 *x* 不存在" "將導致 :exc:`ValueError`。" -#: ../../library/array.rst:196 +#: ../../library/array.rst:199 msgid "Added optional *start* and *stop* parameters." msgstr "新增選擇性的參數 *start* 及 *stop*。" -#: ../../library/array.rst:202 +#: ../../library/array.rst:205 msgid "" "Insert a new item with value *x* in the array before position *i*. Negative " "values are treated as being relative to the end of the array." msgstr "在位置 *i* 之前插入一個元素 *x*。負數的索引值會從陣列尾端開始數。" -#: ../../library/array.rst:208 +#: ../../library/array.rst:211 msgid "" "Removes the item with the index *i* from the array and returns it. The " "optional argument defaults to ``-1``, so that by default the last item is " @@ -441,20 +444,20 @@ msgstr "" "移除並回傳陣列索引值 *i* 的元素。選擇性的引數 *i* 預設為 ``-1``,所以預設會刪" "除並回傳最後一個元素。" -#: ../../library/array.rst:215 +#: ../../library/array.rst:218 msgid "Remove the first occurrence of *x* from the array." msgstr "從陣列中刪除第一個出現的 *x*。" -#: ../../library/array.rst:220 +#: ../../library/array.rst:223 #, fuzzy msgid "Remove all elements from the array." msgstr "從陣列中刪除第一個出現的 *x*。" -#: ../../library/array.rst:227 +#: ../../library/array.rst:230 msgid "Reverse the order of the items in the array." msgstr "反轉陣列中元素的順序。" -#: ../../library/array.rst:232 +#: ../../library/array.rst:235 msgid "" "Convert the array to an array of machine values and return the bytes " "representation (the same sequence of bytes that would be written to a file " @@ -463,31 +466,30 @@ msgstr "" "將陣列轉為另一個機器數值組成的陣列並回傳它的位元組表示(跟用 :meth:`tofile` " "方法寫入檔案時的位元序列相同)。" -#: ../../library/array.rst:236 +#: ../../library/array.rst:239 msgid ":meth:`!tostring` is renamed to :meth:`tobytes` for clarity." msgstr "為了明確性,過去的 :meth:`!tostring` 已更名為 :meth:`tobytes`。" -#: ../../library/array.rst:242 +#: ../../library/array.rst:245 msgid "Write all items (as machine values) to the :term:`file object` *f*." msgstr "將所有元素(作為機器數值)寫入 :term:`file object` *f*。" -#: ../../library/array.rst:247 +#: ../../library/array.rst:250 msgid "Convert the array to an ordinary list with the same items." msgstr "不更改元素,將陣列轉為一般的 list。" -#: ../../library/array.rst:252 +#: ../../library/array.rst:255 #, fuzzy msgid "" "Convert the array to a Unicode string. The array must have a type ``'u'`` " -"or ``'w'``; otherwise a :exc:`ValueError` is raised. Use " -"``array.tobytes().decode(enc)`` to obtain a Unicode string from an array of " -"some other type." +"or ``'w'``; otherwise a :exc:`ValueError` is raised. Use ``array.tobytes()." +"decode(enc)`` to obtain a Unicode string from an array of some other type." msgstr "" -"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u``。其他型別的陣列會導" -"致 :exc:`ValueError` 錯誤。請使用 ``array.tobytes().decode(enc)`` 來為其他型" -"別的陣列轉為 Unicode 字串。" +"將陣列轉為一個 Unicode 字串。陣列的型別必須為 ``u``。其他型別的陣列會導致 :" +"exc:`ValueError` 錯誤。請使用 ``array.tobytes().decode(enc)`` 來為其他型別的" +"陣列轉為 Unicode 字串。" -#: ../../library/array.rst:257 +#: ../../library/array.rst:260 #, fuzzy msgid "" "The string representation of array objects has the form ``array(typecode, " @@ -503,10 +505,10 @@ msgstr "" "陣列物件的字串表示形式為 ``array(typecode, initializer)``。若為空陣列則參數 " "*initializer* 被省略,若 *typecode* 是 ``'u'`` 將被表示為 Unicode 字串,其他" "情況則被表示為由數字組成的 list。只要 :class:`~array.array` class(類別)透" -"過 ``from array import array`` 的方式引入,便能確保該字串表示能透" -"過 :func:`eval` 轉換回一個擁有相同型別及數值的陣列。範例: ::" +"過 ``from array import array`` 的方式引入,便能確保該字串表示能透過 :func:" +"`eval` 轉換回一個擁有相同型別及數值的陣列。範例: ::" -#: ../../library/array.rst:269 +#: ../../library/array.rst:272 #, fuzzy msgid "" "array('l')\n" @@ -519,19 +521,19 @@ msgstr "" "array('l', [1, 2, 3, 4, 5])\n" "array('d', [1.0, 2.0, 3.14, -inf, nan])" -#: ../../library/array.rst:277 +#: ../../library/array.rst:280 msgid "Module :mod:`struct`" msgstr ":mod:`struct` 模組" -#: ../../library/array.rst:278 +#: ../../library/array.rst:281 msgid "Packing and unpacking of heterogeneous binary data." msgstr "將包含不同資料類型的二進位資料包裝與解開包裝。" -#: ../../library/array.rst:280 +#: ../../library/array.rst:283 msgid "`NumPy `_" msgstr "`NumPy `_" -#: ../../library/array.rst:281 +#: ../../library/array.rst:284 msgid "The NumPy package defines another array type." msgstr "NumPy 套件定義了另一個陣列型別" From f3fb9ca8b8584c230f90214e7f1c25c647b1a49c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 31 Jul 2025 00:18:12 +0000 Subject: [PATCH 03/13] sync with cpython 5c16f699 --- library/bisect.po | 74 +++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/library/bisect.po b/library/bisect.po index c423cc4f89..1f1e756f26 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-07-31 00:16+0000\n" "PO-Revision-Date: 2023-08-01 12:53+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -57,10 +57,20 @@ msgstr "" "叫 :meth:`~object.__lt__` 方法,並在陣列中的值回傳一個插入點。" #: ../../library/bisect.rst:29 +msgid "" +"The functions in this module are not thread-safe. If multiple threads " +"concurrently use :mod:`bisect` functions on the same sequence, this may " +"result in undefined behaviour. Likewise, if the provided sequence is mutated " +"by a different thread while a :mod:`bisect` function is operating on it, the " +"result is undefined. For example, using :py:func:`~bisect.insort_left` on " +"the same list from multiple threads may result in the list becoming unsorted." +msgstr "" + +#: ../../library/bisect.rst:39 msgid "The following functions are provided:" msgstr "此模組提供下面的函式:" -#: ../../library/bisect.rst:34 +#: ../../library/bisect.rst:44 msgid "" "Locate the insertion point for *x* in *a* to maintain sorted order. The " "parameters *lo* and *hi* may be used to specify a subset of the list which " @@ -74,7 +84,7 @@ msgstr "" "有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 ``list." "insert()`` 的第一個參數,但列表 *a* 必須先排序過。" -#: ../../library/bisect.rst:41 +#: ../../library/bisect.rst:51 msgid "" "The returned insertion point *ip* partitions the array *a* into two slices " "such that ``all(elem < x for elem in a[lo : ip])`` is true for the left " @@ -85,7 +95,7 @@ msgstr "" "``all(elem < x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem >= " "x for elem in a[ip : hi])`` 為真。" -#: ../../library/bisect.rst:46 +#: ../../library/bisect.rst:56 msgid "" "*key* specifies a :term:`key function` of one argument that is used to " "extract a comparison key from each element in the array. To support " @@ -95,18 +105,18 @@ msgstr "" "所有元素以得到比較值來計算順位。注意此 function 只會套用在陣列中的元素,不會" "套用在 *x*。" -#: ../../library/bisect.rst:50 +#: ../../library/bisect.rst:60 msgid "" "If *key* is ``None``, the elements are compared directly and no key function " "is called." msgstr "若 *key* 為 ``None``,元素將直接進行比較,不會呼叫任何鍵函式。" -#: ../../library/bisect.rst:53 ../../library/bisect.rst:67 -#: ../../library/bisect.rst:85 ../../library/bisect.rst:105 +#: ../../library/bisect.rst:63 ../../library/bisect.rst:77 +#: ../../library/bisect.rst:95 ../../library/bisect.rst:115 msgid "Added the *key* parameter." msgstr "新增 *key* 參數。" -#: ../../library/bisect.rst:60 +#: ../../library/bisect.rst:70 msgid "" "Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point " "which comes after (to the right of) any existing entries of *x* in *a*." @@ -114,7 +124,7 @@ msgstr "" "類似 :py:func:`~bisect.bisect_left`,但回傳的插入位置會在所有 *a* 當中的 *x* " "的後面(右邊)。" -#: ../../library/bisect.rst:63 +#: ../../library/bisect.rst:73 msgid "" "The returned insertion point *ip* partitions the array *a* into two slices " "such that ``all(elem <= x for elem in a[lo : ip])`` is true for the left " @@ -125,11 +135,11 @@ msgstr "" "``all(elem <= x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem > " "x for elem in a[ip : hi])`` 為真。" -#: ../../library/bisect.rst:73 +#: ../../library/bisect.rst:83 msgid "Insert *x* in *a* in sorted order." msgstr "將元素 *x* 插入 list *a*,並維持順序。" -#: ../../library/bisect.rst:75 +#: ../../library/bisect.rst:85 msgid "" "This function first runs :py:func:`~bisect.bisect_left` to locate an " "insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " @@ -138,13 +148,13 @@ msgstr "" "此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:`!" "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" -#: ../../library/bisect.rst:79 ../../library/bisect.rst:99 +#: ../../library/bisect.rst:89 ../../library/bisect.rst:109 msgid "" "To support inserting records in a table, the *key* function (if any) is " "applied to *x* for the search step but not for the insertion step." msgstr "此函式只有在搜尋時會使用 *key* 函式,插入時不會。" -#: ../../library/bisect.rst:82 ../../library/bisect.rst:102 +#: ../../library/bisect.rst:92 ../../library/bisect.rst:112 msgid "" "Keep in mind that the *O*\\ (log *n*) search is dominated by the slow *O*\\ " "(*n*) insertion step." @@ -152,7 +162,7 @@ msgstr "" "注意雖然搜尋是 *O*\\ (log *n*),但插入是 *O*\\ (*n*),因此此函式整體時間複雜" "度是 *O*\\ (*n*)。" -#: ../../library/bisect.rst:92 +#: ../../library/bisect.rst:102 msgid "" "Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after " "any existing entries of *x*." @@ -160,7 +170,7 @@ msgstr "" "類似 :py:func:`~bisect.insort_left`,但插入的位置會在所有 *a* 當中的 *x* 的後" "面(右邊)。" -#: ../../library/bisect.rst:95 +#: ../../library/bisect.rst:105 msgid "" "This function first runs :py:func:`~bisect.bisect_right` to locate an " "insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " @@ -169,11 +179,11 @@ msgstr "" "此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:`!" "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" -#: ../../library/bisect.rst:110 +#: ../../library/bisect.rst:120 msgid "Performance Notes" msgstr "效能考量" -#: ../../library/bisect.rst:112 +#: ../../library/bisect.rst:122 msgid "" "When writing time sensitive code using *bisect()* and *insort()*, keep these " "thoughts in mind:" @@ -181,7 +191,7 @@ msgstr "" "若在需要關注寫入時間的程式當中使用 *bisect()* 和 *insort()*,請特別注意幾個事" "項:" -#: ../../library/bisect.rst:115 +#: ../../library/bisect.rst:125 msgid "" "Bisection is effective for searching ranges of values. For locating specific " "values, dictionaries are more performant." @@ -189,7 +199,7 @@ msgstr "" "二分法在一段範圍的數值中做搜尋的效率較佳,但若是要存取特定數值,使用字典的表" "現還是比較好。" -#: ../../library/bisect.rst:118 +#: ../../library/bisect.rst:128 msgid "" "The *insort()* functions are *O*\\ (*n*) because the logarithmic search step " "is dominated by the linear time insertion step." @@ -197,7 +207,7 @@ msgstr "" "*insort()* 函式的複雜度為 *O*\\ (*n*),因為對數搜尋是以線性時間的插入步驟所主" "導 (dominate)。" -#: ../../library/bisect.rst:121 +#: ../../library/bisect.rst:131 msgid "" "The search functions are stateless and discard key function results after " "they are used. Consequently, if the search functions are used in a loop, " @@ -213,7 +223,7 @@ msgstr "" "另外,也可以透過搜尋預先計算好的鍵列表 (array of precomputed keys) 來定位插入" "點(如下方範例所示)。" -#: ../../library/bisect.rst:131 +#: ../../library/bisect.rst:141 msgid "" "`Sorted Collections `_ is a " "high performance module that uses *bisect* to managed sorted collections of " @@ -222,7 +232,7 @@ msgstr "" "`有序容器 (Sorted Collections) `_ 是一個使用 *bisect* 來管理資料之有序集合的高效能模組。" -#: ../../library/bisect.rst:135 +#: ../../library/bisect.rst:145 msgid "" "The `SortedCollection recipe `_ uses bisect to build a full-featured collection class " @@ -235,11 +245,11 @@ msgstr "" "class) 並帶有符合直覺的搜尋方法 (search methods) 與支援鍵函式。鍵會預先被計算" "好,以減少搜尋過程中多餘的鍵函式呼叫。" -#: ../../library/bisect.rst:143 +#: ../../library/bisect.rst:153 msgid "Searching Sorted Lists" msgstr "搜尋一個已排序的 list" -#: ../../library/bisect.rst:145 +#: ../../library/bisect.rst:155 msgid "" "The above `bisect functions`_ are useful for finding insertion points but " "can be tricky or awkward to use for common searching tasks. The following " @@ -249,7 +259,7 @@ msgstr "" "上面的 `bisect functions`_ 在找到數值插入點上很有用,但一般的數值搜尋任務上就" "不是那麼的方便。以下的五個函式展示了如何將其轉換成標準的有序列表查找函式: ::" -#: ../../library/bisect.rst:150 +#: ../../library/bisect.rst:160 msgid "" "def index(a, x):\n" " 'Locate the leftmost value exactly equal to x'\n" @@ -287,11 +297,11 @@ msgid "" " raise ValueError" msgstr "" -#: ../../library/bisect.rst:187 +#: ../../library/bisect.rst:197 msgid "Examples" msgstr "範例" -#: ../../library/bisect.rst:191 +#: ../../library/bisect.rst:201 msgid "" "The :py:func:`~bisect.bisect` function can be useful for numeric table " "lookups. This example uses :py:func:`~bisect.bisect` to look up a letter " @@ -302,7 +312,7 @@ msgstr "" "個範例使用 :py:func:`~bisect.bisect` 以基於一組有序的數值分界點來為一個考試成" "績找到相對應的字母等級:90 以上是 'A'、80 到 89 為 'B',依此類推: ::" -#: ../../library/bisect.rst:196 +#: ../../library/bisect.rst:206 msgid "" ">>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):\n" "... i = bisect(breakpoints, score)\n" @@ -318,7 +328,7 @@ msgstr "" ">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n" "['F', 'A', 'C', 'C', 'B', 'A', 'A']" -#: ../../library/bisect.rst:203 +#: ../../library/bisect.rst:213 msgid "" "The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also " "work with lists of tuples. The *key* argument can serve to extract the " @@ -328,7 +338,7 @@ msgstr "" "tuples(元組)的 lists,*key* 引數可被用以取出在數值表中作為排序依據的欄" "位: ::" -#: ../../library/bisect.rst:207 +#: ../../library/bisect.rst:217 msgid "" ">>> from collections import namedtuple\n" ">>> from operator import attrgetter\n" @@ -361,7 +371,7 @@ msgid "" " Movie(name='Titanic', released=1997, director='Cameron')]" msgstr "" -#: ../../library/bisect.rst:237 +#: ../../library/bisect.rst:247 msgid "" "If the key function is expensive, it is possible to avoid repeated function " "calls by searching a list of precomputed keys to find the index of a record::" @@ -369,7 +379,7 @@ msgstr "" "如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜尋該紀錄的索引" "值,以減少重複的函式呼叫: ::" -#: ../../library/bisect.rst:240 +#: ../../library/bisect.rst:250 msgid "" ">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n" ">>> data.sort(key=lambda r: r[1]) # Or use operator.itemgetter(1).\n" From 51e85cf3b2f9f8ed15721a09559fdd36c1e29e56 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 3 Aug 2025 00:20:52 +0000 Subject: [PATCH 04/13] sync with cpython 3b28cb0f --- c-api/code.po | 137 +++++++++++++++++++++++++++++++----- c-api/veryhigh.po | 10 +-- library/__future__.po | 157 ++++++++++++++++++++---------------------- 3 files changed, 200 insertions(+), 104 deletions(-) diff --git a/c-api/code.po b/c-api/code.po index 3ce283f533..65d8572ff6 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-03 00:19+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -252,85 +252,184 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/code.rst:215 +#: ../../c-api/code.rst:217 +#, fuzzy +msgid "Code Object Flags" +msgstr "程式碼物件" + +#: ../../c-api/code.rst:219 +msgid "" +"Code objects contain a bit-field of flags, which can be retrieved as the :" +"attr:`~codeobject.co_flags` Python attribute (for example using :c:func:" +"`PyObject_GetAttrString`), and set using a *flags* argument to :c:func:" +"`PyUnstable_Code_New` and similar functions." +msgstr "" + +#: ../../c-api/code.rst:224 +msgid "" +"Flags whose names start with ``CO_FUTURE_`` correspond to features normally " +"selectable by :ref:`future statements `. These flags can be used in :" +"c:member:`PyCompilerFlags.cf_flags`. Note that many ``CO_FUTURE_`` flags are " +"mandatory in current versions of Python, and setting them has no effect." +msgstr "" + +#: ../../c-api/code.rst:230 +msgid "" +"The following flags are available. For their meaning, see the linked " +"documentation of their Python equivalents." +msgstr "" + +#: ../../c-api/code.rst:238 +msgid "Flag" +msgstr "" + +#: ../../c-api/code.rst:239 +msgid "Meaning" +msgstr "" + +#: ../../c-api/code.rst:241 +msgid ":py:data:`inspect.CO_OPTIMIZED`" +msgstr "" + +#: ../../c-api/code.rst:243 +msgid ":py:data:`inspect.CO_NEWLOCALS`" +msgstr "" + +#: ../../c-api/code.rst:245 +msgid ":py:data:`inspect.CO_VARARGS`" +msgstr "" + +#: ../../c-api/code.rst:247 +msgid ":py:data:`inspect.CO_VARKEYWORDS`" +msgstr "" + +#: ../../c-api/code.rst:249 +msgid ":py:data:`inspect.CO_NESTED`" +msgstr "" + +#: ../../c-api/code.rst:251 +msgid ":py:data:`inspect.CO_GENERATOR`" +msgstr "" + +#: ../../c-api/code.rst:253 +msgid ":py:data:`inspect.CO_COROUTINE`" +msgstr "" + +#: ../../c-api/code.rst:255 +msgid ":py:data:`inspect.CO_ITERABLE_COROUTINE`" +msgstr "" + +#: ../../c-api/code.rst:257 +msgid ":py:data:`inspect.CO_ASYNC_GENERATOR`" +msgstr "" + +#: ../../c-api/code.rst:260 +msgid "no effect (:py:data:`__future__.division`)" +msgstr "" + +#: ../../c-api/code.rst:262 +msgid "no effect (:py:data:`__future__.absolute_import`)" +msgstr "" + +#: ../../c-api/code.rst:264 +msgid "no effect (:py:data:`__future__.with_statement`)" +msgstr "" + +#: ../../c-api/code.rst:266 +msgid "no effect (:py:data:`__future__.print_function`)" +msgstr "" + +#: ../../c-api/code.rst:268 +msgid "no effect (:py:data:`__future__.unicode_literals`)" +msgstr "" + +#: ../../c-api/code.rst:270 +msgid "no effect (:py:data:`__future__.generator_stop`)" +msgstr "" + +#: ../../c-api/code.rst:272 +msgid ":py:data:`__future__.annotations`" +msgstr "" + +#: ../../c-api/code.rst:276 msgid "Extra information" msgstr "" -#: ../../c-api/code.rst:217 +#: ../../c-api/code.rst:278 msgid "" "To support low-level extensions to frame evaluation, such as external just-" "in-time compilers, it is possible to attach arbitrary extra data to code " "objects." msgstr "" -#: ../../c-api/code.rst:221 +#: ../../c-api/code.rst:282 msgid "" "These functions are part of the unstable C API tier: this functionality is a " "CPython implementation detail, and the API may change without deprecation " "warnings." msgstr "" -#: ../../c-api/code.rst:227 +#: ../../c-api/code.rst:288 msgid "Return a new an opaque index value used to adding data to code objects." msgstr "" -#: ../../c-api/code.rst:229 +#: ../../c-api/code.rst:290 msgid "" "You generally call this function once (per interpreter) and use the result " "with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate data on " "individual code objects." msgstr "" -#: ../../c-api/code.rst:233 +#: ../../c-api/code.rst:294 msgid "" "If *free* is not ``NULL``: when a code object is deallocated, *free* will be " "called on non-``NULL`` data stored under the new index. Use :c:func:" "`Py_DecRef` when storing :c:type:`PyObject`." msgstr "" -#: ../../c-api/code.rst:239 +#: ../../c-api/code.rst:300 msgid "as ``_PyEval_RequestCodeExtraIndex``" msgstr "" -#: ../../c-api/code.rst:243 +#: ../../c-api/code.rst:304 msgid "" "Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``. The old private name " "is deprecated, but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:249 +#: ../../c-api/code.rst:310 msgid "" "Set *extra* to the extra data stored under the given index. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" -#: ../../c-api/code.rst:252 +#: ../../c-api/code.rst:313 msgid "" "If no data was set under the index, set *extra* to ``NULL`` and return 0 " "without setting an exception." msgstr "" -#: ../../c-api/code.rst:257 +#: ../../c-api/code.rst:318 msgid "as ``_PyCode_GetExtra``" msgstr "" -#: ../../c-api/code.rst:261 +#: ../../c-api/code.rst:322 msgid "" "Renamed to ``PyUnstable_Code_GetExtra``. The old private name is deprecated, " "but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:267 +#: ../../c-api/code.rst:328 msgid "" "Set the extra data stored under the given index to *extra*. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" -#: ../../c-api/code.rst:272 +#: ../../c-api/code.rst:333 msgid "as ``_PyCode_SetExtra``" msgstr "" -#: ../../c-api/code.rst:276 +#: ../../c-api/code.rst:337 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated, " "but will be available until the API changes." @@ -356,14 +455,14 @@ msgstr "PyCode_New(C 函式)" msgid "PyCode_NewWithPosOnlyArgs (C function)" msgstr "PyCode_NewWithPosOnlyArgs(C 函式)" -#: ../../c-api/code.rst:237 +#: ../../c-api/code.rst:298 msgid "_PyEval_RequestCodeExtraIndex (C function)" msgstr "_PyEval_RequestCodeExtraIndex(C 函式)" -#: ../../c-api/code.rst:255 +#: ../../c-api/code.rst:316 msgid "_PyCode_GetExtra (C function)" msgstr "_PyCode_GetExtra(C 函式)" -#: ../../c-api/code.rst:270 +#: ../../c-api/code.rst:331 msgid "_PyCode_SetExtra (C function)" msgstr "_PyCode_SetExtra(C 函式)" diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index 80cabb8b50..4901187f50 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-22 00:13+0000\n" +"POT-Creation-Date: 2025-08-03 00:19+0000\n" "PO-Revision-Date: 2018-05-23 14:08+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -400,10 +400,12 @@ msgid "" "mod:`!ast` Python module, which exports these constants under the same names." msgstr "" -#: ../../c-api/veryhigh.rst:366 +#: ../../c-api/veryhigh.rst:364 msgid "" -"This bit can be set in *flags* to cause division operator ``/`` to be " -"interpreted as \"true division\" according to :pep:`238`." +"The \"``PyCF``\" flags above can be combined with \"``CO_FUTURE``\" flags " +"such as :c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally " +"selectable using :ref:`future statements `. See :ref:" +"`c_codeobject_flags` for a complete list." msgstr "" #: ../../c-api/veryhigh.rst:301 ../../c-api/veryhigh.rst:309 diff --git a/library/__future__.po b/library/__future__.po index a1267b3397..762845fc30 100644 --- a/library/__future__.po +++ b/library/__future__.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-08-03 00:19+0000\n" "PO-Revision-Date: 2024-02-06 02:12+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -88,157 +88,122 @@ msgstr "" "不會從 :mod:`__future__` 中刪除任何功能描述。自從在 Python 2.1 中引入以來,以" "下功能已透過這種機制引入到該語言中:" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:45 msgid "feature" msgstr "功能" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:46 msgid "optional in" msgstr "可選的版本" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:47 msgid "mandatory in" msgstr "強制性的版本" -#: ../../library/__future__.rst:41 +#: ../../library/__future__.rst:48 msgid "effect" msgstr "影響" -#: ../../library/__future__.rst:43 -msgid "nested_scopes" -msgstr "nested_scopes" - -#: ../../library/__future__.rst:43 +#: ../../library/__future__.rst:50 msgid "2.1.0b1" msgstr "2.1.0b1" -#: ../../library/__future__.rst:43 +#: ../../library/__future__.rst:51 msgid "2.2" msgstr "2.2" -#: ../../library/__future__.rst:43 +#: ../../library/__future__.rst:52 msgid ":pep:`227`: *Statically Nested Scopes*" msgstr ":pep:`227`: *靜態巢狀作用域 (Statically Nested Scopes)*" -#: ../../library/__future__.rst:46 -msgid "generators" -msgstr "generators" - -#: ../../library/__future__.rst:46 +#: ../../library/__future__.rst:54 msgid "2.2.0a1" msgstr "2.2.0a1" -#: ../../library/__future__.rst:46 +#: ../../library/__future__.rst:55 msgid "2.3" msgstr "2.3" -#: ../../library/__future__.rst:46 +#: ../../library/__future__.rst:56 msgid ":pep:`255`: *Simple Generators*" msgstr ":pep:`255`: *簡單產生器 (Simple Generators)*" -#: ../../library/__future__.rst:49 -msgid "division" -msgstr "division" - -#: ../../library/__future__.rst:49 +#: ../../library/__future__.rst:58 msgid "2.2.0a2" msgstr "2.2.0a2" -#: ../../library/__future__.rst:49 ../../library/__future__.rst:52 -#: ../../library/__future__.rst:58 ../../library/__future__.rst:61 +#: ../../library/__future__.rst:59 ../../library/__future__.rst:63 +#: ../../library/__future__.rst:71 ../../library/__future__.rst:75 msgid "3.0" msgstr "3.0" -#: ../../library/__future__.rst:49 +#: ../../library/__future__.rst:60 msgid ":pep:`238`: *Changing the Division Operator*" msgstr ":pep:`238`: *更改除法運算子 (Changing the Division Operator)*" -#: ../../library/__future__.rst:52 -msgid "absolute_import" -msgstr "absolute_import" - -#: ../../library/__future__.rst:52 ../../library/__future__.rst:55 +#: ../../library/__future__.rst:62 ../../library/__future__.rst:66 msgid "2.5.0a1" msgstr "2.5.0a1" -#: ../../library/__future__.rst:52 +#: ../../library/__future__.rst:64 msgid ":pep:`328`: *Imports: Multi-Line and Absolute/Relative*" msgstr "" ":pep:`328`: *引入:多列與絕對/相對 (Imports: Multi-Line and Absolute/" "Relative)*" -#: ../../library/__future__.rst:55 -msgid "with_statement" -msgstr "with_statement" - -#: ../../library/__future__.rst:55 +#: ../../library/__future__.rst:67 msgid "2.6" msgstr "2.6" -#: ../../library/__future__.rst:55 -msgid ":pep:`343`: *The \"with\" Statement*" +#: ../../library/__future__.rst:68 +#, fuzzy +msgid ":pep:`343`: *The “with” Statement*" msgstr ":pep:`343`: *\"with\" 陳述式 (The \"with\" Statement)*" -#: ../../library/__future__.rst:58 -msgid "print_function" -msgstr "print_function" - -#: ../../library/__future__.rst:58 ../../library/__future__.rst:61 +#: ../../library/__future__.rst:70 ../../library/__future__.rst:74 msgid "2.6.0a2" msgstr "2.6.0a2" -#: ../../library/__future__.rst:58 +#: ../../library/__future__.rst:72 msgid ":pep:`3105`: *Make print a function*" msgstr ":pep:`3105`: *使 print 成為一個函式 (Make print a function)*" -#: ../../library/__future__.rst:61 -msgid "unicode_literals" -msgstr "unicode_literals" - -#: ../../library/__future__.rst:61 +#: ../../library/__future__.rst:76 msgid ":pep:`3112`: *Bytes literals in Python 3000*" msgstr "" ":pep:`3112`: *Python 3000 中的位元組字面值 (Bytes literals in Python 3000)*" -#: ../../library/__future__.rst:64 -msgid "generator_stop" -msgstr "generator_stop" - -#: ../../library/__future__.rst:64 +#: ../../library/__future__.rst:78 msgid "3.5.0b1" msgstr "3.5.0b1" -#: ../../library/__future__.rst:64 +#: ../../library/__future__.rst:79 msgid "3.7" msgstr "3.7" -#: ../../library/__future__.rst:64 +#: ../../library/__future__.rst:80 msgid ":pep:`479`: *StopIteration handling inside generators*" msgstr "" ":pep:`479`: *產生器內部的 StopIteration 處理 (StopIteration handling inside " "generators)*" -#: ../../library/__future__.rst:67 -msgid "annotations" -msgstr "annotations" - -#: ../../library/__future__.rst:67 +#: ../../library/__future__.rst:82 msgid "3.7.0b1" msgstr "3.7.0b1" -#: ../../library/__future__.rst:67 -msgid "TBD [1]_" -msgstr "TBD [1]_" +#: ../../library/__future__.rst:83 +msgid "Never [1]_" +msgstr "" -#: ../../library/__future__.rst:67 +#: ../../library/__future__.rst:84 msgid ":pep:`563`: *Postponed evaluation of annotations*" msgstr ":pep:`563`: *推遲對註釋的求值 (Postponed evaluation of annotations)*" -#: ../../library/__future__.rst:77 +#: ../../library/__future__.rst:92 msgid "Each statement in :file:`__future__.py` is of the form::" msgstr ":file:`__future__.py` 中的每個陳述式的形式如下: ::" -#: ../../library/__future__.rst:79 +#: ../../library/__future__.rst:94 msgid "" "FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" " CompilerFlag)" @@ -246,7 +211,7 @@ msgstr "" "FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" " CompilerFlag)" -#: ../../library/__future__.rst:82 +#: ../../library/__future__.rst:97 msgid "" "where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both " "are 5-tuples of the same form as :data:`sys.version_info`::" @@ -254,7 +219,7 @@ msgstr "" "通常,*OptionalRelease* 會小於 *MandatoryRelease*,且兩者都是與 :data:`sys." "version_info` 形式相同的 5 元組 (5-tuple): ::" -#: ../../library/__future__.rst:85 +#: ../../library/__future__.rst:100 msgid "" "(PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int\n" " PY_MINOR_VERSION, # the 1; an int\n" @@ -265,13 +230,13 @@ msgid "" ")" msgstr "" -#: ../../library/__future__.rst:94 +#: ../../library/__future__.rst:109 msgid "" "*OptionalRelease* records the first release in which the feature was " "accepted." msgstr "*OptionalRelease* 記錄該功能首次發布時的 Python 版本。" -#: ../../library/__future__.rst:98 +#: ../../library/__future__.rst:113 msgid "" "In the case of a *MandatoryRelease* that has not yet occurred, " "*MandatoryRelease* predicts the release in which the feature will become " @@ -280,7 +245,7 @@ msgstr "" "如果 *MandatoryRelease* 尚未發布,*MandatoryRelease* 會預測該功能將成為該語言" "一部分的版本。" -#: ../../library/__future__.rst:102 +#: ../../library/__future__.rst:117 msgid "" "Else *MandatoryRelease* records when the feature became part of the " "language; in releases at or after that, modules no longer need a future " @@ -290,7 +255,7 @@ msgstr "" "否則 *MandatoryRelease* 會記錄該功能是何時成為語言的一部分;在該版本或之後的" "版本中,模組不再需要 future 聲明來使用相關功能,但可以繼續使用此種引入方式。" -#: ../../library/__future__.rst:106 +#: ../../library/__future__.rst:121 msgid "" "*MandatoryRelease* may also be ``None``, meaning that a planned feature got " "dropped or that it is not yet decided." @@ -298,7 +263,7 @@ msgstr "" "*MandatoryRelease* 也可能是 ``None``,這意味著計劃中的功能被丟棄或者仍未決" "定。" -#: ../../library/__future__.rst:111 +#: ../../library/__future__.rst:126 msgid "" "*CompilerFlag* is the (bitfield) flag that should be passed in the fourth " "argument to the built-in function :func:`compile` to enable the feature in " @@ -309,7 +274,7 @@ msgstr "" "式 :func:`compile` 以在動態編譯的程式碼中啟用該功能。此旗標儲存在 :class:" "`_Feature` 實例上的 :attr:`_Feature.compiler_flag` 屬性中。" -#: ../../library/__future__.rst:117 +#: ../../library/__future__.rst:132 msgid "" "``from __future__ import annotations`` was previously scheduled to become " "mandatory in Python 3.10, but the Python Steering Council twice decided to " @@ -327,18 +292,48 @@ msgstr "" "VIZEBX5EYMSYIJNDBF6DMUMZOCWHARSO/>`__)。目前還尚未做出決定。另請參閱 :pep:" "`563` 和 :pep:`649`。" -#: ../../library/__future__.rst:127 +#: ../../library/__future__.rst:142 msgid ":ref:`future`" msgstr ":ref:`future`" -#: ../../library/__future__.rst:128 +#: ../../library/__future__.rst:143 msgid "How the compiler treats future imports." msgstr "編譯器如何處理 future 引入。" -#: ../../library/__future__.rst:130 +#: ../../library/__future__.rst:145 msgid ":pep:`236` - Back to the __future__" msgstr ":pep:`236` - 回到 __future__" -#: ../../library/__future__.rst:131 +#: ../../library/__future__.rst:146 msgid "The original proposal for the __future__ mechanism." msgstr "__future__ 機制的原始提案。" + +#~ msgid "nested_scopes" +#~ msgstr "nested_scopes" + +#~ msgid "generators" +#~ msgstr "generators" + +#~ msgid "division" +#~ msgstr "division" + +#~ msgid "absolute_import" +#~ msgstr "absolute_import" + +#~ msgid "with_statement" +#~ msgstr "with_statement" + +#~ msgid "print_function" +#~ msgstr "print_function" + +#~ msgid "unicode_literals" +#~ msgstr "unicode_literals" + +#~ msgid "generator_stop" +#~ msgstr "generator_stop" + +#~ msgid "annotations" +#~ msgstr "annotations" + +#~ msgid "TBD [1]_" +#~ msgstr "TBD [1]_" From 7165835b4fecfb0a3b4f3113d20f50afb74be9ef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 4 Aug 2025 00:20:45 +0000 Subject: [PATCH 05/13] sync with cpython d29a9c55 --- library/urllib.request.po | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/urllib.request.po b/library/urllib.request.po index 93b77f5e59..fc66a11e9c 100644 --- a/library/urllib.request.po +++ b/library/urllib.request.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-23 00:17+0000\n" +"POT-Creation-Date: 2025-08-04 00:19+0000\n" "PO-Revision-Date: 2022-04-21 17:59+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1095,7 +1095,8 @@ msgid "the three-digit code of the error, as a string," msgstr "HTTP 錯誤的三位數代號字串," #: ../../library/urllib.request.rst:792 -msgid "the user-visible explanation of the code, as as string, and" +#, fuzzy +msgid "the user-visible explanation of the code, as a string, and" msgstr "HTTP 錯誤代號的使用者可見解釋字串,以及" #: ../../library/urllib.request.rst:793 From 1ac1d35b62bbb675bd893f58e790e05256fcb060 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 6 Aug 2025 00:19:14 +0000 Subject: [PATCH 06/13] sync with cpython 3a61ddf2 --- extending/extending.po | 504 ++++++++++++++++++-------------- glossary.po | 632 +++++++++++++++++++++-------------------- library/codecs.po | 8 +- library/fractions.po | 112 ++++---- library/numbers.po | 17 +- 5 files changed, 697 insertions(+), 576 deletions(-) diff --git a/extending/extending.po b/extending/extending.po index df2ba80946..9818750cbd 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2025-02-17 14:34+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -113,7 +113,7 @@ msgstr "" msgid "The first two lines of our file can be::" msgstr "我們檔案的前兩列可以為: ::" -#: ../../extending/extending.rst:60 ../../extending/extending.rst:681 +#: ../../extending/extending.rst:60 ../../extending/extending.rst:706 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include " @@ -152,21 +152,86 @@ msgstr "" #: ../../extending/extending.rst:77 msgid "" "All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` " -"or ``PY``, except those defined in standard header files. For convenience, " -"and since they are used extensively by the Python interpreter, ``\"Python." -"h\"`` includes a few standard header files: ````, ````, " -"````, and ````. If the latter header file does not exist " -"on your system, it declares the functions :c:func:`malloc`, :c:func:`free` " -"and :c:func:`realloc` directly." -msgstr "" -"除了那些在標準標頭檔中定義的符號以外,所有由 :file:`Python.h` 定義的使用者可" -"見符號 (user-visible symbols) 的前綴都是 ``Py`` 或 ``PY``。為了方便,也因為 " -"Python 直譯器的大量使用,``\"Python.h\"`` 也引入了一些標準的標頭檔:````、````、```` 和 ````。如果 ```` 在" -"你的系統上不存在,它會直接宣告 :c:func:`malloc`、:c:func:`free` 和 :c:func:" -"`realloc` 函式。" - -#: ../../extending/extending.rst:85 +"or ``PY``, except those defined in standard header files." +msgstr "" + +#: ../../extending/extending.rst:82 +msgid "" +"For backward compatibility, :file:`Python.h` includes several standard " +"header files. C extensions should include the standard headers that they " +"use, and should not rely on these implicit includes. If using the limited C " +"API version 3.13 or newer, the implicit includes are:" +msgstr "" + +#: ../../extending/extending.rst:87 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:88 +msgid "```` (on Windows)" +msgstr "" + +#: ../../extending/extending.rst:89 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:90 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:91 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:92 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:93 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:94 +msgid "```` (if present)" +msgstr "" + +#: ../../extending/extending.rst:96 +msgid "" +"If :c:macro:`Py_LIMITED_API` is not defined, or is set to version 3.12 or " +"older, the headers below are also included:" +msgstr "" + +#: ../../extending/extending.rst:99 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:100 +msgid "```` (on POSIX)" +msgstr "" + +#: ../../extending/extending.rst:102 +msgid "" +"If :c:macro:`Py_LIMITED_API` is not defined, or is set to version 3.10 or " +"older, the headers below are also included:" +msgstr "" + +#: ../../extending/extending.rst:105 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:106 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:107 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:108 +msgid "````" +msgstr "" + +#: ../../extending/extending.rst:110 msgid "" "The next thing we add to our module file is the C function that will be " "called when the Python expression ``spam.system(string)`` is evaluated " @@ -176,7 +241,7 @@ msgstr "" "system(string)`` 要被求值 (evaluated) 時就會被呼叫(我們很快就會看到它最後是" "如何被呼叫的): ::" -#: ../../extending/extending.rst:89 +#: ../../extending/extending.rst:114 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -202,7 +267,7 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:101 +#: ../../extending/extending.rst:126 msgid "" "There is a straightforward translation from the argument list in Python (for " "example, the single expression ``\"ls -l\"``) to the arguments passed to the " @@ -212,7 +277,7 @@ msgstr "" "可以很直觀地從 Python 的引數串列(例如單一的運算式 ``\"ls -l\"``)直接轉換成" "傳給 C 函式的引數。C 函式總是有兩個引數,習慣上會命名為 *self* 和 *args*。" -#: ../../extending/extending.rst:106 +#: ../../extending/extending.rst:131 msgid "" "The *self* argument points to the module object for module-level functions; " "for a method it would point to the object instance." @@ -220,7 +285,7 @@ msgstr "" "對於模組層級的函式,*self* 引數會指向模組物件;而對於方法來說則是指向物件的實" "例。" -#: ../../extending/extending.rst:109 +#: ../../extending/extending.rst:134 msgid "" "The *args* argument will be a pointer to a Python tuple object containing " "the arguments. Each item of the tuple corresponds to an argument in the " @@ -237,7 +302,7 @@ msgstr "" "`PyArg_ParseTuple` 函式能夠檢查引數型別並將他們轉換為 C 值。它使用模板字串來" "決定所需的引數型別以及儲存轉換值的 C 變數型別。稍後會再詳細說明。" -#: ../../extending/extending.rst:118 +#: ../../extending/extending.rst:143 msgid "" ":c:func:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the " "right type and its components have been stored in the variables whose " @@ -251,11 +316,11 @@ msgstr "" "(零)。在後者情況下,它也會產生適當的例外,因此呼叫函式可以立即回傳 " "``NULL``\\ (就像我們在範例中所看到的)。" -#: ../../extending/extending.rst:128 +#: ../../extending/extending.rst:153 msgid "Intermezzo: Errors and Exceptions" msgstr "插曲:錯誤與例外" -#: ../../extending/extending.rst:130 +#: ../../extending/extending.rst:155 msgid "" "An important convention throughout the Python interpreter is the following: " "when a function fails, it should set an exception condition and return an " @@ -272,13 +337,13 @@ msgstr "" "們是由 :meth:`sys.exc_info` 所回傳的 Python 元組中的 C 等效元組。它們是例外型" "別、例外實例和回溯物件。了解它們對於理解錯誤是如何傳遞是很重要的。" -#: ../../extending/extending.rst:139 +#: ../../extending/extending.rst:164 msgid "" "The Python API defines a number of functions to set various types of " "exceptions." msgstr "Python API 定義了許多能夠設定各種類型例外的函式。" -#: ../../extending/extending.rst:141 +#: ../../extending/extending.rst:166 msgid "" "The most common one is :c:func:`PyErr_SetString`. Its arguments are an " "exception object and a C string. The exception object is usually a " @@ -291,7 +356,7 @@ msgstr "" "指出錯誤的原因,並被轉換為 Python 字串物件且被儲存為例外的「關聯值 " "(associated value)」。" -#: ../../extending/extending.rst:147 +#: ../../extending/extending.rst:172 msgid "" "Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an " "exception argument and constructs the associated value by inspection of the " @@ -305,7 +370,7 @@ msgstr "" "`PyErr_SetObject`,它接受兩個物件引數,即例外和它的關聯值。你不需要對傳給任何" "這些函式的物件呼叫 :c:func:`Py_INCREF`。" -#: ../../extending/extending.rst:154 +#: ../../extending/extending.rst:179 msgid "" "You can test non-destructively whether an exception has been set with :c:" "func:`PyErr_Occurred`. This returns the current exception object, or " @@ -317,7 +382,7 @@ msgstr "" "回傳目前的例外物件,如果沒有例外發生則回傳 ``NULL``。你通常不需要呼叫 :c:" "func:`PyErr_Occurred` 來查看函式呼叫是否發生錯誤,因為你應可從回傳值就得知。" -#: ../../extending/extending.rst:160 +#: ../../extending/extending.rst:185 msgid "" "When a function *f* that calls another function *g* detects that the latter " "fails, *f* should itself return an error value (usually ``NULL`` or " @@ -336,7 +401,7 @@ msgstr "" "首先檢測到它的函式回報了。一旦錯誤到達 Python 直譯器的主要迴圈,這會中止目前" "執行的 Python 程式碼,並嘗試尋找 Python 程式設計者指定的例外處理程式。" -#: ../../extending/extending.rst:170 +#: ../../extending/extending.rst:195 msgid "" "(There are situations where a module can actually give a more detailed error " "message by calling another ``PyErr_*`` function, and in such cases it is " @@ -348,7 +413,7 @@ msgstr "" "息,在這種情況下這樣做是沒問題的。然而這一般來說並非必要,而且可能會導致錯誤" "原因資訊的遺失:大多數的操作都可能因為各種原因而失敗。)" -#: ../../extending/extending.rst:176 +#: ../../extending/extending.rst:201 msgid "" "To ignore an exception set by a function call that failed, the exception " "condition must be cleared explicitly by calling :c:func:`PyErr_Clear`. The " @@ -361,7 +426,7 @@ msgstr "" "給直譯器而想要完全是自己來處理它時(可能是要再嘗試其他東西,或者假裝什麼都沒" "出錯)。" -#: ../../extending/extending.rst:182 +#: ../../extending/extending.rst:207 msgid "" "Every failing :c:func:`malloc` call must be turned into an exception --- the " "direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call :c:func:" @@ -375,7 +440,7 @@ msgstr "" "`PyLong_FromLong`)都已經這麼做了,所以這個注意事項只和那些直接呼叫 :c:func:" "`malloc` 的函式有關。" -#: ../../extending/extending.rst:188 +#: ../../extending/extending.rst:213 msgid "" "Also note that, with the important exception of :c:func:`PyArg_ParseTuple` " "and friends, functions that return an integer status usually return a " @@ -386,7 +451,7 @@ msgstr "" "整數狀態的函式通常會回傳一個正值或 0 表示成功、回傳 ``-1`` 表示失敗,就像 " "Unix 系統呼叫一樣。" -#: ../../extending/extending.rst:192 +#: ../../extending/extending.rst:217 msgid "" "Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or :" "c:func:`Py_DECREF` calls for objects you have already created) when you " @@ -395,7 +460,7 @@ msgstr "" "最後,在回傳錯誤指示器時要注意垃圾清理(透過對你已經建立的物件呼叫 :c:func:" "`Py_XDECREF` 或 :c:func:`Py_DECREF`)!" -#: ../../extending/extending.rst:196 +#: ../../extending/extending.rst:221 msgid "" "The choice of which exception to raise is entirely yours. There are " "predeclared C objects corresponding to all built-in Python exceptions, such " @@ -415,42 +480,43 @@ msgstr "" "的值必須在一個特定的範圍內或必須滿足其他條件,則可以使用 :c:data:" "`PyExc_ValueError`。" -#: ../../extending/extending.rst:206 +#: ../../extending/extending.rst:231 msgid "" "You can also define a new exception that is unique to your module. The " "simplest way to do this is to declare a static global object variable at the " "beginning of the file::" msgstr "" -"你也可以定義一個你的模組特有的新例外。最簡單的方式是在檔案的開頭宣告一個靜態全域物件變數: ::" +"你也可以定義一個你的模組特有的新例外。最簡單的方式是在檔案的開頭宣告一個靜態" +"全域物件變數: ::" -#: ../../extending/extending.rst:210 +#: ../../extending/extending.rst:235 msgid "static PyObject *SpamError = NULL;" msgstr "static PyObject *SpamError = NULL;" -#: ../../extending/extending.rst:212 +#: ../../extending/extending.rst:237 msgid "" "and initialize it by calling :c:func:`PyErr_NewException` in the module's :c:" "data:`Py_mod_exec` function (:c:func:`!spam_module_exec`)::" msgstr "" -#: ../../extending/extending.rst:215 +#: ../../extending/extending.rst:240 msgid "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" msgstr "" -#: ../../extending/extending.rst:217 +#: ../../extending/extending.rst:242 msgid "" "Since :c:data:`!SpamError` is a global variable, it will be overwitten every " "time the module is reinitialized, when the :c:data:`Py_mod_exec` function is " "called." msgstr "" -#: ../../extending/extending.rst:220 +#: ../../extending/extending.rst:245 msgid "" "For now, let's avoid the issue: we will block repeated initialization by " "raising an :py:exc:`ImportError`::" msgstr "" -#: ../../extending/extending.rst:223 +#: ../../extending/extending.rst:248 msgid "" "static PyObject *SpamError = NULL;\n" "\n" @@ -489,7 +555,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:259 +#: ../../extending/extending.rst:284 msgid "" "Note that the Python name for the exception object is :exc:`!spam.error`. " "The :c:func:`PyErr_NewException` function may create a class with the base " @@ -500,7 +566,7 @@ msgstr "" "exceptions`\\ 所述,:c:func:`PyErr_NewException` 函式可能會建立一個基底類別" "為 :exc:`Exception` 的類別(除非傳入另一個類別來代替 ``NULL``)。" -#: ../../extending/extending.rst:264 +#: ../../extending/extending.rst:289 msgid "" "Note also that the :c:data:`!SpamError` variable retains a reference to the " "newly created exception class; this is intentional! Since the exception " @@ -516,7 +582,7 @@ msgstr "" "如果它變成迷途指標,那產生例外的 C 程式碼可能會導致核心轉儲 (core dump) 或其" "他不預期的 side effect。" -#: ../../extending/extending.rst:271 +#: ../../extending/extending.rst:296 msgid "" "For now, the :c:func:`Py_DECREF` call to remove this reference is missing. " "Even when the Python interpreter shuts down, the global :c:data:`!SpamError` " @@ -524,13 +590,13 @@ msgid "" "ensure that this will happen at most once per process." msgstr "" -#: ../../extending/extending.rst:276 +#: ../../extending/extending.rst:301 msgid "" "We discuss the use of :c:macro:`PyMODINIT_FUNC` as a function return type " "later in this sample." msgstr "我們稍後會討論 :c:macro:`PyMODINIT_FUNC` 作為函式回傳型別的用法。" -#: ../../extending/extending.rst:279 +#: ../../extending/extending.rst:304 msgid "" "The :exc:`!spam.error` exception can be raised in your extension module " "using a call to :c:func:`PyErr_SetString` as shown below::" @@ -538,7 +604,7 @@ msgstr "" "可以在你的擴充模組中呼叫 :c:func:`PyErr_SetString` 來引發 :exc:`!spam.error` " "例外,如下所示: ::" -#: ../../extending/extending.rst:282 +#: ../../extending/extending.rst:307 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -572,17 +638,17 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:302 +#: ../../extending/extending.rst:327 msgid "Back to the Example" msgstr "回到範例" -#: ../../extending/extending.rst:304 +#: ../../extending/extending.rst:329 msgid "" "Going back to our example function, you should now be able to understand " "this statement::" msgstr "回到我們的範例函式,現在你應該可以理解這個陳述式了: ::" -#: ../../extending/extending.rst:307 +#: ../../extending/extending.rst:332 msgid "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" @@ -590,7 +656,7 @@ msgstr "" "if (!PyArg_ParseTuple(args, \"s\", &command))\n" " return NULL;" -#: ../../extending/extending.rst:310 +#: ../../extending/extending.rst:335 msgid "" "It returns ``NULL`` (the error indicator for functions returning object " "pointers) if an error is detected in the argument list, relying on the " @@ -606,7 +672,7 @@ msgstr "" "的字串(所以在標準 C 中,:c:data:`!command` 變數應該正確地被宣告為 ``const " "char *command``)。" -#: ../../extending/extending.rst:318 +#: ../../extending/extending.rst:343 msgid "" "The next statement is a call to the Unix function :c:func:`system`, passing " "it the string we just got from :c:func:`PyArg_ParseTuple`::" @@ -614,11 +680,11 @@ msgstr "" "接下來的陳述式會呼叫 Unix 函式 :c:func:`system`,並將剛才從 :c:func:" "`PyArg_ParseTuple` 得到的字串傳給它:" -#: ../../extending/extending.rst:321 +#: ../../extending/extending.rst:346 msgid "sts = system(command);" msgstr "sts = system(command);" -#: ../../extending/extending.rst:323 +#: ../../extending/extending.rst:348 msgid "" "Our :func:`!spam.system` function must return the value of :c:data:`!sts` as " "a Python object. This is done using the function :c:func:" @@ -627,11 +693,11 @@ msgstr "" "我們的 :func:`!spam.system` 函式必須以 Python 物件的形式來回傳 :c:data:`!" "sts` 的值。這是透過 :c:func:`PyLong_FromLong` 函式來達成。 ::" -#: ../../extending/extending.rst:326 +#: ../../extending/extending.rst:351 msgid "return PyLong_FromLong(sts);" msgstr "return PyLong_FromLong(sts);" -#: ../../extending/extending.rst:328 +#: ../../extending/extending.rst:353 msgid "" "In this case, it will return an integer object. (Yes, even integers are " "objects on the heap in Python!)" @@ -639,7 +705,7 @@ msgstr "" "在這種情況下它會回傳一個整數物件。(是的,在 Python 中連整數也是堆積 (heap) 上" "的物件!)" -#: ../../extending/extending.rst:331 +#: ../../extending/extending.rst:356 msgid "" "If you have a C function that returns no useful argument (a function " "returning :c:expr:`void`), the corresponding Python function must return " @@ -650,7 +716,7 @@ msgstr "" "應的 Python 函式必須回傳 ``None``。你需要以下這個慣例來達成(由 :c:macro:" "`Py_RETURN_NONE` 巨集實作): ::" -#: ../../extending/extending.rst:336 +#: ../../extending/extending.rst:361 msgid "" "Py_INCREF(Py_None);\n" "return Py_None;" @@ -658,7 +724,7 @@ msgstr "" "Py_INCREF(Py_None);\n" "return Py_None;" -#: ../../extending/extending.rst:339 +#: ../../extending/extending.rst:364 msgid "" ":c:data:`Py_None` is the C name for the special Python object ``None``. It " "is a genuine Python object rather than a ``NULL`` pointer, which means " @@ -668,11 +734,11 @@ msgstr "" "Python 物件而不是一個 ``NULL`` 指標,在大多數的情況下它的意思是「錯誤」,如我" "們所見過的那樣。" -#: ../../extending/extending.rst:347 +#: ../../extending/extending.rst:372 msgid "The Module's Method Table and Initialization Function" msgstr "模組的方法表和初始化函式" -#: ../../extending/extending.rst:349 +#: ../../extending/extending.rst:374 msgid "" "I promised to show how :c:func:`!spam_system` is called from Python " "programs. First, we need to list its name and address in a \"method table\"::" @@ -680,7 +746,7 @@ msgstr "" "我承諾過要展示 :c:func:`!spam_system` 是如何從 Python 程式中呼叫的。首先,我" "們需要在「方法表」中列出它的名稱和位址: ::" -#: ../../extending/extending.rst:352 +#: ../../extending/extending.rst:377 msgid "" "static PyMethodDef spam_methods[] = {\n" " ...\n" @@ -698,7 +764,7 @@ msgstr "" " {NULL, NULL, 0, NULL} /* Sentinel */\n" "};" -#: ../../extending/extending.rst:360 +#: ../../extending/extending.rst:385 msgid "" "Note the third entry (``METH_VARARGS``). This is a flag telling the " "interpreter the calling convention to be used for the C function. It should " @@ -710,7 +776,7 @@ msgstr "" "標。通常應該是 ``METH_VARARGS`` 或 ``METH_VARARGS | METH_KEYWORDS``;``0`` 表" "示是使用 :c:func:`PyArg_ParseTuple` 的一個過時變體。" -#: ../../extending/extending.rst:365 +#: ../../extending/extending.rst:390 msgid "" "When using only ``METH_VARARGS``, the function should expect the Python-" "level parameters to be passed in as a tuple acceptable for parsing via :c:" @@ -720,7 +786,7 @@ msgstr "" "能夠接受以 :c:func:`PyArg_ParseTuple` 進行剖析;有關此函式的更多資訊將在下面" "提供。" -#: ../../extending/extending.rst:369 +#: ../../extending/extending.rst:394 msgid "" "The :c:macro:`METH_KEYWORDS` bit may be set in the third field if keyword " "arguments should be passed to the function. In this case, the C function " @@ -733,12 +799,12 @@ msgstr "" "是關鍵字的字典。可使用 :c:func:`PyArg_ParseTupleAndKeywords` 來剖析這種函式的" "引數。" -#: ../../extending/extending.rst:375 +#: ../../extending/extending.rst:400 msgid "" "The method table must be referenced in the module definition structure::" msgstr "方法表必須在模組定義結構中被參照: ::" -#: ../../extending/extending.rst:377 +#: ../../extending/extending.rst:402 msgid "" "static struct PyModuleDef spam_module = {\n" " ...\n" @@ -747,7 +813,7 @@ msgid "" "};" msgstr "" -#: ../../extending/extending.rst:383 +#: ../../extending/extending.rst:408 msgid "" "This structure, in turn, must be passed to the interpreter in the module's " "initialization function. The initialization function must be named :c:func:" @@ -758,7 +824,7 @@ msgstr "" "為 :c:func:`!PyInit_name`,其中 *name* 是模組的名稱,且應該是模組檔案中唯一定" "義的非「靜態 (``static``)」項目: ::" -#: ../../extending/extending.rst:388 +#: ../../extending/extending.rst:413 msgid "" "PyMODINIT_FUNC\n" "PyInit_spam(void)\n" @@ -772,7 +838,7 @@ msgstr "" " return PyModuleDef_Init(&spam_module);\n" "}" -#: ../../extending/extending.rst:394 +#: ../../extending/extending.rst:419 msgid "" "Note that :c:macro:`PyMODINIT_FUNC` declares the function as ``PyObject *`` " "return type, declares any special linkage declarations required by the " @@ -781,7 +847,7 @@ msgstr "" "請注意,:c:macro:`PyMODINIT_FUNC` 宣告函式的回傳型別為 ``PyObject *``、宣告平" "台所需的任何特殊連結宣告、並針對 C++ 宣告函式為 ``extern \"C\"``。" -#: ../../extending/extending.rst:398 +#: ../../extending/extending.rst:423 msgid "" ":c:func:`!PyInit_spam` is called when each interpreter imports its module :" "mod:`!spam` for the first time. (See below for comments about embedding " @@ -790,7 +856,7 @@ msgid "" "store it in ``sys.modules``." msgstr "" -#: ../../extending/extending.rst:403 +#: ../../extending/extending.rst:428 msgid "" "When embedding Python, the :c:func:`!PyInit_spam` function is not called " "automatically unless there's an entry in the :c:data:`PyImport_Inittab` " @@ -801,7 +867,7 @@ msgstr "" "動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使用 :c:func:" "`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" -#: ../../extending/extending.rst:408 +#: ../../extending/extending.rst:433 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -903,7 +969,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../extending/extending.rst:458 +#: ../../extending/extending.rst:483 msgid "" "If you declare a global variable or a local static one, the module may " "experience unintended side-effects on re-initialisation, for example when " @@ -915,7 +981,7 @@ msgid "" "`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)." msgstr "" -#: ../../extending/extending.rst:467 +#: ../../extending/extending.rst:492 msgid "" "A more substantial example module is included in the Python source " "distribution as :file:`Modules/xxlimited.c`. This file may be used as a " @@ -924,11 +990,11 @@ msgstr "" "Python 原始碼發行版本中包含了一個更實質的範例模組 :file:`Modules/xxlimited." "c`。這個檔案可以當作模板使用,也可以簡單地當作範例來閱讀。" -#: ../../extending/extending.rst:475 +#: ../../extending/extending.rst:500 msgid "Compilation and Linkage" msgstr "" -#: ../../extending/extending.rst:477 +#: ../../extending/extending.rst:502 msgid "" "There are two more things to do before you can use your new extension: " "compiling and linking it with the Python system. If you use dynamic " @@ -938,7 +1004,7 @@ msgid "" "Windows (chapter :ref:`building-on-windows`) for more information about this." msgstr "" -#: ../../extending/extending.rst:484 +#: ../../extending/extending.rst:509 msgid "" "If you can't use dynamic loading, or if you want to make your module a " "permanent part of the Python interpreter, you will have to change the " @@ -948,11 +1014,11 @@ msgid "" "line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" -#: ../../extending/extending.rst:491 +#: ../../extending/extending.rst:516 msgid "spam spammodule.o" msgstr "spam spammodule.o" -#: ../../extending/extending.rst:495 +#: ../../extending/extending.rst:520 msgid "" "and rebuild the interpreter by running :program:`make` in the toplevel " "directory. You can also run :program:`make` in the :file:`Modules/` " @@ -961,21 +1027,21 @@ msgid "" "the :file:`Setup` file.)" msgstr "" -#: ../../extending/extending.rst:501 +#: ../../extending/extending.rst:526 msgid "" "If your module requires additional libraries to link with, these can be " "listed on the line in the configuration file as well, for instance:" msgstr "" -#: ../../extending/extending.rst:504 +#: ../../extending/extending.rst:529 msgid "spam spammodule.o -lX11" msgstr "spam spammodule.o -lX11" -#: ../../extending/extending.rst:512 +#: ../../extending/extending.rst:537 msgid "Calling Python Functions from C" msgstr "" -#: ../../extending/extending.rst:514 +#: ../../extending/extending.rst:539 msgid "" "So far we have concentrated on making C functions callable from Python. The " "reverse is also useful: calling Python functions from C. This is especially " @@ -986,7 +1052,7 @@ msgid "" "uses are also imaginable." msgstr "" -#: ../../extending/extending.rst:522 +#: ../../extending/extending.rst:547 msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (I won't dwell on how to " @@ -995,7 +1061,7 @@ msgid "" "line option in :file:`Modules/main.c` from the Python source code.)" msgstr "" -#: ../../extending/extending.rst:528 +#: ../../extending/extending.rst:553 msgid "" "Calling a Python function is easy. First, the Python program must somehow " "pass you the Python function object. You should provide a function (or some " @@ -1005,7 +1071,7 @@ msgid "" "function might be part of a module definition::" msgstr "" -#: ../../extending/extending.rst:535 +#: ../../extending/extending.rst:560 msgid "" "static PyObject *my_callback = NULL;\n" "\n" @@ -1032,7 +1098,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:558 +#: ../../extending/extending.rst:583 msgid "" "This function must be registered with the interpreter using the :c:macro:" "`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The :" @@ -1040,7 +1106,7 @@ msgid "" "section :ref:`parsetuple`." msgstr "" -#: ../../extending/extending.rst:563 +#: ../../extending/extending.rst:588 msgid "" "The macros :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` increment/decrement " "the reference count of an object and are safe in the presence of ``NULL`` " @@ -1048,7 +1114,7 @@ msgid "" "info on them in section :ref:`refcounts`." msgstr "" -#: ../../extending/extending.rst:570 +#: ../../extending/extending.rst:595 msgid "" "Later, when it is time to call the function, you call the C function :c:func:" "`PyObject_CallObject`. This function has two arguments, both pointers to " @@ -1060,7 +1126,7 @@ msgid "" "or more format codes between parentheses. For example::" msgstr "" -#: ../../extending/extending.rst:579 +#: ../../extending/extending.rst:604 msgid "" "int arg;\n" "PyObject *arglist;\n" @@ -1074,7 +1140,7 @@ msgid "" "Py_DECREF(arglist);" msgstr "" -#: ../../extending/extending.rst:590 +#: ../../extending/extending.rst:615 msgid "" ":c:func:`PyObject_CallObject` returns a Python object pointer: this is the " "return value of the Python function. :c:func:`PyObject_CallObject` is " @@ -1083,7 +1149,7 @@ msgid "" "`Py_DECREF`\\ -ed immediately after the :c:func:`PyObject_CallObject` call." msgstr "" -#: ../../extending/extending.rst:597 +#: ../../extending/extending.rst:622 msgid "" "The return value of :c:func:`PyObject_CallObject` is \"new\": either it is a " "brand new object, or it is an existing object whose reference count has been " @@ -1092,7 +1158,7 @@ msgid "" "not interested in its value." msgstr "" -#: ../../extending/extending.rst:603 +#: ../../extending/extending.rst:628 msgid "" "Before you do this, however, it is important to check that the return value " "isn't ``NULL``. If it is, the Python function terminated by raising an " @@ -1103,7 +1169,7 @@ msgid "" "should be cleared by calling :c:func:`PyErr_Clear`. For example::" msgstr "" -#: ../../extending/extending.rst:611 +#: ../../extending/extending.rst:636 msgid "" "if (result == NULL)\n" " return NULL; /* Pass error back */\n" @@ -1111,7 +1177,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:616 +#: ../../extending/extending.rst:641 msgid "" "Depending on the desired interface to the Python callback function, you may " "also have to provide an argument list to :c:func:`PyObject_CallObject`. In " @@ -1123,7 +1189,7 @@ msgid "" "you want to pass an integral event code, you might use the following code::" msgstr "" -#: ../../extending/extending.rst:625 +#: ../../extending/extending.rst:650 msgid "" "PyObject *arglist;\n" "...\n" @@ -1136,7 +1202,7 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:635 +#: ../../extending/extending.rst:660 msgid "" "Note the placement of ``Py_DECREF(arglist)`` immediately after the call, " "before the error check! Also note that strictly speaking this code is not " @@ -1144,14 +1210,14 @@ msgid "" "checked." msgstr "" -#: ../../extending/extending.rst:639 +#: ../../extending/extending.rst:664 msgid "" "You may also call a function with keyword arguments by using :c:func:" "`PyObject_Call`, which supports arguments and keyword arguments. As in the " "above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::" msgstr "" -#: ../../extending/extending.rst:643 +#: ../../extending/extending.rst:668 msgid "" "PyObject *dict;\n" "...\n" @@ -1164,19 +1230,19 @@ msgid "" "Py_DECREF(result);" msgstr "" -#: ../../extending/extending.rst:657 +#: ../../extending/extending.rst:682 msgid "Extracting Parameters in Extension Functions" msgstr "" -#: ../../extending/extending.rst:661 +#: ../../extending/extending.rst:686 msgid "The :c:func:`PyArg_ParseTuple` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:663 +#: ../../extending/extending.rst:688 msgid "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" msgstr "" -#: ../../extending/extending.rst:665 +#: ../../extending/extending.rst:690 msgid "" "The *arg* argument must be a tuple object containing an argument list passed " "from Python to a C function. The *format* argument must be a format string, " @@ -1185,7 +1251,7 @@ msgid "" "whose type is determined by the format string." msgstr "" -#: ../../extending/extending.rst:671 +#: ../../extending/extending.rst:696 msgid "" "Note that while :c:func:`PyArg_ParseTuple` checks that the Python arguments " "have the required types, it cannot check the validity of the addresses of C " @@ -1193,17 +1259,17 @@ msgid "" "probably crash or at least overwrite random bits in memory. So be careful!" msgstr "" -#: ../../extending/extending.rst:676 +#: ../../extending/extending.rst:701 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not decrement their reference count!" msgstr "" -#: ../../extending/extending.rst:679 +#: ../../extending/extending.rst:704 msgid "Some example calls::" msgstr "一些呼叫範例: ::" -#: ../../extending/extending.rst:686 +#: ../../extending/extending.rst:711 msgid "" "int ok;\n" "int i, j;\n" @@ -1223,27 +1289,27 @@ msgstr "" "ok = PyArg_ParseTuple(args, \"\"); /* 沒有引數 */\n" " /* Python 呼叫:f() */" -#: ../../extending/extending.rst:697 +#: ../../extending/extending.rst:722 msgid "" "ok = PyArg_ParseTuple(args, \"s\", &s); /* A string */\n" " /* Possible Python call: f('whoops!') */" msgstr "" -#: ../../extending/extending.rst:702 +#: ../../extending/extending.rst:727 msgid "" "ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* Two longs and a string " "*/\n" " /* Possible Python call: f(1, 2, 'three') */" msgstr "" -#: ../../extending/extending.rst:707 +#: ../../extending/extending.rst:732 msgid "" "ok = PyArg_ParseTuple(args, \"(ii)s#\", &i, &j, &s, &size);\n" " /* A pair of ints and a string, whose size is also returned */\n" " /* Possible Python call: f((1, 2), 'three') */" msgstr "" -#: ../../extending/extending.rst:713 +#: ../../extending/extending.rst:738 msgid "" "{\n" " const char *file;\n" @@ -1258,7 +1324,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:727 +#: ../../extending/extending.rst:752 msgid "" "{\n" " int left, top, right, bottom, h, v;\n" @@ -1270,7 +1336,7 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:738 +#: ../../extending/extending.rst:763 msgid "" "{\n" " Py_complex c;\n" @@ -1280,16 +1346,16 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:749 +#: ../../extending/extending.rst:774 msgid "Keyword Parameters for Extension Functions" msgstr "" -#: ../../extending/extending.rst:753 +#: ../../extending/extending.rst:778 msgid "" "The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::" msgstr "" -#: ../../extending/extending.rst:755 +#: ../../extending/extending.rst:780 msgid "" "int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" " const char *format, char * const " @@ -1299,7 +1365,7 @@ msgstr "" " const char *format, char * const " "*kwlist, ...);" -#: ../../extending/extending.rst:758 +#: ../../extending/extending.rst:783 msgid "" "The *arg* and *format* parameters are identical to those of the :c:func:" "`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of " @@ -1311,20 +1377,20 @@ msgid "" "raises an appropriate exception." msgstr "" -#: ../../extending/extending.rst:768 +#: ../../extending/extending.rst:793 msgid "" "Nested tuples cannot be parsed when using keyword arguments! Keyword " "parameters passed in which are not present in the *kwlist* will cause :exc:" "`TypeError` to be raised." msgstr "" -#: ../../extending/extending.rst:774 +#: ../../extending/extending.rst:799 msgid "" "Here is an example module which uses keywords, based on an example by Geoff " "Philbrick (philbrick@hks.com)::" msgstr "" -#: ../../extending/extending.rst:777 +#: ../../extending/extending.rst:802 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1377,21 +1443,21 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:828 +#: ../../extending/extending.rst:853 msgid "Building Arbitrary Values" msgstr "" -#: ../../extending/extending.rst:830 +#: ../../extending/extending.rst:855 msgid "" "This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is " "declared as follows::" msgstr "" -#: ../../extending/extending.rst:833 +#: ../../extending/extending.rst:858 msgid "PyObject *Py_BuildValue(const char *format, ...);" msgstr "PyObject *Py_BuildValue(const char *format, ...);" -#: ../../extending/extending.rst:835 +#: ../../extending/extending.rst:860 msgid "" "It recognizes a set of format units similar to the ones recognized by :c:" "func:`PyArg_ParseTuple`, but the arguments (which are input to the function, " @@ -1399,7 +1465,7 @@ msgid "" "object, suitable for returning from a C function called from Python." msgstr "" -#: ../../extending/extending.rst:840 +#: ../../extending/extending.rst:865 msgid "" "One difference with :c:func:`PyArg_ParseTuple`: while the latter requires " "its first argument to be a tuple (since Python argument lists are always " @@ -1411,12 +1477,12 @@ msgid "" "parenthesize the format string." msgstr "" -#: ../../extending/extending.rst:848 +#: ../../extending/extending.rst:873 msgid "" "Examples (to the left the call, to the right the resulting Python value):" msgstr "" -#: ../../extending/extending.rst:850 +#: ../../extending/extending.rst:875 msgid "" "Py_BuildValue(\"\") None\n" "Py_BuildValue(\"i\", 123) 123\n" @@ -1454,11 +1520,11 @@ msgstr "" "Py_BuildValue(\"((ii)(ii)) (ii)\",\n" " 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" -#: ../../extending/extending.rst:874 +#: ../../extending/extending.rst:899 msgid "Reference Counts" msgstr "" -#: ../../extending/extending.rst:876 +#: ../../extending/extending.rst:901 msgid "" "In languages like C or C++, the programmer is responsible for dynamic " "allocation and deallocation of memory on the heap. In C, this is done using " @@ -1467,7 +1533,7 @@ msgid "" "restrict the following discussion to the C case." msgstr "" -#: ../../extending/extending.rst:882 +#: ../../extending/extending.rst:907 msgid "" "Every block of memory allocated with :c:func:`malloc` should eventually be " "returned to the pool of available memory by exactly one call to :c:func:" @@ -1482,7 +1548,7 @@ msgid "" "crashes." msgstr "" -#: ../../extending/extending.rst:893 +#: ../../extending/extending.rst:918 msgid "" "Common causes of memory leaks are unusual paths through the code. For " "instance, a function may allocate a block of memory, do some calculation, " @@ -1499,7 +1565,7 @@ msgid "" "of errors." msgstr "" -#: ../../extending/extending.rst:906 +#: ../../extending/extending.rst:931 msgid "" "Since Python makes heavy use of :c:func:`malloc` and :c:func:`free`, it " "needs a strategy to avoid memory leaks as well as the use of freed memory. " @@ -1510,7 +1576,7 @@ msgid "" "reference to the object has been deleted and the object is freed." msgstr "" -#: ../../extending/extending.rst:914 +#: ../../extending/extending.rst:939 msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -1526,7 +1592,7 @@ msgid "" "with reference counts." msgstr "" -#: ../../extending/extending.rst:926 +#: ../../extending/extending.rst:951 msgid "" "While Python uses the traditional reference counting implementation, it also " "offers a cycle detector that works to detect reference cycles. This allows " @@ -1540,7 +1606,7 @@ msgid "" "though there are no further references to the cycle itself." msgstr "" -#: ../../extending/extending.rst:937 +#: ../../extending/extending.rst:962 msgid "" "The cycle detector is able to detect garbage cycles and can reclaim them. " "The :mod:`gc` module exposes a way to run the detector (the :func:`~gc." @@ -1548,11 +1614,11 @@ msgid "" "disable the detector at runtime." msgstr "" -#: ../../extending/extending.rst:946 +#: ../../extending/extending.rst:971 msgid "Reference Counting in Python" msgstr "" -#: ../../extending/extending.rst:948 +#: ../../extending/extending.rst:973 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " "the incrementing and decrementing of the reference count. :c:func:" @@ -1563,7 +1629,7 @@ msgid "" "object." msgstr "" -#: ../../extending/extending.rst:955 +#: ../../extending/extending.rst:980 msgid "" "The big question now remains: when to use ``Py_INCREF(x)`` and " "``Py_DECREF(x)``? Let's first introduce some terms. Nobody \"owns\" an " @@ -1576,7 +1642,7 @@ msgid "" "reference creates a memory leak." msgstr "" -#: ../../extending/extending.rst:964 +#: ../../extending/extending.rst:989 msgid "" "It is also possible to :dfn:`borrow` [#]_ a reference to an object. The " "borrower of a reference should not call :c:func:`Py_DECREF`. The borrower " @@ -1585,7 +1651,7 @@ msgid "" "risks using freed memory and should be avoided completely [#]_." msgstr "" -#: ../../extending/extending.rst:970 +#: ../../extending/extending.rst:995 msgid "" "The advantage of borrowing over owning a reference is that you don't need to " "take care of disposing of the reference on all possible paths through the " @@ -1596,7 +1662,7 @@ msgid "" "borrowed has in fact disposed of it." msgstr "" -#: ../../extending/extending.rst:978 +#: ../../extending/extending.rst:1003 msgid "" "A borrowed reference can be changed into an owned reference by calling :c:" "func:`Py_INCREF`. This does not affect the status of the owner from which " @@ -1605,18 +1671,18 @@ msgid "" "properly, as well as the previous owner)." msgstr "" -#: ../../extending/extending.rst:988 +#: ../../extending/extending.rst:1013 msgid "Ownership Rules" msgstr "" -#: ../../extending/extending.rst:990 +#: ../../extending/extending.rst:1015 msgid "" "Whenever an object reference is passed into or out of a function, it is part " "of the function's interface specification whether ownership is transferred " "with the reference or not." msgstr "" -#: ../../extending/extending.rst:994 +#: ../../extending/extending.rst:1019 msgid "" "Most functions that return a reference to an object pass on ownership with " "the reference. In particular, all functions whose function it is to create " @@ -1627,7 +1693,7 @@ msgid "" "reference to a cached item." msgstr "" -#: ../../extending/extending.rst:1002 +#: ../../extending/extending.rst:1027 msgid "" "Many functions that extract objects from other objects also transfer " "ownership with the reference, for instance :c:func:" @@ -1638,14 +1704,14 @@ msgid "" "list or dictionary." msgstr "" -#: ../../extending/extending.rst:1009 +#: ../../extending/extending.rst:1034 msgid "" "The function :c:func:`PyImport_AddModule` also returns a borrowed reference, " "even though it may actually create the object it returns: this is possible " "because an owned reference to the object is stored in ``sys.modules``." msgstr "" -#: ../../extending/extending.rst:1013 +#: ../../extending/extending.rst:1038 msgid "" "When you pass an object reference into another function, in general, the " "function borrows the reference from you --- if it needs to store it, it will " @@ -1656,7 +1722,7 @@ msgid "" "don't take over ownership --- they are \"normal.\")" msgstr "" -#: ../../extending/extending.rst:1021 +#: ../../extending/extending.rst:1046 msgid "" "When a C function is called from Python, it borrows references to its " "arguments from the caller. The caller owns a reference to the object, so " @@ -1665,18 +1731,18 @@ msgid "" "turned into an owned reference by calling :c:func:`Py_INCREF`." msgstr "" -#: ../../extending/extending.rst:1027 +#: ../../extending/extending.rst:1052 msgid "" "The object reference returned from a C function that is called from Python " "must be an owned reference --- ownership is transferred from the function to " "its caller." msgstr "" -#: ../../extending/extending.rst:1035 +#: ../../extending/extending.rst:1060 msgid "Thin Ice" msgstr "" -#: ../../extending/extending.rst:1037 +#: ../../extending/extending.rst:1062 msgid "" "There are a few situations where seemingly harmless use of a borrowed " "reference can lead to problems. These all have to do with implicit " @@ -1684,14 +1750,14 @@ msgid "" "dispose of it." msgstr "" -#: ../../extending/extending.rst:1041 +#: ../../extending/extending.rst:1066 msgid "" "The first and most important case to know about is using :c:func:`Py_DECREF` " "on an unrelated object while borrowing a reference to a list item. For " "instance::" msgstr "" -#: ../../extending/extending.rst:1044 +#: ../../extending/extending.rst:1069 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1711,14 +1777,14 @@ msgstr "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" -#: ../../extending/extending.rst:1053 +#: ../../extending/extending.rst:1078 msgid "" "This function first borrows a reference to ``list[0]``, then replaces " "``list[1]`` with the value ``0``, and finally prints the borrowed reference. " "Looks harmless, right? But it's not!" msgstr "" -#: ../../extending/extending.rst:1057 +#: ../../extending/extending.rst:1082 msgid "" "Let's follow the control flow into :c:func:`PyList_SetItem`. The list owns " "references to all its items, so when item 1 is replaced, it has to dispose " @@ -1728,7 +1794,7 @@ msgid "" "count of 1, disposing of it will call its :meth:`!__del__` method." msgstr "" -#: ../../extending/extending.rst:1064 +#: ../../extending/extending.rst:1089 msgid "" "Since it is written in Python, the :meth:`!__del__` method can execute " "arbitrary Python code. Could it perhaps do something to invalidate the " @@ -1739,13 +1805,13 @@ msgid "" "associated with it, thereby invalidating ``item``." msgstr "" -#: ../../extending/extending.rst:1072 +#: ../../extending/extending.rst:1097 msgid "" "The solution, once you know the source of the problem, is easy: temporarily " "increment the reference count. The correct version of the function reads::" msgstr "" -#: ../../extending/extending.rst:1075 +#: ../../extending/extending.rst:1100 msgid "" "void\n" "no_bug(PyObject *list)\n" @@ -1769,14 +1835,14 @@ msgstr "" " Py_DECREF(item);\n" "}" -#: ../../extending/extending.rst:1086 +#: ../../extending/extending.rst:1111 msgid "" "This is a true story. An older version of Python contained variants of this " "bug and someone spent a considerable amount of time in a C debugger to " "figure out why his :meth:`!__del__` methods would fail..." msgstr "" -#: ../../extending/extending.rst:1090 +#: ../../extending/extending.rst:1115 msgid "" "The second case of problems with a borrowed reference is a variant involving " "threads. Normally, multiple threads in the Python interpreter can't get in " @@ -1789,7 +1855,7 @@ msgid "" "Obviously, the following function has the same problem as the previous one::" msgstr "" -#: ../../extending/extending.rst:1100 +#: ../../extending/extending.rst:1125 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1802,11 +1868,11 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1114 +#: ../../extending/extending.rst:1139 msgid "NULL Pointers" msgstr "NULL 指標" -#: ../../extending/extending.rst:1116 +#: ../../extending/extending.rst:1141 msgid "" "In general, functions that take object references as arguments do not expect " "you to pass them ``NULL`` pointers, and will dump core (or cause later core " @@ -1818,21 +1884,21 @@ msgid "" "more slowly." msgstr "" -#: ../../extending/extending.rst:1124 +#: ../../extending/extending.rst:1149 msgid "" "It is better to test for ``NULL`` only at the \"source:\" when a pointer " "that may be ``NULL`` is received, for example, from :c:func:`malloc` or from " "a function that may raise an exception." msgstr "" -#: ../../extending/extending.rst:1128 +#: ../../extending/extending.rst:1153 msgid "" "The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for " "``NULL`` pointers --- however, their variants :c:func:`Py_XINCREF` and :c:" "func:`Py_XDECREF` do." msgstr "" -#: ../../extending/extending.rst:1132 +#: ../../extending/extending.rst:1157 msgid "" "The macros for checking for a particular object type (``Pytype_Check()``) " "don't check for ``NULL`` pointers --- again, there is much code that calls " @@ -1841,24 +1907,24 @@ msgid "" "variants with ``NULL`` checking." msgstr "" -#: ../../extending/extending.rst:1138 +#: ../../extending/extending.rst:1163 msgid "" "The C function calling mechanism guarantees that the argument list passed to " "C functions (``args`` in the examples) is never ``NULL`` --- in fact it " "guarantees that it is always a tuple [#]_." msgstr "" -#: ../../extending/extending.rst:1142 +#: ../../extending/extending.rst:1167 msgid "" "It is a severe error to ever let a ``NULL`` pointer \"escape\" to the Python " "user." msgstr "" -#: ../../extending/extending.rst:1153 +#: ../../extending/extending.rst:1178 msgid "Writing Extensions in C++" msgstr "" -#: ../../extending/extending.rst:1155 +#: ../../extending/extending.rst:1180 msgid "" "It is possible to write extension modules in C++. Some restrictions apply. " "If the main program (the Python interpreter) is compiled and linked by the C " @@ -1871,11 +1937,11 @@ msgid "" "(all recent C++ compilers define this symbol)." msgstr "" -#: ../../extending/extending.rst:1169 +#: ../../extending/extending.rst:1194 msgid "Providing a C API for an Extension Module" msgstr "" -#: ../../extending/extending.rst:1174 +#: ../../extending/extending.rst:1199 msgid "" "Many extension modules just provide new functions and types to be used from " "Python, but sometimes the code in an extension module can be useful for " @@ -1886,7 +1952,7 @@ msgid "" "functions for direct manipulation from other extension modules." msgstr "" -#: ../../extending/extending.rst:1182 +#: ../../extending/extending.rst:1207 msgid "" "At first sight this seems easy: just write the functions (without declaring " "them ``static``, of course), provide an appropriate header file, and " @@ -1902,7 +1968,7 @@ msgid "" "call might not have been loaded yet!" msgstr "" -#: ../../extending/extending.rst:1194 +#: ../../extending/extending.rst:1219 msgid "" "Portability therefore requires not to make any assumptions about symbol " "visibility. This means that all symbols in extension modules should be " @@ -1912,7 +1978,7 @@ msgid "" "accessible from other extension modules must be exported in a different way." msgstr "" -#: ../../extending/extending.rst:1201 +#: ../../extending/extending.rst:1226 msgid "" "Python provides a special mechanism to pass C-level information (pointers) " "from one extension module to another one: Capsules. A Capsule is a Python " @@ -1924,7 +1990,7 @@ msgid "" "the Capsule." msgstr "" -#: ../../extending/extending.rst:1209 +#: ../../extending/extending.rst:1234 msgid "" "There are many ways in which Capsules can be used to export the C API of an " "extension module. Each function could get its own Capsule, or all C API " @@ -1934,7 +2000,7 @@ msgid "" "client modules." msgstr "" -#: ../../extending/extending.rst:1215 +#: ../../extending/extending.rst:1240 msgid "" "Whichever method you choose, it's important to name your Capsules properly. " "The function :c:func:`PyCapsule_New` takes a name parameter (:c:expr:`const " @@ -1944,17 +2010,17 @@ msgid "" "from another." msgstr "" -#: ../../extending/extending.rst:1222 +#: ../../extending/extending.rst:1247 msgid "" "In particular, Capsules used to expose C APIs should be given a name " "following this convention::" msgstr "" -#: ../../extending/extending.rst:1225 +#: ../../extending/extending.rst:1250 msgid "modulename.attributename" msgstr "modulename.attributename" -#: ../../extending/extending.rst:1227 +#: ../../extending/extending.rst:1252 msgid "" "The convenience function :c:func:`PyCapsule_Import` makes it easy to load a " "C API provided via a Capsule, but only if the Capsule's name matches this " @@ -1962,7 +2028,7 @@ msgid "" "the Capsule they load contains the correct C API." msgstr "" -#: ../../extending/extending.rst:1232 +#: ../../extending/extending.rst:1257 msgid "" "The following example demonstrates an approach that puts most of the burden " "on the writer of the exporting module, which is appropriate for commonly " @@ -1973,7 +2039,7 @@ msgid "" "modules only have to call this macro before accessing the C API." msgstr "" -#: ../../extending/extending.rst:1240 +#: ../../extending/extending.rst:1265 msgid "" "The exporting module is a modification of the :mod:`!spam` module from " "section :ref:`extending-simpleexample`. The function :func:`!spam.system` " @@ -1984,13 +2050,13 @@ msgid "" "modules." msgstr "" -#: ../../extending/extending.rst:1247 +#: ../../extending/extending.rst:1272 msgid "" "The function :c:func:`!PySpam_System` is a plain C function, declared " "``static`` like everything else::" msgstr "" -#: ../../extending/extending.rst:1250 +#: ../../extending/extending.rst:1275 msgid "" "static int\n" "PySpam_System(const char *command)\n" @@ -2004,11 +2070,11 @@ msgstr "" " return system(command);\n" "}" -#: ../../extending/extending.rst:1256 +#: ../../extending/extending.rst:1281 msgid "The function :c:func:`!spam_system` is modified in a trivial way::" msgstr "" -#: ../../extending/extending.rst:1258 +#: ../../extending/extending.rst:1283 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -2034,19 +2100,19 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:1270 +#: ../../extending/extending.rst:1295 msgid "In the beginning of the module, right after the line ::" msgstr "" -#: ../../extending/extending.rst:1272 +#: ../../extending/extending.rst:1297 msgid "#include " msgstr "#include " -#: ../../extending/extending.rst:1274 +#: ../../extending/extending.rst:1299 msgid "two more lines must be added::" msgstr "" -#: ../../extending/extending.rst:1276 +#: ../../extending/extending.rst:1301 msgid "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" @@ -2054,7 +2120,7 @@ msgstr "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" -#: ../../extending/extending.rst:1279 +#: ../../extending/extending.rst:1304 msgid "" "The ``#define`` is used to tell the header file that it is being included in " "the exporting module, not a client module. Finally, the module's :c:data:" @@ -2062,7 +2128,7 @@ msgid "" "pointer array::" msgstr "" -#: ../../extending/extending.rst:1283 +#: ../../extending/extending.rst:1308 msgid "" "static int\n" "spam_module_exec(PyObject *m)\n" @@ -2085,19 +2151,19 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1302 +#: ../../extending/extending.rst:1327 msgid "" "Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " "would disappear when :c:func:`!PyInit_spam` terminates!" msgstr "" -#: ../../extending/extending.rst:1305 +#: ../../extending/extending.rst:1330 msgid "" "The bulk of the work is in the header file :file:`spammodule.h`, which looks " "like this::" msgstr "" -#: ../../extending/extending.rst:1308 +#: ../../extending/extending.rst:1333 msgid "" "#ifndef Py_SPAMMODULE_H\n" "#define Py_SPAMMODULE_H\n" @@ -2149,14 +2215,14 @@ msgid "" "#endif /* !defined(Py_SPAMMODULE_H) */" msgstr "" -#: ../../extending/extending.rst:1356 +#: ../../extending/extending.rst:1381 msgid "" "All that a client module must do in order to have access to the function :c:" "func:`!PySpam_System` is to call the function (or rather macro) :c:func:`!" "import_spam` in its :c:data:`mod_exec ` function::" msgstr "" -#: ../../extending/extending.rst:1360 +#: ../../extending/extending.rst:1385 msgid "" "static int\n" "client_module_exec(PyObject *m)\n" @@ -2169,14 +2235,14 @@ msgid "" "}" msgstr "" -#: ../../extending/extending.rst:1370 +#: ../../extending/extending.rst:1395 msgid "" "The main disadvantage of this approach is that the file :file:`spammodule.h` " "is rather complicated. However, the basic structure is the same for each " "function that is exported, so it has to be learned only once." msgstr "" -#: ../../extending/extending.rst:1374 +#: ../../extending/extending.rst:1399 msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -2186,51 +2252,67 @@ msgid "" "in the Python source code distribution)." msgstr "" -#: ../../extending/extending.rst:1382 +#: ../../extending/extending.rst:1407 msgid "Footnotes" msgstr "註腳" -#: ../../extending/extending.rst:1383 +#: ../../extending/extending.rst:1408 msgid "" "An interface for this function already exists in the standard module :mod:" "`os` --- it was chosen as a simple and straightforward example." msgstr "" -#: ../../extending/extending.rst:1386 +#: ../../extending/extending.rst:1411 msgid "" "The metaphor of \"borrowing\" a reference is not completely correct: the " "owner still has a copy of the reference." msgstr "" -#: ../../extending/extending.rst:1389 +#: ../../extending/extending.rst:1414 msgid "" "Checking that the reference count is at least 1 **does not work** --- the " "reference count itself could be in freed memory and may thus be reused for " "another object!" msgstr "" -#: ../../extending/extending.rst:1393 +#: ../../extending/extending.rst:1418 msgid "" "These guarantees don't hold when you use the \"old\" style calling " "convention --- this is still found in much existing code." msgstr "" -#: ../../extending/extending.rst:568 +#: ../../extending/extending.rst:593 msgid "PyObject_CallObject (C function)" msgstr "PyObject_CallObject(C 函式)" -#: ../../extending/extending.rst:659 +#: ../../extending/extending.rst:684 msgid "PyArg_ParseTuple (C function)" msgstr "PyArg_ParseTuple(C 函式)" -#: ../../extending/extending.rst:751 +#: ../../extending/extending.rst:776 msgid "PyArg_ParseTupleAndKeywords (C function)" msgstr "PyArg_ParseTupleAndKeywords(C 函式)" -#: ../../extending/extending.rst:772 +#: ../../extending/extending.rst:797 msgid "Philbrick, Geoff" msgstr "Philbrick, Geoff" +#~ msgid "" +#~ "All user-visible symbols defined by :file:`Python.h` have a prefix of " +#~ "``Py`` or ``PY``, except those defined in standard header files. For " +#~ "convenience, and since they are used extensively by the Python " +#~ "interpreter, ``\"Python.h\"`` includes a few standard header files: " +#~ "````, ````, ````, and ````. If the " +#~ "latter header file does not exist on your system, it declares the " +#~ "functions :c:func:`malloc`, :c:func:`free` and :c:func:`realloc` directly." +#~ msgstr "" +#~ "除了那些在標準標頭檔中定義的符號以外,所有由 :file:`Python.h` 定義的使用者" +#~ "可見符號 (user-visible symbols) 的前綴都是 ``Py`` 或 ``PY``。為了方便,也" +#~ "因為 Python 直譯器的大量使用,``\"Python.h\"`` 也引入了一些標準的標頭檔:" +#~ "````、````、```` 和 ````。如果 " +#~ "```` 在你的系統上不存在,它會直接宣告 :c:func:`malloc`、:c:func:" +#~ "`free` 和 :c:func:`realloc` 函式。" + #~ msgid "" #~ "and initialize it in your module's initialization function (:c:func:`!" #~ "PyInit_spam`) with an exception object::" diff --git a/glossary.po b/glossary.po index 18ffbb20e3..9002348c19 100644 --- a/glossary.po +++ b/glossary.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-13 11:32+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2023-07-02 22:47+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -924,10 +924,22 @@ msgstr "" "風格。" #: ../../glossary.rst:404 +#, fuzzy +msgid "dunder" +msgstr "finder(尋檢器)" + +#: ../../glossary.rst:406 +msgid "" +"An informal short-hand for \"double underscore\", used when talking about a :" +"term:`special method`. For example, ``__init__`` is often pronounced " +"\"dunder init\"." +msgstr "" + +#: ../../glossary.rst:409 msgid "EAFP" msgstr "EAFP" -#: ../../glossary.rst:406 +#: ../../glossary.rst:411 msgid "" "Easier to ask for forgiveness than permission. This common Python coding " "style assumes the existence of valid keys or attributes and catches " @@ -942,11 +954,11 @@ msgstr "" "keyword:`except` 陳述式。該技術與許多其他語言(例如 C)常見的 :term:`LBYL` 風" "格形成了對比。" -#: ../../glossary.rst:412 +#: ../../glossary.rst:417 msgid "expression" msgstr "expression(運算式)" -#: ../../glossary.rst:414 +#: ../../glossary.rst:419 msgid "" "A piece of syntax which can be evaluated to some value. In other words, an " "expression is an accumulation of expression elements like literals, names, " @@ -962,11 +974,11 @@ msgstr "" "(陳述式)不能被用作運算式,例如 :keyword:`while`。賦值 (assignment) 也是陳述" "式,而不是運算式。" -#: ../../glossary.rst:421 +#: ../../glossary.rst:426 msgid "extension module" msgstr "extension module(擴充模組)" -#: ../../glossary.rst:423 +#: ../../glossary.rst:428 msgid "" "A module written in C or C++, using Python's C API to interact with the core " "and with user code." @@ -974,11 +986,11 @@ msgstr "" "一個以 C 或 C++ 編寫的模組,它使用 Python 的 C API 來與核心及使用者程式碼進行" "互動。" -#: ../../glossary.rst:425 +#: ../../glossary.rst:430 msgid "f-string" msgstr "f-string(f 字串)" -#: ../../glossary.rst:427 +#: ../../glossary.rst:432 msgid "" "String literals prefixed with ``'f'`` or ``'F'`` are commonly called \"f-" "strings\" which is short for :ref:`formatted string literals `. " @@ -987,11 +999,11 @@ msgstr "" "以 ``'f'`` 或 ``'F'`` 為前綴的字串文本通常被稱為「f 字串」,它是\\ :ref:`格式" "化的字串文本 `\\ 的縮寫。另請參閱 :pep:`498`。" -#: ../../glossary.rst:430 +#: ../../glossary.rst:435 msgid "file object" msgstr "file object(檔案物件)" -#: ../../glossary.rst:432 +#: ../../glossary.rst:437 msgid "" "An object exposing a file-oriented API (with methods such as :meth:`!read` " "or :meth:`!write`) to an underlying resource. Depending on the way it was " @@ -1006,7 +1018,7 @@ msgstr "" "衝區、socket(插座)、管線 (pipe) 等)的存取。檔案物件也被稱為\\ :dfn:`類檔案" "物件 (file-like object)` 或\\ :dfn:`串流 (stream)`。" -#: ../../glossary.rst:440 +#: ../../glossary.rst:445 msgid "" "There are actually three categories of file objects: raw :term:`binary files " "`, buffered :term:`binary files ` and :term:`text " @@ -1018,19 +1030,19 @@ msgstr "" "term:`二進位檔案 `\\ 和\\ :term:`文字檔案 `。它們的介" "面在 :mod:`io` 模組中被定義。建立檔案物件的標準方法是使用 :func:`open` 函式。" -#: ../../glossary.rst:445 +#: ../../glossary.rst:450 msgid "file-like object" msgstr "file-like object(類檔案物件)" -#: ../../glossary.rst:447 +#: ../../glossary.rst:452 msgid "A synonym for :term:`file object`." msgstr ":term:`file object`\\ (檔案物件)的同義字。" -#: ../../glossary.rst:448 +#: ../../glossary.rst:453 msgid "filesystem encoding and error handler" msgstr "filesystem encoding and error handler(檔案系統編碼和錯誤處理函式)" -#: ../../glossary.rst:450 +#: ../../glossary.rst:455 msgid "" "Encoding and error handler used by Python to decode bytes from the operating " "system and encode Unicode to the operating system." @@ -1038,7 +1050,7 @@ msgstr "" "Python 所使用的一種編碼和錯誤處理函式,用來解碼來自作業系統的位元組,以及將 " "Unicode 編碼到作業系統。" -#: ../../glossary.rst:453 +#: ../../glossary.rst:458 msgid "" "The filesystem encoding must guarantee to successfully decode all bytes " "below 128. If the file system encoding fails to provide this guarantee, API " @@ -1047,7 +1059,7 @@ msgstr "" "檔案系統編碼必須保證能成功解碼所有小於 128 的位元組。如果檔案系統編碼無法提供" "此保證,則 API 函式會引發 :exc:`UnicodeError`。" -#: ../../glossary.rst:457 +#: ../../glossary.rst:462 msgid "" "The :func:`sys.getfilesystemencoding` and :func:`sys." "getfilesystemencodeerrors` functions can be used to get the filesystem " @@ -1056,7 +1068,7 @@ msgstr "" ":func:`sys.getfilesystemencoding` 和 :func:`sys.getfilesystemencodeerrors` 函" "式可用於取得檔案系統編碼和錯誤處理函式。" -#: ../../glossary.rst:461 +#: ../../glossary.rst:466 msgid "" "The :term:`filesystem encoding and error handler` are configured at Python " "startup by the :c:func:`PyConfig_Read` function: see :c:member:`~PyConfig." @@ -1068,22 +1080,22 @@ msgstr "" "member:`~PyConfig.filesystem_encoding`,以及 :c:type:`PyConfig` 的成員 :c:" "member:`~PyConfig.filesystem_errors`。" -#: ../../glossary.rst:466 +#: ../../glossary.rst:471 msgid "See also the :term:`locale encoding`." msgstr "另請參閱 :term:`locale encoding`\\ (區域編碼)。" -#: ../../glossary.rst:467 +#: ../../glossary.rst:472 msgid "finder" msgstr "finder(尋檢器)" -#: ../../glossary.rst:469 +#: ../../glossary.rst:474 msgid "" "An object that tries to find the :term:`loader` for a module that is being " "imported." msgstr "" "一個物件,它會嘗試為正在被 import 的模組尋找 :term:`loader`\\ (載入器)。" -#: ../../glossary.rst:472 +#: ../../glossary.rst:477 msgid "" "There are two types of finder: :term:`meta path finders ` " "for use with :data:`sys.meta_path`, and :term:`path entry finders ` 會使用 :data:`sys.meta_path`,而\\ :term:`路徑項目尋檢器 (path " "entry finder) ` 會使用 :data:`sys.path_hooks`。" -#: ../../glossary.rst:476 +#: ../../glossary.rst:481 msgid "" "See :ref:`finders-and-loaders` and :mod:`importlib` for much more detail." msgstr "請參閱 :ref:`finders-and-loaders` 和 :mod:`importlib` 以了解更多細節。" -#: ../../glossary.rst:477 +#: ../../glossary.rst:482 msgid "floor division" msgstr "floor division(向下取整除法)" -#: ../../glossary.rst:479 +#: ../../glossary.rst:484 msgid "" "Mathematical division that rounds down to nearest integer. The floor " "division operator is ``//``. For example, the expression ``11 // 4`` " @@ -1115,11 +1127,11 @@ msgstr "" "``2.75`` 不同。請注意,``(-11) // 4`` 的結果是 ``-3``,因為是 ``-2.75`` 被\\ " "*向下*\\ 無條件捨去。請參閱 :pep:`238`。" -#: ../../glossary.rst:484 +#: ../../glossary.rst:489 msgid "free threading" msgstr "free threading(自由執行緒)" -#: ../../glossary.rst:486 +#: ../../glossary.rst:491 msgid "" "A threading model where multiple threads can run Python bytecode " "simultaneously within the same interpreter. This is in contrast to the :" @@ -1130,11 +1142,11 @@ msgstr "" "\\ :term:`全域直譯器鎖 `\\ 形成對比,後者一次只允許" "一個執行緒執行 Python 位元組碼。請參閱 :pep:`703`。" -#: ../../glossary.rst:490 +#: ../../glossary.rst:495 msgid "free variable" msgstr "free variable(自由變數)" -#: ../../glossary.rst:492 +#: ../../glossary.rst:497 msgid "" "Formally, as defined in the :ref:`language execution model `, a " "free variable is any variable used in a namespace which is not a local " @@ -1144,11 +1156,11 @@ msgid "" "variable`." msgstr "" -#: ../../glossary.rst:497 +#: ../../glossary.rst:502 msgid "function" msgstr "function(函式)" -#: ../../glossary.rst:499 +#: ../../glossary.rst:504 msgid "" "A series of statements which returns some value to a caller. It can also be " "passed zero or more :term:`arguments ` which may be used in the " @@ -1160,15 +1172,15 @@ msgstr "" "`parameter`\\ (參數)、:term:`method`\\ (方法),以及\\ :ref:`function`\\ " "章節。" -#: ../../glossary.rst:503 +#: ../../glossary.rst:508 msgid "function annotation" msgstr "function annotation(函式註釋)" -#: ../../glossary.rst:505 +#: ../../glossary.rst:510 msgid "An :term:`annotation` of a function parameter or return value." msgstr "函式參數或回傳值的一個 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:507 +#: ../../glossary.rst:512 msgid "" "Function annotations are usually used for :term:`type hints `: " "for example, this function is expected to take two :class:`int` arguments " @@ -1177,7 +1189,7 @@ msgstr "" "函式註釋通常被使用於\\ :term:`型別提示 `:例如,這個函式預期會得到" "兩個 :class:`int` 引數,並會有一個 :class:`int` 回傳值: ::" -#: ../../glossary.rst:512 +#: ../../glossary.rst:517 msgid "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" @@ -1185,11 +1197,11 @@ msgstr "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" -#: ../../glossary.rst:515 +#: ../../glossary.rst:520 msgid "Function annotation syntax is explained in section :ref:`function`." msgstr "函式註釋的語法在\\ :ref:`function`\\ 章節有詳細解釋。" -#: ../../glossary.rst:517 +#: ../../glossary.rst:522 msgid "" "See :term:`variable annotation` and :pep:`484`, which describe this " "functionality. Also see :ref:`annotations-howto` for best practices on " @@ -1198,11 +1210,11 @@ msgstr "" "請參閱 :term:`variable annotation` 和 :pep:`484`,皆有此功能的描述。關於註釋" "的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:521 +#: ../../glossary.rst:526 msgid "__future__" msgstr "__future__" -#: ../../glossary.rst:523 +#: ../../glossary.rst:528 msgid "" "A :ref:`future statement `, ``from __future__ import ``, " "directs the compiler to compile the current module using syntax or semantics " @@ -1218,7 +1230,7 @@ msgstr "" "import 此模組並對其變數求值,你可以看見一個新的功能是何時首次被新增到此語言" "中,以及它何時將會(或已經)成為預設的功能: ::" -#: ../../glossary.rst:531 +#: ../../glossary.rst:536 msgid "" ">>> import __future__\n" ">>> __future__.division\n" @@ -1228,11 +1240,11 @@ msgstr "" ">>> __future__.division\n" "_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" -#: ../../glossary.rst:534 +#: ../../glossary.rst:539 msgid "garbage collection" msgstr "garbage collection(垃圾回收)" -#: ../../glossary.rst:536 +#: ../../glossary.rst:541 msgid "" "The process of freeing memory when it is not used anymore. Python performs " "garbage collection via reference counting and a cyclic garbage collector " @@ -1244,11 +1256,11 @@ msgstr "" "垃圾回收器 (cyclic garbage collector) 來完成。垃圾回收器可以使用 :mod:`gc` 模" "組對其進行控制。" -#: ../../glossary.rst:541 ../../glossary.rst:542 +#: ../../glossary.rst:546 ../../glossary.rst:547 msgid "generator" msgstr "generator(產生器)" -#: ../../glossary.rst:544 +#: ../../glossary.rst:549 msgid "" "A function which returns a :term:`generator iterator`. It looks like a " "normal function except that it contains :keyword:`yield` expressions for " @@ -1259,7 +1271,7 @@ msgstr "" "個正常的函式,但不同的是它包含了 :keyword:`yield` 運算式,能產生一系列的值," "這些值可用於 for 迴圈,或是以 :func:`next` 函式,每次檢索其中的一個值。" -#: ../../glossary.rst:549 +#: ../../glossary.rst:554 msgid "" "Usually refers to a generator function, but may refer to a *generator " "iterator* in some contexts. In cases where the intended meaning isn't " @@ -1268,15 +1280,15 @@ msgstr "" "這個術語通常用來表示一個產生器函式,但在某些情境中,也可能是表示\\ *產生器疊" "代器*。萬一想表達的意思不夠清楚,那就使用完整的術語,以避免歧義。" -#: ../../glossary.rst:552 +#: ../../glossary.rst:557 msgid "generator iterator" msgstr "generator iterator(產生器疊代器)" -#: ../../glossary.rst:554 +#: ../../glossary.rst:559 msgid "An object created by a :term:`generator` function." msgstr "一個由 :term:`generator`\\ (產生器)函式所建立的物件。" -#: ../../glossary.rst:556 +#: ../../glossary.rst:561 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " "execution state (including local variables and pending try-statements). " @@ -1287,11 +1299,11 @@ msgstr "" "try 陳述式)。當\\ *產生器疊代器*\\ 回復時,它會從停止的地方繼續執行(與那些" "每次呼叫時都要重新開始的函式有所不同)。" -#: ../../glossary.rst:562 ../../glossary.rst:563 +#: ../../glossary.rst:567 ../../glossary.rst:568 msgid "generator expression" msgstr "generator expression(產生器運算式)" -#: ../../glossary.rst:565 +#: ../../glossary.rst:570 msgid "" "An :term:`expression` that returns an :term:`iterator`. It looks like a " "normal expression followed by a :keyword:`!for` clause defining a loop " @@ -1303,7 +1315,7 @@ msgstr "" "變數、範圍以及一個選擇性的 :keyword:`!if` 子句。該組合運算式會為外層函式產生" "多個值: ::" -#: ../../glossary.rst:570 +#: ../../glossary.rst:575 msgid "" ">>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n" "285" @@ -1311,11 +1323,11 @@ msgstr "" ">>> sum(i*i for i in range(10)) # 平方之和 0, 1, 4, ... 81\n" "285" -#: ../../glossary.rst:572 +#: ../../glossary.rst:577 msgid "generic function" msgstr "generic function(泛型函式)" -#: ../../glossary.rst:574 +#: ../../glossary.rst:579 msgid "" "A function composed of multiple functions implementing the same operation " "for different types. Which implementation should be used during a call is " @@ -1324,7 +1336,7 @@ msgstr "" "一個由多個函式組成的函式,該函式會對不同的型別實作相同的運算。呼叫期間應該使" "用哪種實作,是由調度演算法 (dispatch algorithm) 來決定。" -#: ../../glossary.rst:578 +#: ../../glossary.rst:583 msgid "" "See also the :term:`single dispatch` glossary entry, the :func:`functools." "singledispatch` decorator, and :pep:`443`." @@ -1332,11 +1344,11 @@ msgstr "" "另請參閱 :term:`single dispatch`\\ (單一調度)術語表條目、:func:`functools." "singledispatch` 裝飾器和 :pep:`443`。" -#: ../../glossary.rst:580 +#: ../../glossary.rst:585 msgid "generic type" msgstr "generic type(泛型型別)" -#: ../../glossary.rst:582 +#: ../../glossary.rst:587 msgid "" "A :term:`type` that can be parameterized; typically a :ref:`container " "class` such as :class:`list` or :class:`dict`. Used for :" @@ -1346,7 +1358,7 @@ msgstr "" "`容器型別 `,像是 :class:`list` 和 :class:`dict`。它被用於" "\\ :term:`型別提示 `\\ 和\\ :term:`註釋 `。" -#: ../../glossary.rst:587 +#: ../../glossary.rst:592 msgid "" "For more details, see :ref:`generic alias types`, :pep:" "`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module." @@ -1354,19 +1366,19 @@ msgstr "" "詳情請參閱\\ :ref:`泛型別名型別 `、:pep:`483`、:pep:" "`484`、:pep:`585` 和 :mod:`typing` 模組。" -#: ../../glossary.rst:589 +#: ../../glossary.rst:594 msgid "GIL" msgstr "GIL" -#: ../../glossary.rst:591 +#: ../../glossary.rst:596 msgid "See :term:`global interpreter lock`." msgstr "請參閱 :term:`global interpreter lock`\\ (全域直譯器鎖)。" -#: ../../glossary.rst:592 +#: ../../glossary.rst:597 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../glossary.rst:594 +#: ../../glossary.rst:599 msgid "" "The mechanism used by the :term:`CPython` interpreter to assure that only " "one thread executes Python :term:`bytecode` at a time. This simplifies the " @@ -1383,7 +1395,7 @@ msgstr "" "(multi-threaded),但代價是會犧牲掉多處理器的機器能夠提供的一大部分平行性 " "(parallelism)。" -#: ../../glossary.rst:603 +#: ../../glossary.rst:608 msgid "" "However, some extension modules, either standard or third-party, are " "designed so as to release the GIL when doing computationally intensive tasks " @@ -1394,7 +1406,7 @@ msgstr "" "計算密集 (computationally intensive) 的任務時,可以解除 GIL。另外,在執行 I/" "O 時,GIL 總是會被解除。" -#: ../../glossary.rst:608 +#: ../../glossary.rst:613 msgid "" "As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil` " "build configuration. After building Python with this option, code must be " @@ -1409,11 +1421,11 @@ msgstr "" "多執行緒應用程式的效能,並使多核心 CPU 的高效使用變得更加容易。有關更多詳細資" "訊,請參閱 :pep:`703`。" -#: ../../glossary.rst:614 +#: ../../glossary.rst:619 msgid "hash-based pyc" msgstr "hash-based pyc(雜湊架構的 pyc)" -#: ../../glossary.rst:616 +#: ../../glossary.rst:621 msgid "" "A bytecode cache file that uses the hash rather than the last-modified time " "of the corresponding source file to determine its validity. See :ref:`pyc-" @@ -1422,11 +1434,11 @@ msgstr "" "一個位元組碼 (bytecode) 暫存檔,它使用雜湊值而不是對應原始檔案的最後修改時" "間,來確定其有效性。請參閱\\ :ref:`pyc-invalidation`。" -#: ../../glossary.rst:619 +#: ../../glossary.rst:624 msgid "hashable" msgstr "hashable(可雜湊的)" -#: ../../glossary.rst:621 +#: ../../glossary.rst:626 msgid "" "An object is *hashable* if it has a hash value which never changes during " "its lifetime (it needs a :meth:`~object.__hash__` method), and can be " @@ -1438,7 +1450,7 @@ msgstr "" "`~object.__eq__` method),那麼它就是一個\\ *可雜湊*\\ 物件。比較結果為相等的" "多個可雜湊物件,它們必須擁有相同的雜湊值。" -#: ../../glossary.rst:627 +#: ../../glossary.rst:632 msgid "" "Hashability makes an object usable as a dictionary key and a set member, " "because these data structures use the hash value internally." @@ -1446,7 +1458,7 @@ msgstr "" "可雜湊性 (hashability) 使一個物件可用作 dictionary(字典)的鍵和 set(集合)" "的成員,因為這些資料結構都在其內部使用了雜湊值。" -#: ../../glossary.rst:630 +#: ../../glossary.rst:635 msgid "" "Most of Python's immutable built-in objects are hashable; mutable containers " "(such as lists or dictionaries) are not; immutable containers (such as " @@ -1461,11 +1473,11 @@ msgstr "" "則這些物件會被預設為可雜湊的。它們在互相比較時都是不相等的(除非它們與自己比" "較),而它們的雜湊值則是衍生自它們的 :func:`id`。" -#: ../../glossary.rst:637 +#: ../../glossary.rst:642 msgid "IDLE" msgstr "IDLE" -#: ../../glossary.rst:639 +#: ../../glossary.rst:644 msgid "" "An Integrated Development and Learning Environment for Python. :ref:`idle` " "is a basic editor and interpreter environment which ships with the standard " @@ -1475,17 +1487,17 @@ msgstr "" "境)。:ref:`idle` 是一個基本的編輯器和直譯器環境,它和 Python 的標準發行版本" "一起被提供。" -#: ../../glossary.rst:642 +#: ../../glossary.rst:647 msgid "immortal" msgstr "immortal(不滅)" -#: ../../glossary.rst:644 +#: ../../glossary.rst:649 msgid "" "*Immortal objects* are a CPython implementation detail introduced in :pep:" "`683`." msgstr "*不滅物件 (Immortal objects)* 是 :pep:`683` 引入的 CPython 實作細節。" -#: ../../glossary.rst:647 +#: ../../glossary.rst:652 msgid "" "If an object is immortal, its :term:`reference count` is never modified, and " "therefore it is never deallocated while the interpreter is running. For " @@ -1495,11 +1507,11 @@ msgstr "" "修改,因此在直譯器運行時它永遠不會被釋放。例如,:const:`True` 和 :const:" "`None` 在 CPython 中是不滅的。" -#: ../../glossary.rst:650 +#: ../../glossary.rst:655 msgid "immutable" msgstr "immutable(不可變物件)" -#: ../../glossary.rst:652 +#: ../../glossary.rst:657 msgid "" "An object with a fixed value. Immutable objects include numbers, strings " "and tuples. Such an object cannot be altered. A new object has to be " @@ -1511,11 +1523,11 @@ msgstr "" "能被改變的。如果一個不同的值必須被儲存,則必須建立一個新的物件。它們在需要恆" "定雜湊值的地方,扮演重要的角色,例如 dictionary(字典)中的一個鍵。" -#: ../../glossary.rst:657 +#: ../../glossary.rst:662 msgid "import path" msgstr "import path(引入路徑)" -#: ../../glossary.rst:659 +#: ../../glossary.rst:664 msgid "" "A list of locations (or :term:`path entries `) that are searched " "by the :term:`path based finder` for modules to import. During import, this " @@ -1527,11 +1539,11 @@ msgstr "" "的位置。在 import 期間,此位置列表通常是來自 :data:`sys.path`,但對於子套件 " "(subpackage) 而言,它也可能是來自父套件的 ``__path__`` 屬性。" -#: ../../glossary.rst:664 +#: ../../glossary.rst:669 msgid "importing" msgstr "importing(引入)" -#: ../../glossary.rst:666 +#: ../../glossary.rst:671 msgid "" "The process by which Python code in one module is made available to Python " "code in another module." @@ -1539,11 +1551,11 @@ msgstr "" "一個過程。一個模組中的 Python 程式碼可以透過此過程,被另一個模組中的 Python " "程式碼使用。" -#: ../../glossary.rst:668 +#: ../../glossary.rst:673 msgid "importer" msgstr "importer(引入器)" -#: ../../glossary.rst:670 +#: ../../glossary.rst:675 msgid "" "An object that both finds and loads a module; both a :term:`finder` and :" "term:`loader` object." @@ -1551,11 +1563,11 @@ msgstr "" "一個能夠尋找及載入模組的物件;它既是 :term:`finder`\\ (尋檢器)也是 :term:" "`loader`\\ (載入器)物件。" -#: ../../glossary.rst:672 +#: ../../glossary.rst:677 msgid "interactive" msgstr "interactive(互動的)" -#: ../../glossary.rst:674 +#: ../../glossary.rst:679 msgid "" "Python has an interactive interpreter which means you can enter statements " "and expressions at the interpreter prompt, immediately execute them and see " @@ -1569,11 +1581,11 @@ msgstr "" "從你的電腦的主選單選擇它)。這是測試新想法或檢查模組和包的非常強大的方法(請" "記住help(x))。更多互動式模式相關資訊請見 :ref:`tut-interac`。" -#: ../../glossary.rst:681 +#: ../../glossary.rst:686 msgid "interpreted" msgstr "interpreted(直譯的)" -#: ../../glossary.rst:683 +#: ../../glossary.rst:688 msgid "" "Python is an interpreted language, as opposed to a compiled one, though the " "distinction can be blurry because of the presence of the bytecode compiler. " @@ -1587,11 +1599,11 @@ msgstr "" "一個執行檔,然後再執行它。直譯語言通常比編譯語言有更短的開發/除錯週期,不過" "它們的程式通常也運行得較慢。另請參閱 :term:`interactive`\\ (互動的)。" -#: ../../glossary.rst:690 +#: ../../glossary.rst:695 msgid "interpreter shutdown" msgstr "interpreter shutdown(直譯器關閉)" -#: ../../glossary.rst:692 +#: ../../glossary.rst:697 msgid "" "When asked to shut down, the Python interpreter enters a special phase where " "it gradually releases all allocated resources, such as modules and various " @@ -1609,18 +1621,18 @@ msgstr "" "段被執行的程式碼會遇到各種例外,因為它所依賴的資源可能不再有作用了(常見的例" "子是函式庫模組或是警告機制)。" -#: ../../glossary.rst:701 +#: ../../glossary.rst:706 msgid "" "The main reason for interpreter shutdown is that the ``__main__`` module or " "the script being run has finished executing." msgstr "" "直譯器關閉的主要原因,是 ``__main__`` 模組或正被運行的腳本已經執行完成。" -#: ../../glossary.rst:703 +#: ../../glossary.rst:708 msgid "iterable" msgstr "iterable(可疊代物件)" -#: ../../glossary.rst:705 +#: ../../glossary.rst:710 msgid "" "An object capable of returning its members one at a time. Examples of " "iterables include all sequence types (such as :class:`list`, :class:`str`, " @@ -1635,7 +1647,7 @@ msgstr "" "只要那些 class 有實作 :term:`sequence`\\ (序列)語意的 :meth:`~object." "__iter__` 或是 :meth:`~object.__getitem__` method,該物件就是可疊代物件。" -#: ../../glossary.rst:713 +#: ../../glossary.rst:718 msgid "" "Iterables can be used in a :keyword:`for` loop and in many other places " "where a sequence is needed (:func:`zip`, :func:`map`, ...). When an " @@ -1655,11 +1667,11 @@ msgstr "" "數,用於在迴圈期間保有該疊代器。另請參閱 :term:`iterator`\\ (疊代器)、:" "term:`sequence`\\ (序列)和 :term:`generator`\\ (產生器)。" -#: ../../glossary.rst:723 +#: ../../glossary.rst:728 msgid "iterator" msgstr "iterator(疊代器)" -#: ../../glossary.rst:725 +#: ../../glossary.rst:730 msgid "" "An object representing a stream of data. Repeated calls to the iterator's :" "meth:`~iterator.__next__` method (or passing it to the built-in function :" @@ -1688,11 +1700,11 @@ msgstr "" "此事(多遍疊代)時,只會回傳在前一遍疊代中被用過的、同一個已被用盡的疊代器物" "件,使其看起來就像一個空的容器。" -#: ../../glossary.rst:740 +#: ../../glossary.rst:745 msgid "More information can be found in :ref:`typeiter`." msgstr "在\\ :ref:`typeiter`\\ 文中可以找到更多資訊。" -#: ../../glossary.rst:744 +#: ../../glossary.rst:749 msgid "" "CPython does not consistently apply the requirement that an iterator define :" "meth:`~iterator.__iter__`. And also please note that the free-threading " @@ -1702,11 +1714,11 @@ msgstr "" "__iter__`\\ 」這個規定。另請注意,free-threading(自由執行緒)CPython 不保證" "疊代器操作的執行緒安全。" -#: ../../glossary.rst:749 +#: ../../glossary.rst:754 msgid "key function" msgstr "key function(鍵函式)" -#: ../../glossary.rst:751 +#: ../../glossary.rst:756 msgid "" "A key function or collation function is a callable that returns a value used " "for sorting or ordering. For example, :func:`locale.strxfrm` is used to " @@ -1716,7 +1728,7 @@ msgstr "" "一個用於排序 (sorting) 或定序 (ordering) 的值。例如,:func:`locale.strxfrm` " "被用來產生一個了解區域特定排序慣例的排序鍵。" -#: ../../glossary.rst:756 +#: ../../glossary.rst:761 msgid "" "A number of tools in Python accept key functions to control how elements are " "ordered or grouped. They include :func:`min`, :func:`max`, :func:`sorted`, :" @@ -1728,7 +1740,7 @@ msgstr "" "merge`、:func:`heapq.nsmallest`、:func:`heapq.nlargest` 和 :func:`itertools." "groupby`。" -#: ../../glossary.rst:762 +#: ../../glossary.rst:767 msgid "" "There are several ways to create a key function. For example. the :meth:" "`str.lower` method can serve as a key function for case insensitive sorts. " @@ -1745,19 +1757,19 @@ msgstr "" "式 (constructor)。關於如何建立和使用鍵函式的範例,請參閱\\ :ref:`如何排序 " "`。" -#: ../../glossary.rst:769 +#: ../../glossary.rst:774 msgid "keyword argument" msgstr "keyword argument(關鍵字引數)" -#: ../../glossary.rst:771 ../../glossary.rst:1086 +#: ../../glossary.rst:776 ../../glossary.rst:1091 msgid "See :term:`argument`." msgstr "請參閱 :term:`argument`\\ (引數)。" -#: ../../glossary.rst:772 +#: ../../glossary.rst:777 msgid "lambda" msgstr "lambda" -#: ../../glossary.rst:774 +#: ../../glossary.rst:779 msgid "" "An anonymous inline function consisting of a single :term:`expression` which " "is evaluated when the function is called. The syntax to create a lambda " @@ -1767,11 +1779,11 @@ msgstr "" "function),於該函式被呼叫時求值。建立 lambda 函式的語法是 ``lambda " "[parameters]: expression``" -#: ../../glossary.rst:777 +#: ../../glossary.rst:782 msgid "LBYL" msgstr "LBYL" -#: ../../glossary.rst:779 +#: ../../glossary.rst:784 msgid "" "Look before you leap. This coding style explicitly tests for pre-conditions " "before making calls or lookups. This style contrasts with the :term:`EAFP` " @@ -1782,7 +1794,7 @@ msgstr "" "地測試先決條件。這種風格與 :term:`EAFP` 方式形成對比,且它的特色是會有許多 :" "keyword:`if` 陳述式的存在。" -#: ../../glossary.rst:784 +#: ../../glossary.rst:789 msgid "" "In a multi-threaded environment, the LBYL approach can risk introducing a " "race condition between \"the looking\" and \"the leaping\". For example, " @@ -1796,19 +1808,19 @@ msgstr "" "了 *key*,則該程式碼就會失效。這個問題可以用鎖 (lock) 或使用 EAFP 編碼方式來" "解決。" -#: ../../glossary.rst:789 +#: ../../glossary.rst:794 msgid "lexical analyzer" msgstr "lexical analyzer(詞法分析器)" -#: ../../glossary.rst:792 +#: ../../glossary.rst:797 msgid "Formal name for the *tokenizer*; see :term:`token`." msgstr "tokenizer 的正式名稱;請參閱 :term:`token`。" -#: ../../glossary.rst:793 +#: ../../glossary.rst:798 msgid "list" msgstr "list(串列)" -#: ../../glossary.rst:795 +#: ../../glossary.rst:800 msgid "" "A built-in Python :term:`sequence`. Despite its name it is more akin to an " "array in other languages than to a linked list since access to elements is " @@ -1818,11 +1830,11 @@ msgstr "" "似其他語言中的一個陣列 (array) 而較不像一個鏈結串列 (linked list),因為存取元" "素的時間複雜度是 *O*\\ (1)。" -#: ../../glossary.rst:798 +#: ../../glossary.rst:803 msgid "list comprehension" msgstr "list comprehension(串列綜合運算)" -#: ../../glossary.rst:800 +#: ../../glossary.rst:805 msgid "" "A compact way to process all or part of the elements in a sequence and " "return a list with the results. ``result = ['{:#04x}'.format(x) for x in " @@ -1836,11 +1848,11 @@ msgstr "" "keyword:`if` 子句是選擇性的。如果省略它,則 ``range(256)`` 中的所有元素都會被" "處理。" -#: ../../glossary.rst:806 +#: ../../glossary.rst:811 msgid "loader" msgstr "loader(載入器)" -#: ../../glossary.rst:808 +#: ../../glossary.rst:813 msgid "" "An object that loads a module. It must define the :meth:`!exec_module` and :" "meth:`!create_module` methods to implement the :class:`~importlib.abc." @@ -1851,23 +1863,23 @@ msgstr "" "create_module` 方法以實作 :class:`~importlib.abc.Loader` 介面。載入器通常是" "被 :term:`finder`\\ (尋檢器)回傳。更多細節請參閱:" -#: ../../glossary.rst:814 +#: ../../glossary.rst:819 msgid ":ref:`finders-and-loaders`" msgstr ":ref:`finders-and-loaders`" -#: ../../glossary.rst:815 +#: ../../glossary.rst:820 msgid ":class:`importlib.abc.Loader`" msgstr ":class:`importlib.abc.Loader`" -#: ../../glossary.rst:816 +#: ../../glossary.rst:821 msgid ":pep:`302`" msgstr ":pep:`302`" -#: ../../glossary.rst:817 +#: ../../glossary.rst:822 msgid "locale encoding" msgstr "locale encoding(區域編碼)" -#: ../../glossary.rst:819 +#: ../../glossary.rst:824 msgid "" "On Unix, it is the encoding of the LC_CTYPE locale. It can be set with :func:" "`locale.setlocale(locale.LC_CTYPE, new_locale) `." @@ -1875,36 +1887,36 @@ msgstr "" "在 Unix 上,它是 LC_CTYPE 區域設定的編碼。它可以用 :func:`locale." "setlocale(locale.LC_CTYPE, new_locale) ` 來設定。" -#: ../../glossary.rst:822 +#: ../../glossary.rst:827 msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." msgstr "在 Windows 上,它是 ANSI 碼頁(code page,例如 ``\"cp1252\"``\\ )。" -#: ../../glossary.rst:824 +#: ../../glossary.rst:829 msgid "" "On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." msgstr "在 Android 和 VxWorks 上,Python 使用 ``\"utf-8\"`` 作為區域編碼。" -#: ../../glossary.rst:826 +#: ../../glossary.rst:831 msgid ":func:`locale.getencoding` can be used to get the locale encoding." msgstr ":func:`locale.getencoding` 可以用來取得區域編碼。" -#: ../../glossary.rst:828 +#: ../../glossary.rst:833 msgid "See also the :term:`filesystem encoding and error handler`." msgstr "也請參考 :term:`filesystem encoding and error handler`。" -#: ../../glossary.rst:829 +#: ../../glossary.rst:834 msgid "magic method" msgstr "magic method(魔術方法)" -#: ../../glossary.rst:833 +#: ../../glossary.rst:838 msgid "An informal synonym for :term:`special method`." msgstr ":term:`special method`\\ (特殊方法)的一個非正式同義詞。" -#: ../../glossary.rst:834 +#: ../../glossary.rst:839 msgid "mapping" msgstr "mapping(對映)" -#: ../../glossary.rst:836 +#: ../../glossary.rst:841 msgid "" "A container object that supports arbitrary key lookups and implements the " "methods specified in the :class:`collections.abc.Mapping` or :class:" @@ -1919,11 +1931,11 @@ msgstr "" "包括 :class:`dict`、:class:`collections.defaultdict`、:class:`collections." "OrderedDict` 和 :class:`collections.Counter`。" -#: ../../glossary.rst:842 +#: ../../glossary.rst:847 msgid "meta path finder" msgstr "meta path finder(元路徑尋檢器)" -#: ../../glossary.rst:844 +#: ../../glossary.rst:849 msgid "" "A :term:`finder` returned by a search of :data:`sys.meta_path`. Meta path " "finders are related to, but different from :term:`path entry finders ` " "相關但是不同。" -#: ../../glossary.rst:848 +#: ../../glossary.rst:853 msgid "" "See :class:`importlib.abc.MetaPathFinder` for the methods that meta path " "finders implement." msgstr "" "關於元路徑尋檢器實作的 method,請參閱 :class:`importlib.abc.MetaPathFinder`。" -#: ../../glossary.rst:850 +#: ../../glossary.rst:855 msgid "metaclass" msgstr "metaclass(元類別)" -#: ../../glossary.rst:852 +#: ../../glossary.rst:857 msgid "" "The class of a class. Class definitions create a class name, a class " "dictionary, and a list of base classes. The metaclass is responsible for " @@ -1964,15 +1976,15 @@ msgstr "" "性存取、增加執行緒安全性、追蹤物件建立、實作單例模式 (singleton),以及許多其" "他的任務。" -#: ../../glossary.rst:862 +#: ../../glossary.rst:867 msgid "More information can be found in :ref:`metaclasses`." msgstr "更多資訊可以在\\ :ref:`metaclasses`\\ 章節中找到。" -#: ../../glossary.rst:831 ../../glossary.rst:863 ../../glossary.rst:1236 +#: ../../glossary.rst:836 ../../glossary.rst:868 ../../glossary.rst:1241 msgid "method" msgstr "method(方法)" -#: ../../glossary.rst:865 +#: ../../glossary.rst:870 msgid "" "A function which is defined inside a class body. If called as an attribute " "of an instance of that class, the method will get the instance object as its " @@ -1984,11 +1996,11 @@ msgstr "" "通常被稱為 ``self``)。請參閱 :term:`function`\\ (函式)和 :term:`nested " "scope`\\ (巢狀作用域)。" -#: ../../glossary.rst:869 +#: ../../glossary.rst:874 msgid "method resolution order" msgstr "method resolution order(方法解析順序)" -#: ../../glossary.rst:871 +#: ../../glossary.rst:876 msgid "" "Method Resolution Order is the order in which base classes are searched for " "a member during lookup. See :ref:`python_2.3_mro` for details of the " @@ -1997,11 +2009,11 @@ msgstr "" "方法解析順序是在查找某個成員的過程中,base class(基底類別)被搜尋的順序。關" "於 Python 自 2.3 版直譯器所使用的演算法細節,請參閱 :ref:`python_2.3_mro`。" -#: ../../glossary.rst:874 +#: ../../glossary.rst:879 msgid "module" msgstr "module(模組)" -#: ../../glossary.rst:876 +#: ../../glossary.rst:881 msgid "" "An object that serves as an organizational unit of Python code. Modules " "have a namespace containing arbitrary Python objects. Modules are loaded " @@ -2011,15 +2023,15 @@ msgstr "" "空間,它包含任意的 Python 物件。模組是藉由 :term:`importing` 的過程,被載入" "至 Python。" -#: ../../glossary.rst:880 +#: ../../glossary.rst:885 msgid "See also :term:`package`." msgstr "另請參閱 :term:`package`\\ (套件)。" -#: ../../glossary.rst:881 +#: ../../glossary.rst:886 msgid "module spec" msgstr "module spec(模組規格)" -#: ../../glossary.rst:883 +#: ../../glossary.rst:888 msgid "" "A namespace containing the import-related information used to load a module. " "An instance of :class:`importlib.machinery.ModuleSpec`." @@ -2027,23 +2039,23 @@ msgstr "" "一個命名空間,它包含用於載入模組的 import 相關資訊。它是 :class:`importlib." "machinery.ModuleSpec` 的一個實例。" -#: ../../glossary.rst:886 +#: ../../glossary.rst:891 msgid "See also :ref:`module-specs`." msgstr "另請參閱 :ref:`module-specs`。" -#: ../../glossary.rst:887 +#: ../../glossary.rst:892 msgid "MRO" msgstr "MRO" -#: ../../glossary.rst:889 +#: ../../glossary.rst:894 msgid "See :term:`method resolution order`." msgstr "請參閱 :term:`method resolution order`\\ (方法解析順序)。" -#: ../../glossary.rst:890 +#: ../../glossary.rst:895 msgid "mutable" msgstr "mutable(可變物件)" -#: ../../glossary.rst:892 +#: ../../glossary.rst:897 msgid "" "Mutable objects can change their value but keep their :func:`id`. See also :" "term:`immutable`." @@ -2051,11 +2063,11 @@ msgstr "" "可變物件可以改變它們的值,但維持它們的 :func:`id`。另請參閱 :term:" "`immutable`\\ (不可變物件)。" -#: ../../glossary.rst:894 +#: ../../glossary.rst:899 msgid "named tuple" msgstr "named tuple(附名元組)" -#: ../../glossary.rst:896 +#: ../../glossary.rst:901 msgid "" "The term \"named tuple\" applies to any type or class that inherits from " "tuple and whose indexable elements are also accessible using named " @@ -2065,7 +2077,7 @@ msgstr "" "索引 (indexable) 元素也可以用附名屬性來存取。這些型別或 class 也可以具有其他" "的特性。" -#: ../../glossary.rst:900 +#: ../../glossary.rst:905 msgid "" "Several built-in types are named tuples, including the values returned by :" "func:`time.localtime` and :func:`os.stat`. Another example is :data:`sys." @@ -2074,7 +2086,7 @@ msgstr "" "有些內建型別是 named tuple,包括由 :func:`time.localtime` 和 :func:`os.stat` " "回傳的值。另一個例子是 :data:`sys.float_info`: ::" -#: ../../glossary.rst:904 +#: ../../glossary.rst:909 msgid "" ">>> sys.float_info[1] # indexed access\n" "1024\n" @@ -2090,7 +2102,7 @@ msgstr "" ">>> isinstance(sys.float_info, tuple) # 屬於 tuple 型別\n" "True" -#: ../../glossary.rst:911 +#: ../../glossary.rst:916 msgid "" "Some named tuples are built-in types (such as the above examples). " "Alternatively, a named tuple can be created from a regular class definition " @@ -2107,11 +2119,11 @@ msgstr "" "namedtuple` 來建立。後者技術也增加了一些額外的 method,這些 method 可能是在手" "寫或內建的 named tuple 中,無法找到的。" -#: ../../glossary.rst:919 +#: ../../glossary.rst:924 msgid "namespace" msgstr "namespace(命名空間)" -#: ../../glossary.rst:921 +#: ../../glossary.rst:926 msgid "" "The place where a variable is stored. Namespaces are implemented as " "dictionaries. There are the local, global and built-in namespaces as well " @@ -2131,11 +2143,11 @@ msgstr "" "func:`itertools.islice` 明確地表示,這些函式分別是由 :mod:`random` 和 :mod:" "`itertools` 模組在實作。" -#: ../../glossary.rst:931 +#: ../../glossary.rst:936 msgid "namespace package" msgstr "namespace package(命名空間套件)" -#: ../../glossary.rst:933 +#: ../../glossary.rst:938 msgid "" "A :term:`package` which serves only as a container for subpackages. " "Namespace packages may have no physical representation, and specifically are " @@ -2145,7 +2157,7 @@ msgstr "" "名空間套件可能沒有實體的表示法,而且具體來說它們不像是一個 :term:`regular " "package`\\ (正規套件),因為它們並沒有 ``__init__.py`` 這個檔案。" -#: ../../glossary.rst:938 +#: ../../glossary.rst:943 msgid "" "Namespace packages allow several individually installable packages to have a " "common parent package. Otherwise, it is recommended to use a :term:`regular " @@ -2154,20 +2166,20 @@ msgstr "" "命名空間套件允許數個可獨立安裝的套件擁有一個共同的父套件。除此之外,建議使" "用 :term:`regular package`。" -#: ../../glossary.rst:941 +#: ../../glossary.rst:946 msgid "" "For more information, see :pep:`420` and :ref:`reference-namespace-package`." msgstr "更多資訊,請參閱 :pep:`420` 和 :ref:`reference-namespace-package`。" -#: ../../glossary.rst:943 +#: ../../glossary.rst:948 msgid "See also :term:`module`." msgstr "另請參閱 :term:`module`\\ (模組)。" -#: ../../glossary.rst:944 +#: ../../glossary.rst:949 msgid "nested scope" msgstr "nested scope(巢狀作用域)" -#: ../../glossary.rst:946 +#: ../../glossary.rst:951 msgid "" "The ability to refer to a variable in an enclosing definition. For " "instance, a function defined inside another function can refer to variables " @@ -2182,11 +2194,11 @@ msgstr "" "寫入。同樣地,全域變數是在全域命名空間中讀取及寫入。:keyword:`nonlocal` 容許" "對外層作用域進行寫入。" -#: ../../glossary.rst:953 +#: ../../glossary.rst:958 msgid "new-style class" msgstr "new-style class(新式類別)" -#: ../../glossary.rst:955 +#: ../../glossary.rst:960 msgid "" "Old name for the flavor of classes now used for all class objects. In " "earlier Python versions, only new-style classes could use Python's newer, " @@ -2198,11 +2210,11 @@ msgstr "" "__slots__`、描述器 (descriptor)、屬性 (property)、:meth:`~object." "__getattribute__`、class method(類別方法)和 static method(靜態方法)。" -#: ../../glossary.rst:960 +#: ../../glossary.rst:965 msgid "object" msgstr "object(物件)" -#: ../../glossary.rst:962 +#: ../../glossary.rst:967 msgid "" "Any data with state (attributes or value) and defined behavior (methods). " "Also the ultimate base class of any :term:`new-style class`." @@ -2210,11 +2222,11 @@ msgstr "" "具有狀態(屬性或值)及被定義的行為(method)的任何資料。它也是任何 :term:" "`new-style class`\\ (新式類別)的最終 base class(基底類別)。" -#: ../../glossary.rst:965 +#: ../../glossary.rst:970 msgid "optimized scope" msgstr "optimized scope(最佳化作用域)" -#: ../../glossary.rst:967 +#: ../../glossary.rst:972 msgid "" "A scope where target local variable names are reliably known to the compiler " "when the code is compiled, allowing optimization of read and write access to " @@ -2225,11 +2237,11 @@ msgid "" "to optimized scopes." msgstr "" -#: ../../glossary.rst:974 +#: ../../glossary.rst:979 msgid "package" msgstr "package(套件)" -#: ../../glossary.rst:976 +#: ../../glossary.rst:981 msgid "" "A Python :term:`module` which can contain submodules or recursively, " "subpackages. Technically, a package is a Python module with a ``__path__`` " @@ -2239,17 +2251,17 @@ msgstr "" "迴的子套件 (subpackage)。技術上而言,套件就是具有 ``__path__`` 屬性的一個 " "Python 模組。" -#: ../../glossary.rst:980 +#: ../../glossary.rst:985 msgid "See also :term:`regular package` and :term:`namespace package`." msgstr "" "另請參閱 :term:`regular package`\\ (正規套件)和 :term:`namespace " "package`\\ (命名空間套件)。" -#: ../../glossary.rst:981 +#: ../../glossary.rst:986 msgid "parameter" msgstr "parameter(參數)" -#: ../../glossary.rst:983 +#: ../../glossary.rst:988 msgid "" "A named entity in a :term:`function` (or method) definition that specifies " "an :term:`argument` (or in some cases, arguments) that the function can " @@ -2259,7 +2271,7 @@ msgstr "" "它指明該函式能夠接受的一個 :term:`argument`\\ (引數),或在某些情況下指示多" "個引數。共有有五種不同的參數類型:" -#: ../../glossary.rst:987 +#: ../../glossary.rst:992 msgid "" ":dfn:`positional-or-keyword`: specifies an argument that can be passed " "either :term:`positionally ` or as a :term:`keyword argument " @@ -2270,11 +2282,11 @@ msgstr "" "置 `\\ 或是作為\\ :term:`關鍵字引數 `\\ 被傳遞的引數。這" "是參數的預設類型,例如以下的 *foo* 和 *bar*: ::" -#: ../../glossary.rst:992 +#: ../../glossary.rst:997 msgid "def func(foo, bar=None): ..." msgstr "def func(foo, bar=None): ..." -#: ../../glossary.rst:996 +#: ../../glossary.rst:1001 msgid "" ":dfn:`positional-only`: specifies an argument that can be supplied only by " "position. Positional-only parameters can be defined by including a ``/`` " @@ -2285,11 +2297,11 @@ msgstr "" "式定義的參數列表中包含一個 ``/`` 字元,就可以在該字元前面定義僅限位置參數,例" "如以下的 *posonly1* 和 *posonly2*: ::" -#: ../../glossary.rst:1001 +#: ../../glossary.rst:1006 msgid "def func(posonly1, posonly2, /, positional_or_keyword): ..." msgstr "def func(posonly1, posonly2, /, positional_or_keyword): ..." -#: ../../glossary.rst:1005 +#: ../../glossary.rst:1010 msgid "" ":dfn:`keyword-only`: specifies an argument that can be supplied only by " "keyword. Keyword-only parameters can be defined by including a single var-" @@ -2302,11 +2314,11 @@ msgstr "" "單純的 ``*`` 字元,就可以在其後方定義僅限關鍵字參數,例如以下的 *kw_only1* " "和 *kw_only2*: ::" -#: ../../glossary.rst:1011 +#: ../../glossary.rst:1016 msgid "def func(arg, *, kw_only1, kw_only2): ..." msgstr "def func(arg, *, kw_only1, kw_only2): ..." -#: ../../glossary.rst:1013 +#: ../../glossary.rst:1018 msgid "" ":dfn:`var-positional`: specifies that an arbitrary sequence of positional " "arguments can be provided (in addition to any positional arguments already " @@ -2318,11 +2330,11 @@ msgstr "" "數(在已被其他參數接受的任何位置引數之外)。這類參數是透過在其參數名稱字首加" "上 ``*`` 來定義的,例如以下的 *args*: ::" -#: ../../glossary.rst:1019 +#: ../../glossary.rst:1024 msgid "def func(*args, **kwargs): ..." msgstr "def func(*args, **kwargs): ..." -#: ../../glossary.rst:1021 +#: ../../glossary.rst:1026 msgid "" ":dfn:`var-keyword`: specifies that arbitrarily many keyword arguments can be " "provided (in addition to any keyword arguments already accepted by other " @@ -2333,14 +2345,14 @@ msgstr "" "已被其他參數接受的任何關鍵字引數之外)。這類參數是透過在其參數名稱字首加上 " "``**`` 來定義的,例如上面範例中的 *kwargs*。" -#: ../../glossary.rst:1027 +#: ../../glossary.rst:1032 msgid "" "Parameters can specify both optional and required arguments, as well as " "default values for some optional arguments." msgstr "" "參數可以指明引數是選擇性的或必需的,也可以為一些選擇性的引數指定預設值。" -#: ../../glossary.rst:1030 +#: ../../glossary.rst:1035 msgid "" "See also the :term:`argument` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " @@ -2351,11 +2363,11 @@ msgstr "" "參數之間的差異 `、:class:`inspect.Parameter` " "class、:ref:`function`\\ 章節,以及 :pep:`362`。" -#: ../../glossary.rst:1034 +#: ../../glossary.rst:1039 msgid "path entry" msgstr "path entry(路徑項目)" -#: ../../glossary.rst:1036 +#: ../../glossary.rst:1041 msgid "" "A single location on the :term:`import path` which the :term:`path based " "finder` consults to find modules for importing." @@ -2363,11 +2375,11 @@ msgstr "" "在 :term:`import path`\\ (引入路徑)中的一個位置,而 :term:`path based " "finder` (基於路徑的尋檢器)會參考該位置來尋找要 import 的模組。" -#: ../../glossary.rst:1038 +#: ../../glossary.rst:1043 msgid "path entry finder" msgstr "path entry finder(路徑項目尋檢器)" -#: ../../glossary.rst:1040 +#: ../../glossary.rst:1045 msgid "" "A :term:`finder` returned by a callable on :data:`sys.path_hooks` (i.e. a :" "term:`path entry hook`) which knows how to locate modules given a :term:" @@ -2377,7 +2389,7 @@ msgstr "" "`path entry hook`\\ )所回傳的一種 :term:`finder`,它知道如何以一個 :term:" "`path entry`\\ 定位模組。" -#: ../../glossary.rst:1044 +#: ../../glossary.rst:1049 msgid "" "See :class:`importlib.abc.PathEntryFinder` for the methods that path entry " "finders implement." @@ -2385,11 +2397,11 @@ msgstr "" "關於路徑項目尋檢器實作的 method,請參閱 :class:`importlib.abc." "PathEntryFinder`。" -#: ../../glossary.rst:1046 +#: ../../glossary.rst:1051 msgid "path entry hook" msgstr "path entry hook(路徑項目鉤)" -#: ../../glossary.rst:1048 +#: ../../glossary.rst:1053 msgid "" "A callable on the :data:`sys.path_hooks` list which returns a :term:`path " "entry finder` if it knows how to find modules on a specific :term:`path " @@ -2399,11 +2411,11 @@ msgstr "" "個特定的 :term:`path entry` 中尋找模組,則會回傳一個 :term:`path entry " "finder`\\ (路徑項目尋檢器)。" -#: ../../glossary.rst:1051 +#: ../../glossary.rst:1056 msgid "path based finder" msgstr "path based finder(基於路徑的尋檢器)" -#: ../../glossary.rst:1053 +#: ../../glossary.rst:1058 msgid "" "One of the default :term:`meta path finders ` which " "searches an :term:`import path` for modules." @@ -2411,11 +2423,11 @@ msgstr "" "預設的\\ :term:`元路徑尋檢器 (meta path finder) ` 之一,它" "會在一個 :term:`import path` 中搜尋模組。" -#: ../../glossary.rst:1055 +#: ../../glossary.rst:1060 msgid "path-like object" msgstr "path-like object(類路徑物件)" -#: ../../glossary.rst:1057 +#: ../../glossary.rst:1062 msgid "" "An object representing a file system path. A path-like object is either a :" "class:`str` or :class:`bytes` object representing a path, or an object " @@ -2433,11 +2445,11 @@ msgstr "" "`os.fsencode` 則分別可用於確保 :class:`str` 及 :class:`bytes` 的結果。由 :" "pep:`519` 引入。" -#: ../../glossary.rst:1065 +#: ../../glossary.rst:1070 msgid "PEP" msgstr "PEP" -#: ../../glossary.rst:1067 +#: ../../glossary.rst:1072 msgid "" "Python Enhancement Proposal. A PEP is a design document providing " "information to the Python community, or describing a new feature for Python " @@ -2448,7 +2460,7 @@ msgstr "" "為 Python 社群提供資訊,或是描述 Python 的一個新功能或該功能的程序和環境。" "PEP 應該要提供簡潔的技術規範以及被提案功能的運作原理。" -#: ../../glossary.rst:1073 +#: ../../glossary.rst:1078 msgid "" "PEPs are intended to be the primary mechanisms for proposing major new " "features, for collecting community input on an issue, and for documenting " @@ -2460,15 +2472,15 @@ msgstr "" "已納入 Python 的設計決策的記錄,這些過程的主要機制。PEP 的作者要負責在社群內" "建立共識並記錄反對意見。" -#: ../../glossary.rst:1079 +#: ../../glossary.rst:1084 msgid "See :pep:`1`." msgstr "請參閱 :pep:`1`。" -#: ../../glossary.rst:1080 +#: ../../glossary.rst:1085 msgid "portion" msgstr "portion(部分)" -#: ../../glossary.rst:1082 +#: ../../glossary.rst:1087 msgid "" "A set of files in a single directory (possibly stored in a zip file) that " "contribute to a namespace package, as defined in :pep:`420`." @@ -2476,15 +2488,15 @@ msgstr "" "在單一目錄中的一組檔案(也可能儲存在一個 zip 檔中),這些檔案能對一個命名空間" "套件 (namespace package) 有所貢獻,如同 :pep:`420` 中的定義。" -#: ../../glossary.rst:1084 +#: ../../glossary.rst:1089 msgid "positional argument" msgstr "positional argument(位置引數)" -#: ../../glossary.rst:1087 +#: ../../glossary.rst:1092 msgid "provisional API" msgstr "provisional API(暫行 API)" -#: ../../glossary.rst:1089 +#: ../../glossary.rst:1094 msgid "" "A provisional API is one which has been deliberately excluded from the " "standard library's backwards compatibility guarantees. While major changes " @@ -2500,7 +2512,7 @@ msgstr "" "該介面)。這種變更並不會無端地產生——只有 API 被納入之前未察覺的嚴重基本缺陷被" "揭露時,它們才會發生。" -#: ../../glossary.rst:1098 +#: ../../glossary.rst:1103 msgid "" "Even for provisional APIs, backwards incompatible changes are seen as a " "\"solution of last resort\" - every attempt will still be made to find a " @@ -2509,7 +2521,7 @@ msgstr "" "即使對於暫行 API,向後不相容的變更也會被視為「最後的解決方案」——對於任何被發" "現的問題,仍然會盡可能找出一個向後相容的解決方案。" -#: ../../glossary.rst:1102 +#: ../../glossary.rst:1107 msgid "" "This process allows the standard library to continue to evolve over time, " "without locking in problematic design errors for extended periods of time. " @@ -2518,19 +2530,19 @@ msgstr "" "這個過程使得標準函式庫能隨著時間不斷進化,而避免耗費過長的時間去鎖定有問題的" "設計錯誤。請參閱 :pep:`411` 了解更多細節。" -#: ../../glossary.rst:1105 +#: ../../glossary.rst:1110 msgid "provisional package" msgstr "provisional package(暫行套件)" -#: ../../glossary.rst:1107 +#: ../../glossary.rst:1112 msgid "See :term:`provisional API`." msgstr "請參閱 :term:`provisional API`\\ (暫行 API)。" -#: ../../glossary.rst:1108 +#: ../../glossary.rst:1113 msgid "Python 3000" msgstr "Python 3000" -#: ../../glossary.rst:1110 +#: ../../glossary.rst:1115 msgid "" "Nickname for the Python 3.x release line (coined long ago when the release " "of version 3 was something in the distant future.) This is also abbreviated " @@ -2539,11 +2551,11 @@ msgstr "" "Python 3.x 系列版本的暱稱(很久以前創造的,當時第 3 版的發布是在遙遠的未" "來。)也可以縮寫為「Py3k」。" -#: ../../glossary.rst:1113 +#: ../../glossary.rst:1118 msgid "Pythonic" msgstr "Pythonic(Python 風格的)" -#: ../../glossary.rst:1115 +#: ../../glossary.rst:1120 msgid "" "An idea or piece of code which closely follows the most common idioms of the " "Python language, rather than implementing code using concepts common to " @@ -2557,7 +2569,7 @@ msgstr "" "keyword:`for` 陳述式,對一個可疊代物件的所有元素進行迴圈。許多其他語言並沒有" "這種類型的架構,所以不熟悉 Python 的人有時會使用一個數值計數器來代替: ::" -#: ../../glossary.rst:1122 +#: ../../glossary.rst:1127 msgid "" "for i in range(len(food)):\n" " print(food[i])" @@ -2565,11 +2577,11 @@ msgstr "" "for i in range(len(food)):\n" " print(food[i])" -#: ../../glossary.rst:1125 +#: ../../glossary.rst:1130 msgid "As opposed to the cleaner, Pythonic method::" msgstr "相較之下,以下方法更簡潔、更具有 Python 風格: ::" -#: ../../glossary.rst:1127 +#: ../../glossary.rst:1132 msgid "" "for piece in food:\n" " print(piece)" @@ -2577,11 +2589,11 @@ msgstr "" "for piece in food:\n" " print(piece)" -#: ../../glossary.rst:1129 +#: ../../glossary.rst:1134 msgid "qualified name" msgstr "qualified name(限定名稱)" -#: ../../glossary.rst:1131 +#: ../../glossary.rst:1136 msgid "" "A dotted name showing the \"path\" from a module's global scope to a class, " "function or method defined in that module, as defined in :pep:`3155`. For " @@ -2592,7 +2604,7 @@ msgstr "" "或 method 的「路徑」,如 :pep:`3155` 中的定義。對於頂層的函式和 class 而言," "限定名稱與其物件名稱相同: ::" -#: ../../glossary.rst:1136 +#: ../../glossary.rst:1141 msgid "" ">>> class C:\n" "... class D:\n" @@ -2618,7 +2630,7 @@ msgstr "" ">>> C.D.meth.__qualname__\n" "'C.D.meth'" -#: ../../glossary.rst:1148 +#: ../../glossary.rst:1153 msgid "" "When used to refer to modules, the *fully qualified name* means the entire " "dotted path to the module, including any parent packages, e.g. ``email.mime." @@ -2627,7 +2639,7 @@ msgstr "" "當用於引用模組時,*完全限定名稱 (fully qualified name)* 是表示該模組的完整點" "分隔路徑,包括任何的父套件,例如 ``email.mime.text``: ::" -#: ../../glossary.rst:1152 +#: ../../glossary.rst:1157 msgid "" ">>> import email.mime.text\n" ">>> email.mime.text.__name__\n" @@ -2637,11 +2649,11 @@ msgstr "" ">>> email.mime.text.__name__\n" "'email.mime.text'" -#: ../../glossary.rst:1155 +#: ../../glossary.rst:1160 msgid "reference count" msgstr "reference count(參照計數)" -#: ../../glossary.rst:1157 +#: ../../glossary.rst:1162 msgid "" "The number of references to an object. When the reference count of an " "object drops to zero, it is deallocated. Some objects are :term:`immortal` " @@ -2657,7 +2669,7 @@ msgstr "" "看不到,但它卻是 :term:`CPython` 實作的一個關鍵元素。程式設計師可以呼叫 :" "func:`~sys.getrefcount` 函式來回傳一個特定物件的參照計數。" -#: ../../glossary.rst:1166 +#: ../../glossary.rst:1171 msgid "" "In :term:`CPython`, reference counts are not considered to be stable or well-" "defined values; the number of references to an object, and how that number " @@ -2666,11 +2678,11 @@ msgstr "" "在 :term:`CPython` 中,參照計數不被視為穩定或明確定義的值;對物件的參照數量," "以及該數量如何受到 Python 程式碼的影響,在不同版本之間可能會有所不同。" -#: ../../glossary.rst:1170 +#: ../../glossary.rst:1175 msgid "regular package" msgstr "regular package(正規套件)" -#: ../../glossary.rst:1172 +#: ../../glossary.rst:1177 msgid "" "A traditional :term:`package`, such as a directory containing an ``__init__." "py`` file." @@ -2678,15 +2690,15 @@ msgstr "" "一個傳統的 :term:`package`\\ (套件),例如一個包含 ``__init__.py`` 檔案的目" "錄。" -#: ../../glossary.rst:1175 +#: ../../glossary.rst:1180 msgid "See also :term:`namespace package`." msgstr "另請參閱 :term:`namespace package`\\ (命名空間套件)。" -#: ../../glossary.rst:1176 +#: ../../glossary.rst:1181 msgid "REPL" msgstr "REPL" -#: ../../glossary.rst:1178 +#: ../../glossary.rst:1183 msgid "" "An acronym for the \"read–eval–print loop\", another name for the :term:" "`interactive` interpreter shell." @@ -2694,11 +2706,11 @@ msgstr "" "「read-eval-print 迴圈 (read–eval–print loop)」的縮寫,是\\ :term:`互動式 " "`\\ 直譯器 shell 的另一個名稱。" -#: ../../glossary.rst:1180 +#: ../../glossary.rst:1185 msgid "__slots__" msgstr "__slots__" -#: ../../glossary.rst:1182 +#: ../../glossary.rst:1187 msgid "" "A declaration inside a class that saves memory by pre-declaring space for " "instance attributes and eliminating instance dictionaries. Though popular, " @@ -2711,11 +2723,11 @@ msgstr "" "最好保留給那種在一個記憶體關鍵 (memory-critical) 的應用程式中存在大量實例的罕" "見情況。" -#: ../../glossary.rst:1187 +#: ../../glossary.rst:1192 msgid "sequence" msgstr "sequence(序列)" -#: ../../glossary.rst:1189 +#: ../../glossary.rst:1194 msgid "" "An :term:`iterable` which supports efficient element access using integer " "indices via the :meth:`~object.__getitem__` special method and defines a :" @@ -2734,7 +2746,7 @@ msgstr "" "為對映 (mapping) 而不是序列,因為其查找方式是使用任意的 :term:`hashable` 鍵," "而不是整數。" -#: ../../glossary.rst:1198 +#: ../../glossary.rst:1203 msgid "" "The :class:`collections.abc.Sequence` abstract base class defines a much " "richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:" @@ -2751,11 +2763,11 @@ msgstr "" "用 :func:`~abc.ABCMeta.register` 被明確地註冊。更多關於序列方法的文件,請見" "\\ :ref:`常見序列操作 `。" -#: ../../glossary.rst:1207 +#: ../../glossary.rst:1212 msgid "set comprehension" msgstr "set comprehension(集合綜合運算)" -#: ../../glossary.rst:1209 +#: ../../glossary.rst:1214 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a set with the results. ``results = {c for c in 'abracadabra' if c " @@ -2766,11 +2778,11 @@ msgstr "" "set 回傳。``results = {c for c in 'abracadabra' if c not in 'abc'}`` 會產生一" "個字串 set:``{'r', 'd'}``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:1213 +#: ../../glossary.rst:1218 msgid "single dispatch" msgstr "single dispatch(單一調度)" -#: ../../glossary.rst:1215 +#: ../../glossary.rst:1220 msgid "" "A form of :term:`generic function` dispatch where the implementation is " "chosen based on the type of a single argument." @@ -2778,11 +2790,11 @@ msgstr "" ":term:`generic function`\\ (泛型函式)調度的一種形式,在此,實作的選擇是基於" "單一引數的型別。" -#: ../../glossary.rst:1217 +#: ../../glossary.rst:1222 msgid "slice" msgstr "slice(切片)" -#: ../../glossary.rst:1219 +#: ../../glossary.rst:1224 msgid "" "An object usually containing a portion of a :term:`sequence`. A slice is " "created using the subscript notation, ``[]`` with colons between numbers " @@ -2794,11 +2806,11 @@ msgstr "" "之間使用冒號,例如 ``variable_name[1:3:5]``。在括號(下標)符號的內部,會使" "用 :class:`slice` 物件。" -#: ../../glossary.rst:1223 +#: ../../glossary.rst:1228 msgid "soft deprecated" msgstr "soft deprecated(軟性棄用)" -#: ../../glossary.rst:1225 +#: ../../glossary.rst:1230 msgid "" "A soft deprecated API should not be used in new code, but it is safe for " "already existing code to use it. The API remains documented and tested, but " @@ -2807,13 +2819,13 @@ msgstr "" "被軟性棄用的 API 代表不應再用於新程式碼中,但在現有程式碼中繼續使用它仍會是安" "全的。API 仍會以文件記錄並會被測試,但不會被繼續改進。" -#: ../../glossary.rst:1229 +#: ../../glossary.rst:1234 msgid "" "Soft deprecation, unlike normal deprecation, does not plan on removing the " "API and will not emit warnings." msgstr "與正常棄用不同,軟性棄用沒有刪除 API 的規劃,也不會發出警告。" -#: ../../glossary.rst:1232 +#: ../../glossary.rst:1237 msgid "" "See `PEP 387: Soft Deprecation `_." @@ -2821,11 +2833,11 @@ msgstr "" "請參閱 `PEP 387:軟性棄用 `_。" -#: ../../glossary.rst:1234 +#: ../../glossary.rst:1239 msgid "special method" msgstr "special method(特殊方法)" -#: ../../glossary.rst:1238 +#: ../../glossary.rst:1243 msgid "" "A method that is called implicitly by Python to execute a certain operation " "on a type, such as addition. Such methods have names starting and ending " @@ -2836,11 +2848,11 @@ msgstr "" "種 method 的名稱會在開頭和結尾有兩個下底線。Special method 在\\ :ref:" "`specialnames`\\ 中有詳細說明。" -#: ../../glossary.rst:1242 +#: ../../glossary.rst:1247 msgid "standard library" msgstr "標準函式庫" -#: ../../glossary.rst:1244 +#: ../../glossary.rst:1249 msgid "" "The collection of :term:`packages `, :term:`modules ` and :" "term:`extension modules ` distributed as a part of the " @@ -2853,7 +2865,7 @@ msgstr "" "行。該集合的成員可能會因平台、可用的系統函式庫或其他條件而有所不同。相關文件" "可以在 :ref:`library-index` 中找到。" -#: ../../glossary.rst:1250 +#: ../../glossary.rst:1255 msgid "" "See also :data:`sys.stdlib_module_names` for a list of all possible standard " "library module names." @@ -2861,11 +2873,11 @@ msgstr "" "請參閱 :data:`sys.stdlib_module_names` 以取得所有可能的標準函式庫模組名稱的列" "表。" -#: ../../glossary.rst:1252 +#: ../../glossary.rst:1257 msgid "statement" msgstr "statement(陳述式)" -#: ../../glossary.rst:1254 +#: ../../glossary.rst:1259 msgid "" "A statement is part of a suite (a \"block\" of code). A statement is either " "an :term:`expression` or one of several constructs with a keyword, such as :" @@ -2875,11 +2887,11 @@ msgstr "" "term:`expression`\\ (運算式),或是含有關鍵字(例如 :keyword:`if`、:keyword:" "`while` 或 :keyword:`for`\\ )的多種結構之一。" -#: ../../glossary.rst:1257 +#: ../../glossary.rst:1262 msgid "static type checker" msgstr "static type checker(靜態型別檢查器)" -#: ../../glossary.rst:1259 +#: ../../glossary.rst:1264 msgid "" "An external tool that reads Python code and analyzes it, looking for issues " "such as incorrect types. See also :term:`type hints ` and the :" @@ -2889,19 +2901,19 @@ msgstr "" "另請參閱\\ :term:`型別提示 (type hints) ` 以及 :mod:`typing` 模" "組。" -#: ../../glossary.rst:1262 +#: ../../glossary.rst:1267 msgid "stdlib" msgstr "stdlib(標準函式庫)" -#: ../../glossary.rst:1264 +#: ../../glossary.rst:1269 msgid "An abbreviation of :term:`standard library`." msgstr ":term:`standard library` 的縮寫。" -#: ../../glossary.rst:1265 +#: ../../glossary.rst:1270 msgid "strong reference" msgstr "strong reference(強參照)" -#: ../../glossary.rst:1267 +#: ../../glossary.rst:1272 msgid "" "In Python's C API, a strong reference is a reference to an object which is " "owned by the code holding the reference. The strong reference is taken by " @@ -2912,7 +2924,7 @@ msgstr "" "有。建立參照時透過呼叫 :c:func:`Py_INCREF` 來獲得強參照、刪除參照時透過 :c:" "func:`Py_DECREF` 釋放強參照。" -#: ../../glossary.rst:1273 +#: ../../glossary.rst:1278 msgid "" "The :c:func:`Py_NewRef` function can be used to create a strong reference to " "an object. Usually, the :c:func:`Py_DECREF` function must be called on the " @@ -2922,15 +2934,15 @@ msgstr "" ":c:func:`Py_NewRef` 函式可用於建立一個對物件的強參照。通常,在退出強參照的作" "用域之前,必須在該強參照上呼叫 :c:func:`Py_DECREF` 函式,以避免洩漏一個參照。" -#: ../../glossary.rst:1278 +#: ../../glossary.rst:1283 msgid "See also :term:`borrowed reference`." msgstr "另請參閱 :term:`borrowed reference`\\ (借用參照)。" -#: ../../glossary.rst:1279 +#: ../../glossary.rst:1284 msgid "text encoding" msgstr "text encoding(文字編碼)" -#: ../../glossary.rst:1281 +#: ../../glossary.rst:1286 msgid "" "A string in Python is a sequence of Unicode code points (in range " "``U+0000``--``U+10FFFF``). To store or transfer a string, it needs to be " @@ -2939,7 +2951,7 @@ msgstr "" "Python 中的字串是一個 Unicode 碼點 (code point) 的序列(範圍在 ``U+0000`` -- " "``U+10FFFF`` 之間)。若要儲存或傳送一個字串,它必須被序列化為一個位元組序列。" -#: ../../glossary.rst:1285 +#: ../../glossary.rst:1290 msgid "" "Serializing a string into a sequence of bytes is known as \"encoding\", and " "recreating the string from the sequence of bytes is known as \"decoding\"." @@ -2947,7 +2959,7 @@ msgstr "" "將一個字串序列化為位元組序列,稱為「編碼」,而從位元組序列重新建立該字串則稱" "為「解碼 (decoding)」。" -#: ../../glossary.rst:1288 +#: ../../glossary.rst:1293 msgid "" "There are a variety of different text serialization :ref:`codecs `, which are collectively referred to as \"text encodings\"." @@ -2955,11 +2967,11 @@ msgstr "" "有多種不同的文字序列化編解碼器 (:ref:`codecs `),它們被統" "稱為「文字編碼」。" -#: ../../glossary.rst:1291 +#: ../../glossary.rst:1296 msgid "text file" msgstr "text file(文字檔案)" -#: ../../glossary.rst:1293 +#: ../../glossary.rst:1298 msgid "" "A :term:`file object` able to read and write :class:`str` objects. Often, a " "text file actually accesses a byte-oriented datastream and handles the :term:" @@ -2973,7 +2985,7 @@ msgstr "" "有:以文字模式(``'r'`` 或 ``'w'``)開啟的檔案、:data:`sys.stdin`、:data:" "`sys.stdout` 以及 :class:`io.StringIO` 的實例。" -#: ../../glossary.rst:1300 +#: ../../glossary.rst:1305 msgid "" "See also :term:`binary file` for a file object able to read and write :term:" "`bytes-like objects `." @@ -2981,11 +2993,11 @@ msgstr "" "另請參閱 :term:`binary file`\\ (二進位檔案),它是一個能夠讀取和寫入\\ :" "term:`類位元組串物件 (bytes-like object) ` 的檔案物件。" -#: ../../glossary.rst:1302 +#: ../../glossary.rst:1307 msgid "token" msgstr "token" -#: ../../glossary.rst:1305 +#: ../../glossary.rst:1310 msgid "" "A small unit of source code, generated by the :ref:`lexical analyzer " "` (also called the *tokenizer*). Names, numbers, strings, " @@ -2994,19 +3006,19 @@ msgstr "" "原始碼的小單位,由 :ref:`詞法分析器 ` (也稱為 *tokenizer*)產生。名" "稱、數字、字串、運算子、換行符號等都以 token 表示。" -#: ../../glossary.rst:1310 +#: ../../glossary.rst:1315 msgid "" "The :mod:`tokenize` module exposes Python's lexical analyzer. The :mod:" "`token` module contains information on the various types of tokens." msgstr "" -":mod:`tokenize` 模組公開了 Python 的詞法分析器。:mod:`token` 模組包含各種 token " -"類型的資訊。" +":mod:`tokenize` 模組公開了 Python 的詞法分析器。:mod:`token` 模組包含各種 " +"token 類型的資訊。" -#: ../../glossary.rst:1313 +#: ../../glossary.rst:1318 msgid "triple-quoted string" msgstr "triple-quoted string(三引號內字串)" -#: ../../glossary.rst:1315 +#: ../../glossary.rst:1320 msgid "" "A string which is bound by three instances of either a quotation mark (\") " "or an apostrophe ('). While they don't provide any functionality not " @@ -3021,11 +3033,11 @@ msgstr "" "中包含未跳脫 (unescaped) 的單引號和雙引號,而且它們不需使用連續字元 " "(continuation character) 就可以跨越多行,這使得它們在編寫說明字串時特別有用。" -#: ../../glossary.rst:1322 +#: ../../glossary.rst:1327 msgid "type" msgstr "type(型別)" -#: ../../glossary.rst:1324 +#: ../../glossary.rst:1329 msgid "" "The type of a Python object determines what kind of object it is; every " "object has a type. An object's type is accessible as its :attr:`~object." @@ -3035,22 +3047,22 @@ msgstr "" "件的型別可以用它的 :attr:`~object.__class__` 屬性來存取,或以 ``type(obj)`` " "來檢索。" -#: ../../glossary.rst:1328 +#: ../../glossary.rst:1333 msgid "type alias" msgstr "type alias(型別別名)" -#: ../../glossary.rst:1330 +#: ../../glossary.rst:1335 msgid "A synonym for a type, created by assigning the type to an identifier." msgstr "一個型別的同義詞,透過將型別指定給一個識別符 (identifier) 來建立。" -#: ../../glossary.rst:1332 +#: ../../glossary.rst:1337 msgid "" "Type aliases are useful for simplifying :term:`type hints `. For " "example::" msgstr "" "型別別名對於簡化\\ :term:`型別提示 (type hint) ` 很有用。例如: ::" -#: ../../glossary.rst:1335 +#: ../../glossary.rst:1340 msgid "" "def remove_gray_shades(\n" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" @@ -3060,11 +3072,11 @@ msgstr "" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" " pass" -#: ../../glossary.rst:1339 +#: ../../glossary.rst:1344 msgid "could be made more readable like this::" msgstr "可以寫成這樣,更具有可讀性: ::" -#: ../../glossary.rst:1341 +#: ../../glossary.rst:1346 msgid "" "Color = tuple[int, int, int]\n" "\n" @@ -3076,15 +3088,15 @@ msgstr "" "def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" " pass" -#: ../../glossary.rst:1346 ../../glossary.rst:1360 +#: ../../glossary.rst:1351 ../../glossary.rst:1365 msgid "See :mod:`typing` and :pep:`484`, which describe this functionality." msgstr "請參閱 :mod:`typing` 和 :pep:`484`,有此功能的描述。" -#: ../../glossary.rst:1347 +#: ../../glossary.rst:1352 msgid "type hint" msgstr "type hint(型別提示)" -#: ../../glossary.rst:1349 +#: ../../glossary.rst:1354 msgid "" "An :term:`annotation` that specifies the expected type for a variable, a " "class attribute, or a function parameter or return value." @@ -3092,7 +3104,7 @@ msgstr "" "一種 :term:`annotation`\\ (註釋),它指定一個變數、一個 class 屬性或一個函式" "的參數或回傳值的預期型別。" -#: ../../glossary.rst:1352 +#: ../../glossary.rst:1357 msgid "" "Type hints are optional and are not enforced by Python but they are useful " "to :term:`static type checkers `. They can also aid " @@ -3102,7 +3114,7 @@ msgstr "" "(static type checkers) `\\ 很有用,並能協助 IDE 完成程式" "碼的補全 (completion) 和重構 (refactoring)。" -#: ../../glossary.rst:1356 +#: ../../glossary.rst:1361 msgid "" "Type hints of global variables, class attributes, and functions, but not " "local variables, can be accessed using :func:`typing.get_type_hints`." @@ -3110,11 +3122,11 @@ msgstr "" "全域變數、class 屬性和函式(不含區域變數)的型別提示,都可以使用 :func:" "`typing.get_type_hints` 來存取。" -#: ../../glossary.rst:1361 +#: ../../glossary.rst:1366 msgid "universal newlines" msgstr "universal newlines(通用換行字元)" -#: ../../glossary.rst:1363 +#: ../../glossary.rst:1368 msgid "" "A manner of interpreting text streams in which all of the following are " "recognized as ending a line: the Unix end-of-line convention ``'\\n'``, the " @@ -3127,20 +3139,20 @@ msgstr "" "``'\\r'``。請參閱 :pep:`278` 和 :pep:`3116`,以及用於 :func:`bytes." "splitlines` 的附加用途。" -#: ../../glossary.rst:1368 +#: ../../glossary.rst:1373 msgid "variable annotation" msgstr "variable annotation(變數註釋)" -#: ../../glossary.rst:1370 +#: ../../glossary.rst:1375 msgid "An :term:`annotation` of a variable or a class attribute." msgstr "一個變數或 class 屬性的 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:1372 +#: ../../glossary.rst:1377 msgid "" "When annotating a variable or a class attribute, assignment is optional::" msgstr "註釋變數或 class 屬性時,賦值是選擇性的: ::" -#: ../../glossary.rst:1374 +#: ../../glossary.rst:1379 msgid "" "class C:\n" " field: 'annotation'" @@ -3148,7 +3160,7 @@ msgstr "" "class C:\n" " field: 'annotation'" -#: ../../glossary.rst:1377 +#: ../../glossary.rst:1382 msgid "" "Variable annotations are usually used for :term:`type hints `: " "for example this variable is expected to take :class:`int` values::" @@ -3156,15 +3168,15 @@ msgstr "" "變數註釋通常用於\\ :term:`型別提示 (type hint) `:例如,這個變數預" "期會取得 :class:`int`\\ (整數)值: ::" -#: ../../glossary.rst:1381 +#: ../../glossary.rst:1386 msgid "count: int = 0" msgstr "count: int = 0" -#: ../../glossary.rst:1383 +#: ../../glossary.rst:1388 msgid "Variable annotation syntax is explained in section :ref:`annassign`." msgstr "變數註釋的語法在\\ :ref:`annassign`\\ 章節有詳細的解釋。" -#: ../../glossary.rst:1385 +#: ../../glossary.rst:1390 msgid "" "See :term:`function annotation`, :pep:`484` and :pep:`526`, which describe " "this functionality. Also see :ref:`annotations-howto` for best practices on " @@ -3173,11 +3185,11 @@ msgstr "" "請參閱 :term:`function annotation`\\ (函式註釋)、:pep:`484` 和 :pep:`526`," "皆有此功能的描述。關於註釋的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:1389 +#: ../../glossary.rst:1394 msgid "virtual environment" msgstr "virtual environment(虛擬環境)" -#: ../../glossary.rst:1391 +#: ../../glossary.rst:1396 msgid "" "A cooperatively isolated runtime environment that allows Python users and " "applications to install and upgrade Python distribution packages without " @@ -3188,15 +3200,15 @@ msgstr "" "程式得以安裝和升級 Python 發佈套件,而不會對同一個系統上運行的其他 Python 應" "用程式的行為產生干擾。" -#: ../../glossary.rst:1396 +#: ../../glossary.rst:1401 msgid "See also :mod:`venv`." msgstr "另請參閱 :mod:`venv`。" -#: ../../glossary.rst:1397 +#: ../../glossary.rst:1402 msgid "virtual machine" msgstr "virtual machine(虛擬機器)" -#: ../../glossary.rst:1399 +#: ../../glossary.rst:1404 msgid "" "A computer defined entirely in software. Python's virtual machine executes " "the :term:`bytecode` emitted by the bytecode compiler." @@ -3204,11 +3216,23 @@ msgstr "" "一部完全由軟體所定義的電腦 (computer)。Python 的虛擬機器會執行由 :term:" "`bytecode`\\ (位元組碼)編譯器所發出的位元組碼。" -#: ../../glossary.rst:1401 +#: ../../glossary.rst:1406 +#, fuzzy +msgid "walrus operator" +msgstr "asynchronous iterator(非同步疊代器)" + +#: ../../glossary.rst:1408 +msgid "" +"A light-hearted way to refer to the :ref:`assignment expression ` operator ``:=`` because it looks a bit like a walrus if you " +"turn your head." +msgstr "" + +#: ../../glossary.rst:1411 msgid "Zen of Python" msgstr "Zen of Python(Python 之禪)" -#: ../../glossary.rst:1403 +#: ../../glossary.rst:1413 msgid "" "Listing of Python design principles and philosophies that are helpful in " "understanding and using the language. The listing can be found by typing " @@ -3225,11 +3249,11 @@ msgstr "C-contiguous(C 連續的)" msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" -#: ../../glossary.rst:831 +#: ../../glossary.rst:836 msgid "magic" msgstr "magic" -#: ../../glossary.rst:1236 +#: ../../glossary.rst:1241 msgid "special" msgstr "special" diff --git a/library/codecs.po b/library/codecs.po index fdd1bfcb7c..0316e8e612 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-28 00:20+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2018-05-23 14:40+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1536,7 +1536,7 @@ msgid "IBM775" msgstr "IBM775" #: ../../library/codecs.rst:1129 ../../library/codecs.rst:1196 -#: ../../library/codecs.rst:1246 ../../library/codecs.rst:1263 +#: ../../library/codecs.rst:1263 msgid "Baltic languages" msgstr "" @@ -2018,6 +2018,10 @@ msgstr "iso8859_4" msgid "iso-8859-4, latin4, L4" msgstr "iso-8859-4, latin4, L4" +#: ../../library/codecs.rst:1246 +msgid "Northern Europe" +msgstr "" + #: ../../library/codecs.rst:1248 msgid "iso8859_5" msgstr "iso8859_5" diff --git a/library/fractions.po b/library/fractions.po index 92a898b867..c3f5ecb277 100644 --- a/library/fractions.po +++ b/library/fractions.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2016-01-31 07:18+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,23 +33,23 @@ msgstr "" #: ../../library/fractions.rst:17 msgid "" -"A Fraction instance can be constructed from a pair of integers, from another " -"rational number, or from a string." +"A Fraction instance can be constructed from a pair of rational numbers, from " +"a single number, or from a string." msgstr "" #: ../../library/fractions.rst:26 msgid "" "The first version requires that *numerator* and *denominator* are instances " "of :class:`numbers.Rational` and returns a new :class:`Fraction` instance " -"with value ``numerator/denominator``. If *denominator* is ``0``, it raises " -"a :exc:`ZeroDivisionError`. The second version requires that " -"*other_fraction* is an instance of :class:`numbers.Rational` and returns " -"a :class:`Fraction` instance with the same value. The next two versions " -"accept either a :class:`float` or a :class:`decimal.Decimal` instance, and " -"return a :class:`Fraction` instance with exactly the same value. Note that " -"due to the usual issues with binary floating point (see :ref:`tut-fp-" -"issues`), the argument to ``Fraction(1.1)`` is not exactly equal to 11/10, " -"and so ``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might " +"with a value equal to ``numerator/denominator``. If *denominator* is zero, " +"it raises a :exc:`ZeroDivisionError`. The second version requires that " +"*other_fraction* is an instance of :class:`numbers.Rational` and returns a :" +"class:`Fraction` instance with the same value. The next two versions accept " +"either a :class:`float` or a :class:`decimal.Decimal` instance, and return " +"a :class:`Fraction` instance with exactly the same value. Note that due to " +"the usual issues with binary floating point (see :ref:`tut-fp-issues`), the " +"argument to ``Fraction(1.1)`` is not exactly equal to 11/10, and so " +"``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might " "expect. (But see the documentation for the :meth:`limit_denominator` method " "below.) The last version of the constructor expects a string or unicode " "instance. The usual form for this instance is::" @@ -64,10 +64,10 @@ msgid "" "where the optional ``sign`` may be either '+' or '-' and ``numerator`` and " "``denominator`` (if present) are strings of decimal digits (underscores may " "be used to delimit digits as with integral literals in code). In addition, " -"any string that represents a finite value and is accepted by " -"the :class:`float` constructor is also accepted by the :class:`Fraction` " -"constructor. In either form the input string may also have leading and/or " -"trailing whitespace. Here are some examples::" +"any string that represents a finite value and is accepted by the :class:" +"`float` constructor is also accepted by the :class:`Fraction` constructor. " +"In either form the input string may also have leading and/or trailing " +"whitespace. Here are some examples::" msgstr "" #: ../../library/fractions.rst:52 @@ -124,18 +124,20 @@ msgstr "" #: ../../library/fractions.rst:78 msgid "" -"The :class:`Fraction` class inherits from the abstract base " -"class :class:`numbers.Rational`, and implements all of the methods and " -"operations from that class. :class:`Fraction` instances " -"are :term:`hashable`, and should be treated as immutable. In " -"addition, :class:`Fraction` has the following properties and methods:" +"The :class:`Fraction` class inherits from the abstract base class :class:" +"`numbers.Rational`, and implements all of the methods and operations from " +"that class. :class:`Fraction` instances are :term:`hashable`, and should be " +"treated as immutable. In addition, :class:`Fraction` has the following " +"properties and methods:" msgstr "" #: ../../library/fractions.rst:84 msgid "" -"The :class:`Fraction` constructor now accepts :class:`float` " -"and :class:`decimal.Decimal` instances." -msgstr ":class:`Fraction` 建構函式現在可接受 :class:`float` 和 :class:`decimal.Decimal` 實例。" +"The :class:`Fraction` constructor now accepts :class:`float` and :class:" +"`decimal.Decimal` instances." +msgstr "" +":class:`Fraction` 建構函式現在可接受 :class:`float` 和 :class:`decimal." +"Decimal` 實例。" #: ../../library/fractions.rst:88 msgid "" @@ -152,8 +154,8 @@ msgstr "" #: ../../library/fractions.rst:97 msgid "" -":class:`Fraction` implements ``__int__`` now to satisfy " -"``typing.SupportsInt`` instance checks." +":class:`Fraction` implements ``__int__`` now to satisfy ``typing." +"SupportsInt`` instance checks." msgstr "" #: ../../library/fractions.rst:101 @@ -179,84 +181,84 @@ msgid "Numerator of the Fraction in lowest term." msgstr "" #: ../../library/fractions.rst:119 -msgid "Denominator of the Fraction in lowest term." +msgid "Denominator of the Fraction in lowest terms. Guaranteed to be positive." msgstr "" -#: ../../library/fractions.rst:124 +#: ../../library/fractions.rst:125 msgid "" "Return a tuple of two integers, whose ratio is equal to the original " "Fraction. The ratio is in lowest terms and has a positive denominator." msgstr "" -#: ../../library/fractions.rst:132 +#: ../../library/fractions.rst:133 msgid "Return ``True`` if the Fraction is an integer." msgstr "" -#: ../../library/fractions.rst:138 +#: ../../library/fractions.rst:139 msgid "" -"Alternative constructor which only accepts instances of :class:`float` " -"or :class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is " -"not the same value as ``Fraction(3, 10)``." +"Alternative constructor which only accepts instances of :class:`float` or :" +"class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is not " +"the same value as ``Fraction(3, 10)``." msgstr "" -#: ../../library/fractions.rst:144 +#: ../../library/fractions.rst:145 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`float`." msgstr "" -#: ../../library/fractions.rst:150 +#: ../../library/fractions.rst:151 msgid "" -"Alternative constructor which only accepts instances " -"of :class:`decimal.Decimal` or :class:`numbers.Integral`." +"Alternative constructor which only accepts instances of :class:`decimal." +"Decimal` or :class:`numbers.Integral`." msgstr "" -#: ../../library/fractions.rst:155 +#: ../../library/fractions.rst:156 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`decimal.Decimal` instance." msgstr "" -#: ../../library/fractions.rst:162 +#: ../../library/fractions.rst:163 msgid "" "Finds and returns the closest :class:`Fraction` to ``self`` that has " "denominator at most max_denominator. This method is useful for finding " "rational approximations to a given floating-point number:" msgstr "" -#: ../../library/fractions.rst:170 +#: ../../library/fractions.rst:171 msgid "or for recovering a rational number that's represented as a float:" msgstr "" -#: ../../library/fractions.rst:183 +#: ../../library/fractions.rst:184 msgid "" "Returns the greatest :class:`int` ``<= self``. This method can also be " "accessed through the :func:`math.floor` function:" msgstr "" -#: ../../library/fractions.rst:193 +#: ../../library/fractions.rst:194 msgid "" "Returns the least :class:`int` ``>= self``. This method can also be " "accessed through the :func:`math.ceil` function." msgstr "" -#: ../../library/fractions.rst:200 +#: ../../library/fractions.rst:201 msgid "" "The first version returns the nearest :class:`int` to ``self``, rounding " "half to even. The second version rounds ``self`` to the nearest multiple of " "``Fraction(1, 10**ndigits)`` (logically, if ``ndigits`` is negative), again " -"rounding half toward even. This method can also be accessed through " -"the :func:`round` function." +"rounding half toward even. This method can also be accessed through the :" +"func:`round` function." msgstr "" -#: ../../library/fractions.rst:208 +#: ../../library/fractions.rst:209 msgid "" -"Provides support for formatting of :class:`Fraction` instances via " -"the :meth:`str.format` method, the :func:`format` built-in function, " -"or :ref:`Formatted string literals `." +"Provides support for formatting of :class:`Fraction` instances via the :meth:" +"`str.format` method, the :func:`format` built-in function, or :ref:" +"`Formatted string literals `." msgstr "" -#: ../../library/fractions.rst:212 +#: ../../library/fractions.rst:213 msgid "" "If the ``format_spec`` format specification string does not end with one of " "the presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` " @@ -268,7 +270,7 @@ msgid "" "exact integer. The zero-fill flag ``'0'`` is not supported." msgstr "" -#: ../../library/fractions.rst:222 +#: ../../library/fractions.rst:223 msgid "" "If the ``format_spec`` format specification string ends with one of the " "presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` or " @@ -276,11 +278,11 @@ msgid "" "type in the :ref:`formatspec` section." msgstr "" -#: ../../library/fractions.rst:227 +#: ../../library/fractions.rst:228 msgid "Here are some examples::" msgstr "" -#: ../../library/fractions.rst:229 +#: ../../library/fractions.rst:230 msgid "" ">>> from fractions import Fraction\n" ">>> format(Fraction(103993, 33102), '_')\n" @@ -320,10 +322,10 @@ msgstr "" ">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" "'34.67% price increase'" -#: ../../library/fractions.rst:251 +#: ../../library/fractions.rst:252 msgid "Module :mod:`numbers`" msgstr ":mod:`numbers` 模組" -#: ../../library/fractions.rst:252 +#: ../../library/fractions.rst:253 msgid "The abstract base classes making up the numeric tower." msgstr "" diff --git a/library/numbers.po b/library/numbers.po index db32c6ca63..d33387bbdc 100644 --- a/library/numbers.po +++ b/library/numbers.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-22 08:51+0000\n" +"POT-Creation-Date: 2025-08-06 00:17+0000\n" "PO-Revision-Date: 2022-11-16 04:57+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -120,9 +120,15 @@ msgstr "" ":attr:`~Rational.numerator` 和 :attr:`~Rational.denominator` 的值必須是 :" "class:`Integral` 的實例且 :attr:`~Rational.denominator` 要是正數。" -#: ../../library/numbers.rst:72 ../../library/numbers.rst:76 -msgid "Abstract." -msgstr "為抽象的。" +#: ../../library/numbers.rst:72 +#, fuzzy +msgid "Abstract. The numerator of this rational number." +msgstr "為抽象的。取得該數值的實數部分。" + +#: ../../library/numbers.rst:76 +#, fuzzy +msgid "Abstract. The denominator of this rational number." +msgstr "為抽象的。取得該數值的實數部分。" #: ../../library/numbers.rst:81 msgid "" @@ -420,3 +426,6 @@ msgstr "" "__add__, __radd__ = _operator_fallbacks(_add, operator.add)\n" "\n" "# ..." + +#~ msgid "Abstract." +#~ msgstr "為抽象的。" From 1f672a1e0269d0e41ca638475d1da87003238da5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 7 Aug 2025 00:19:24 +0000 Subject: [PATCH 07/13] sync with cpython 7762de25 --- library/warnings.po | 30 ++-- reference/compound_stmts.po | 286 ++++++++++++++++++------------------ 2 files changed, 159 insertions(+), 157 deletions(-) diff --git a/library/warnings.po b/library/warnings.po index dac5cbe821..136d899866 100644 --- a/library/warnings.po +++ b/library/warnings.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-03 00:14+0000\n" +"POT-Creation-Date: 2025-08-07 00:18+0000\n" "PO-Revision-Date: 2025-07-14 13:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -406,8 +406,8 @@ msgid "" "If a warning is reported and doesn't match any registered filter then the " "\"default\" action is applied (hence its name)." msgstr "" -"如果一個警告被回報且不匹配任何已註冊的過濾器,則會套用 \"default\" 動作(因此得" -"名)。" +"如果一個警告被回報且不匹配任何已註冊的過濾器,則會套用 \"default\" 動作(因此" +"得名)。" #: ../../library/warnings.rst:185 msgid "Repeated Warning Suppression Criteria" @@ -937,9 +937,10 @@ msgstr "" " lower.one_way(**kw)" #: ../../library/warnings.rst:453 +#, fuzzy msgid "" "This makes the warning refer to both the ``example.lower.one_way()`` and " -"``package.higher.another_way()`` call sites only from calling code living " +"``example.higher.another_way()`` call sites only from calling code living " "outside of ``example`` package." msgstr "" "這使得警告只會從存在於 ``example`` 套件之外的呼叫程式碼中,指向 ``example." @@ -983,8 +984,9 @@ msgid "" "displaying source for modules found in zipfiles or other non-filesystem " "import sources)." msgstr "" -"*module_globals*\\ (如果提供)應該是發出警告的程式碼所使用的全域命名空間。(此" -"引數用於支援顯示在 zip 檔案或其他非檔案系統引入來源中找到的模組的原始碼)。" +"*module_globals*\\ (如果提供)應該是發出警告的程式碼所使用的全域命名空間。" +"(此引數用於支援顯示在 zip 檔案或其他非檔案系統引入來源中找到的模組的原始" +"碼)。" #: ../../library/warnings.rst:486 msgid "Add the *source* parameter." @@ -1124,9 +1126,10 @@ msgid "" msgstr "" "由 *category* 指定的警告將在使用已棄用物件時於 runtime 發出。對於函式,這發生" "在呼叫時;對於類別,發生在實例化和建立子類別時。如果 *category* 是 ``None``," -"則在 runtime 不會發出警告。*stacklevel* 決定了警告發出的位置。如果它是 ``1``\\ " -"(預設值),警告會在已棄用物件的直接呼叫者處發出;如果更高,它會在堆疊的更上" -"層發出。靜態型別檢查器的行為不受 *category* 和 *stacklevel* 引數的影響。" +"則在 runtime 不會發出警告。*stacklevel* 決定了警告發出的位置。如果它是 " +"``1``\\ (預設值),警告會在已棄用物件的直接呼叫者處發出;如果更高,它會在堆" +"疊的更上層發出。靜態型別檢查器的行為不受 *category* 和 *stacklevel* 引數的影" +"響。" #: ../../library/warnings.rst:577 msgid "" @@ -1159,10 +1162,11 @@ msgid "" "has attributes with the same names as the arguments to :func:`showwarning`." msgstr "" "一個情境管理器,它會複製並在退出時恢復警告過濾器和 :func:`showwarning` 函式。" -"如果 *record* 引數為 :const:`False`\\ (預設值),情境管理器在進入時回傳 :class:" -"`None`。如果 *record* 為 :const:`True`,則會回傳一個串列,該串列會由自訂的 :" -"func:`showwarning` 函式(該函式也會抑制對 ``sys.stdout`` 的輸出)所看到的物件" -"逐步填充。串列中的每個物件都具有與 :func:`showwarning` 的引數同名的屬性。" +"如果 *record* 引數為 :const:`False`\\ (預設值),情境管理器在進入時回傳 :" +"class:`None`。如果 *record* 為 :const:`True`,則會回傳一個串列,該串列會由自" +"訂的 :func:`showwarning` 函式(該函式也會抑制對 ``sys.stdout`` 的輸出)所看到" +"的物件逐步填充。串列中的每個物件都具有與 :func:`showwarning` 的引數同名的屬" +"性。" #: ../../library/warnings.rst:602 msgid "" diff --git a/reference/compound_stmts.po b/reference/compound_stmts.po index 9930b44306..a60aae4a99 100644 --- a/reference/compound_stmts.po +++ b/reference/compound_stmts.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-22 00:13+0000\n" +"POT-Creation-Date: 2025-08-07 00:18+0000\n" "PO-Revision-Date: 2018-05-23 16:17+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,10 +33,10 @@ msgstr "" msgid "" "The :keyword:`if`, :keyword:`while` and :keyword:`for` statements implement " "traditional control flow constructs. :keyword:`try` specifies exception " -"handlers and/or cleanup code for a group of statements, while " -"the :keyword:`with` statement allows the execution of initialization and " -"finalization code around a block of code. Function and class definitions " -"are also syntactically compound statements." +"handlers and/or cleanup code for a group of statements, while the :keyword:" +"`with` statement allows the execution of initialization and finalization " +"code around a block of code. Function and class definitions are also " +"syntactically compound statements." msgstr "" #: ../../reference/compound_stmts.rst:26 @@ -78,8 +78,8 @@ msgid "" "Note that statements always end in a ``NEWLINE`` possibly followed by a " "``DEDENT``. Also note that optional continuation clauses always begin with " "a keyword that cannot start a statement, thus there are no ambiguities (the " -"'dangling :keyword:`else`' problem is solved in Python by requiring " -"nested :keyword:`if` statements to be indented)." +"'dangling :keyword:`else`' problem is solved in Python by requiring nested :" +"keyword:`if` statements to be indented)." msgstr "" #: ../../reference/compound_stmts.rst:75 @@ -127,9 +127,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:133 msgid "" "A :keyword:`break` statement executed in the first suite terminates the loop " -"without executing the :keyword:`!else` clause's suite. " -"A :keyword:`continue` statement executed in the first suite skips the rest " -"of the suite and goes back to testing the expression." +"without executing the :keyword:`!else` clause's suite. A :keyword:" +"`continue` statement executed in the first suite skips the rest of the suite " +"and goes back to testing the expression." msgstr "" #: ../../reference/compound_stmts.rst:142 @@ -144,23 +144,22 @@ msgstr "" #: ../../reference/compound_stmts.rst:160 msgid "" -"The ``starred_list`` expression is evaluated once; it should yield " -"an :term:`iterable` object. An :term:`iterator` is created for that " -"iterable. The first item provided by the iterator is then assigned to the " -"target list using the standard rules for assignments " -"(see :ref:`assignment`), and the suite is executed. This repeats for each " -"item provided by the iterator. When the iterator is exhausted, the suite in " -"the :keyword:`!else` clause, if present, is executed, and the loop " -"terminates." +"The ``starred_list`` expression is evaluated once; it should yield an :term:" +"`iterable` object. An :term:`iterator` is created for that iterable. The " +"first item provided by the iterator is then assigned to the target list " +"using the standard rules for assignments (see :ref:`assignment`), and the " +"suite is executed. This repeats for each item provided by the iterator. " +"When the iterator is exhausted, the suite in the :keyword:`!else` clause, if " +"present, is executed, and the loop terminates." msgstr "" #: ../../reference/compound_stmts.rst:173 msgid "" "A :keyword:`break` statement executed in the first suite terminates the loop " -"without executing the :keyword:`!else` clause's suite. " -"A :keyword:`continue` statement executed in the first suite skips the rest " -"of the suite and continues with the next item, or with the :keyword:`!else` " -"clause if there is no next item." +"without executing the :keyword:`!else` clause's suite. A :keyword:" +"`continue` statement executed in the first suite skips the rest of the suite " +"and continues with the next item, or with the :keyword:`!else` clause if " +"there is no next item." msgstr "" #: ../../reference/compound_stmts.rst:179 @@ -204,9 +203,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:231 msgid "" -"Additional information on exceptions can be found in " -"section :ref:`exceptions`, and information on using the :keyword:`raise` " -"statement to generate exceptions may be found in section :ref:`raise`." +"Additional information on exceptions can be found in section :ref:" +"`exceptions`, and information on using the :keyword:`raise` statement to " +"generate exceptions may be found in section :ref:`raise`." msgstr "" #: ../../reference/compound_stmts.rst:239 @@ -252,13 +251,13 @@ msgstr "" #: ../../reference/compound_stmts.rst:267 msgid "" "When a matching :keyword:`!except` clause is found, the exception is " -"assigned to the target specified after the :keyword:`!as` keyword in " -"that :keyword:`!except` clause, if present, and the :keyword:`!except` " -"clause's suite is executed. All :keyword:`!except` clauses must have an " -"executable block. When the end of this block is reached, execution continues " -"normally after the entire :keyword:`try` statement. (This means that if two " -"nested handlers exist for the same exception, and the exception occurs in " -"the :keyword:`!try` clause of the inner handler, the outer handler will not " +"assigned to the target specified after the :keyword:`!as` keyword in that :" +"keyword:`!except` clause, if present, and the :keyword:`!except` clause's " +"suite is executed. All :keyword:`!except` clauses must have an executable " +"block. When the end of this block is reached, execution continues normally " +"after the entire :keyword:`try` statement. (This means that if two nested " +"handlers exist for the same exception, and the exception occurs in the :" +"keyword:`!try` clause of the inner handler, the outer handler will not " "handle the exception.)" msgstr "" @@ -356,15 +355,15 @@ msgstr ":keyword:`!except*` 子句" #: ../../reference/compound_stmts.rst:335 msgid "" -"The :keyword:`!except*` clause(s) are used for " -"handling :exc:`ExceptionGroup`\\s. The exception type for matching is " -"interpreted as in the case of :keyword:`except`, but in the case of " -"exception groups we can have partial matches when the type matches some of " -"the exceptions in the group. This means that multiple :keyword:`!except*` " -"clauses can execute, each handling part of the exception group. Each clause " -"executes at most once and handles an exception group of all matching " -"exceptions. Each exception in the group is handled by at most " -"one :keyword:`!except*` clause, the first that matches it. ::" +"The :keyword:`!except*` clause(s) are used for handling :exc:" +"`ExceptionGroup`\\s. The exception type for matching is interpreted as in " +"the case of :keyword:`except`, but in the case of exception groups we can " +"have partial matches when the type matches some of the exceptions in the " +"group. This means that multiple :keyword:`!except*` clauses can execute, " +"each handling part of the exception group. Each clause executes at most once " +"and handles an exception group of all matching exceptions. Each exception " +"in the group is handled by at most one :keyword:`!except*` clause, the first " +"that matches it. ::" msgstr "" #: ../../reference/compound_stmts.rst:345 @@ -428,8 +427,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:384 msgid "" "It is not possible to mix :keyword:`except` and :keyword:`!except*` in the " -"same :keyword:`try`. :keyword:`break`, :keyword:`continue` " -"and :keyword:`return` cannot appear in an :keyword:`!except*` clause." +"same :keyword:`try`. The :keyword:`break`, :keyword:`continue`, and :keyword:" +"`return` statements cannot appear in an :keyword:`!except*` clause." msgstr "" #: ../../reference/compound_stmts.rst:399 @@ -439,10 +438,10 @@ msgstr ":keyword:`!else` 子句" #: ../../reference/compound_stmts.rst:401 msgid "" "The optional :keyword:`!else` clause is executed if the control flow leaves " -"the :keyword:`try` suite, no exception was raised, and " -"no :keyword:`return`, :keyword:`continue`, or :keyword:`break` statement was " -"executed. Exceptions in the :keyword:`!else` clause are not handled by the " -"preceding :keyword:`except` clauses." +"the :keyword:`try` suite, no exception was raised, and no :keyword:" +"`return`, :keyword:`continue`, or :keyword:`break` statement was executed. " +"Exceptions in the :keyword:`!else` clause are not handled by the preceding :" +"keyword:`except` clauses." msgstr "" #: ../../reference/compound_stmts.rst:413 @@ -451,16 +450,16 @@ msgstr ":keyword:`!finally` 子句" #: ../../reference/compound_stmts.rst:415 msgid "" -"If :keyword:`!finally` is present, it specifies a 'cleanup' handler. " -"The :keyword:`try` clause is executed, including any :keyword:`except` " -"and :keyword:`else` clauses. If an exception occurs in any of the clauses " -"and is not handled, the exception is temporarily saved. The :keyword:`!" -"finally` clause is executed. If there is a saved exception it is re-raised " -"at the end of the :keyword:`!finally` clause. If the :keyword:`!finally` " -"clause raises another exception, the saved exception is set as the context " -"of the new exception. If the :keyword:`!finally` clause executes " -"a :keyword:`return`, :keyword:`break` or :keyword:`continue` statement, the " -"saved exception is discarded::" +"If :keyword:`!finally` is present, it specifies a 'cleanup' handler. The :" +"keyword:`try` clause is executed, including any :keyword:`except` and :" +"keyword:`else` clauses. If an exception occurs in any of the clauses and is " +"not handled, the exception is temporarily saved. The :keyword:`!finally` " +"clause is executed. If there is a saved exception it is re-raised at the " +"end of the :keyword:`!finally` clause. If the :keyword:`!finally` clause " +"raises another exception, the saved exception is set as the context of the " +"new exception. If the :keyword:`!finally` clause executes a :keyword:" +"`return`, :keyword:`break` or :keyword:`continue` statement, the saved " +"exception is discarded::" msgstr "" #: ../../reference/compound_stmts.rst:425 @@ -527,8 +526,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:460 msgid "" -"Prior to Python 3.8, a :keyword:`continue` statement was illegal in " -"the :keyword:`!finally` clause due to a problem with the implementation." +"Prior to Python 3.8, a :keyword:`continue` statement was illegal in the :" +"keyword:`!finally` clause due to a problem with the implementation." msgstr "" #: ../../reference/compound_stmts.rst:469 @@ -539,8 +538,8 @@ msgstr ":keyword:`!with` 陳述式" msgid "" "The :keyword:`with` statement is used to wrap the execution of a block with " "methods defined by a context manager (see section :ref:`context-managers`). " -"This allows common :keyword:`try`...\\ :keyword:`except`..." -"\\ :keyword:`finally` usage patterns to be encapsulated for convenient reuse." +"This allows common :keyword:`try`...\\ :keyword:`except`...\\ :keyword:" +"`finally` usage patterns to be encapsulated for convenient reuse." msgstr "" #: ../../reference/compound_stmts.rst:488 @@ -551,8 +550,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:490 msgid "" -"The context expression (the expression given in the :token:`~python-" -"grammar:with_item`) is evaluated to obtain a context manager." +"The context expression (the expression given in the :token:`~python-grammar:" +"with_item`) is evaluated to obtain a context manager." msgstr "" #: ../../reference/compound_stmts.rst:493 @@ -576,11 +575,11 @@ msgstr "" #: ../../reference/compound_stmts.rst:504 msgid "" -"The :keyword:`with` statement guarantees that if " -"the :meth:`~object.__enter__` method returns without an error, " -"then :meth:`~object.__exit__` will always be called. Thus, if an error " -"occurs during the assignment to the target list, it will be treated the same " -"as an error occurring within the suite would be. See step 7 below." +"The :keyword:`with` statement guarantees that if the :meth:`~object." +"__enter__` method returns without an error, then :meth:`~object.__exit__` " +"will always be called. Thus, if an error occurs during the assignment to the " +"target list, it will be treated the same as an error occurring within the " +"suite would be. See step 7 below." msgstr "" #: ../../reference/compound_stmts.rst:510 @@ -591,16 +590,16 @@ msgstr "" msgid "" "The context manager's :meth:`~object.__exit__` method is invoked. If an " "exception caused the suite to be exited, its type, value, and traceback are " -"passed as arguments to :meth:`~object.__exit__`. Otherwise, " -"three :const:`None` arguments are supplied." +"passed as arguments to :meth:`~object.__exit__`. Otherwise, three :const:" +"`None` arguments are supplied." msgstr "" #: ../../reference/compound_stmts.rst:517 msgid "" -"If the suite was exited due to an exception, and the return value from " -"the :meth:`~object.__exit__` method was false, the exception is reraised. " -"If the return value was true, the exception is suppressed, and execution " -"continues with the statement following the :keyword:`with` statement." +"If the suite was exited due to an exception, and the return value from the :" +"meth:`~object.__exit__` method was false, the exception is reraised. If the " +"return value was true, the exception is suppressed, and execution continues " +"with the statement following the :keyword:`with` statement." msgstr "" #: ../../reference/compound_stmts.rst:522 @@ -668,8 +667,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:550 msgid "" -"With more than one item, the context managers are processed as if " -"multiple :keyword:`with` statements were nested::" +"With more than one item, the context managers are processed as if multiple :" +"keyword:`with` statements were nested::" msgstr "" #: ../../reference/compound_stmts.rst:553 @@ -1048,8 +1047,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:846 msgid "" -"The rule ``strings`` and the token ``NUMBER`` are defined in " -"the :doc:`standard Python grammar <./grammar>`. Triple-quoted strings are " +"The rule ``strings`` and the token ``NUMBER`` are defined in the :doc:" +"`standard Python grammar <./grammar>`. Triple-quoted strings are " "supported. Raw strings and byte strings are supported. :ref:`f-strings` " "are not supported." msgstr "" @@ -1079,8 +1078,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:869 msgid "" "A single underscore ``_`` is not a capture pattern (this is what ``!'_'`` " -"expresses). It is instead treated as a :token:`~python-" -"grammar:wildcard_pattern`." +"expresses). It is instead treated as a :token:`~python-grammar:" +"wildcard_pattern`." msgstr "" #: ../../reference/compound_stmts.rst:873 @@ -1141,8 +1140,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:918 msgid "" -"In simple terms ``NAME1.NAME2`` will succeed only if `` == " -"NAME1.NAME2``" +"In simple terms ``NAME1.NAME2`` will succeed only if `` == NAME1." +"NAME2``" msgstr "" #: ../../reference/compound_stmts.rst:922 @@ -1354,8 +1353,8 @@ msgstr "" msgid "" "Key-value pairs are matched using the two-argument form of the mapping " "subject's ``get()`` method. Matched key-value pairs must already be present " -"in the mapping, and not created on-the-fly via :meth:`__missing__` " -"or :meth:`~object.__getitem__`." +"in the mapping, and not created on-the-fly via :meth:`__missing__` or :meth:" +"`~object.__getitem__`." msgstr "" #: ../../reference/compound_stmts.rst:1064 @@ -1402,14 +1401,14 @@ msgstr "" #: ../../reference/compound_stmts.rst:1094 msgid "" -"If ``name_or_attr`` is not an instance of the builtin :class:`type` , " -"raise :exc:`TypeError`." +"If ``name_or_attr`` is not an instance of the builtin :class:`type` , raise :" +"exc:`TypeError`." msgstr "" #: ../../reference/compound_stmts.rst:1097 msgid "" -"If the subject value is not an instance of ``name_or_attr`` (tested " -"via :func:`isinstance`), the class pattern fails." +"If the subject value is not an instance of ``name_or_attr`` (tested via :" +"func:`isinstance`), the class pattern fails." msgstr "" #: ../../reference/compound_stmts.rst:1100 @@ -1475,14 +1474,14 @@ msgstr "" #: ../../reference/compound_stmts.rst:1133 msgid "" -"If the returned value is not a tuple, the conversion fails " -"and :exc:`TypeError` is raised." +"If the returned value is not a tuple, the conversion fails and :exc:" +"`TypeError` is raised." msgstr "" #: ../../reference/compound_stmts.rst:1136 msgid "" -"If there are more positional patterns than " -"``len(cls.__match_args__)``, :exc:`TypeError` is raised." +"If there are more positional patterns than ``len(cls.__match_args__)``, :exc:" +"`TypeError` is raised." msgstr "" #: ../../reference/compound_stmts.rst:1139 @@ -1603,8 +1602,8 @@ msgstr "函式定義" #: ../../reference/compound_stmts.rst:1208 msgid "" -"A function definition defines a user-defined function object (see " -"section :ref:`types`):" +"A function definition defines a user-defined function object (see section :" +"ref:`types`):" msgstr "" #: ../../reference/compound_stmts.rst:1230 @@ -1664,9 +1663,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1260 msgid "" -"Functions may be decorated with any valid :token:`~python-" -"grammar:assignment_expression`. Previously, the grammar was much more " -"restrictive; see :pep:`614` for details." +"Functions may be decorated with any valid :token:`~python-grammar:" +"assignment_expression`. Previously, the grammar was much more restrictive; " +"see :pep:`614` for details." msgstr "" #: ../../reference/compound_stmts.rst:1265 @@ -1719,18 +1718,18 @@ msgstr "" #: ../../reference/compound_stmts.rst:1309 msgid "" -"Function call semantics are described in more detail in " -"section :ref:`calls`. A function call always assigns values to all " -"parameters mentioned in the parameter list, either from positional " -"arguments, from keyword arguments, or from default values. If the form " -"\"``*identifier``\" is present, it is initialized to a tuple receiving any " -"excess positional parameters, defaulting to the empty tuple. If the form " -"\"``**identifier``\" is present, it is initialized to a new ordered mapping " -"receiving any excess keyword arguments, defaulting to a new empty mapping of " -"the same type. Parameters after \"``*``\" or \"``*identifier``\" are " -"keyword-only parameters and may only be passed by keyword arguments. " -"Parameters before \"``/``\" are positional-only parameters and may only be " -"passed by positional arguments." +"Function call semantics are described in more detail in section :ref:" +"`calls`. A function call always assigns values to all parameters mentioned " +"in the parameter list, either from positional arguments, from keyword " +"arguments, or from default values. If the form \"``*identifier``\" is " +"present, it is initialized to a tuple receiving any excess positional " +"parameters, defaulting to the empty tuple. If the form \"``**identifier``\" " +"is present, it is initialized to a new ordered mapping receiving any excess " +"keyword arguments, defaulting to a new empty mapping of the same type. " +"Parameters after \"``*``\" or \"``*identifier``\" are keyword-only " +"parameters and may only be passed by keyword arguments. Parameters before " +"\"``/``\" are positional-only parameters and may only be passed by " +"positional arguments." msgstr "" #: ../../reference/compound_stmts.rst:1321 @@ -1749,8 +1748,8 @@ msgid "" "of the form \"``-> expression``\" after the parameter list. These " "annotations can be any valid Python expression. The presence of annotations " "does not change the semantics of a function. The annotation values are " -"available as values of a dictionary keyed by the parameters' names in " -"the :attr:`__annotations__` attribute of the function object. If the " +"available as values of a dictionary keyed by the parameters' names in the :" +"attr:`__annotations__` attribute of the function object. If the " "``annotations`` import from :mod:`__future__` is used, annotations are " "preserved as strings at runtime which enables postponed evaluation. " "Otherwise, they are evaluated when the function definition is executed. In " @@ -1771,8 +1770,8 @@ msgid "" "described in section :ref:`lambda`. Note that the lambda expression is " "merely a shorthand for a simplified function definition; a function defined " "in a \":keyword:`def`\" statement can be passed around or assigned to " -"another name just like a function defined by a lambda expression. The " -"\":keyword:`!def`\" form is actually more powerful since it allows the " +"another name just like a function defined by a lambda expression. The \":" +"keyword:`!def`\" form is actually more powerful since it allows the " "execution of multiple statements and annotations." msgstr "" @@ -1870,14 +1869,14 @@ msgstr "" #: ../../reference/compound_stmts.rst:1423 msgid "" -"The class's suite is then executed in a new execution frame " -"(see :ref:`naming`), using a newly created local namespace and the original " -"global namespace. (Usually, the suite contains mostly function " -"definitions.) When the class's suite finishes execution, its execution " -"frame is discarded but its local namespace is saved. [#]_ A class object is " -"then created using the inheritance list for the base classes and the saved " -"local namespace for the attribute dictionary. The class name is bound to " -"this class object in the original local namespace." +"The class's suite is then executed in a new execution frame (see :ref:" +"`naming`), using a newly created local namespace and the original global " +"namespace. (Usually, the suite contains mostly function definitions.) When " +"the class's suite finishes execution, its execution frame is discarded but " +"its local namespace is saved. [#]_ A class object is then created using the " +"inheritance list for the base classes and the saved local namespace for the " +"attribute dictionary. The class name is bound to this class object in the " +"original local namespace." msgstr "" #: ../../reference/compound_stmts.rst:1432 @@ -1924,9 +1923,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1456 msgid "" -"Classes may be decorated with any valid :token:`~python-" -"grammar:assignment_expression`. Previously, the grammar was much more " -"restrictive; see :pep:`614` for details." +"Classes may be decorated with any valid :token:`~python-grammar:" +"assignment_expression`. Previously, the grammar was much more restrictive; " +"see :pep:`614` for details." msgstr "" #: ../../reference/compound_stmts.rst:1461 @@ -1934,8 +1933,8 @@ msgid "" "A list of :ref:`type parameters ` may be given in square " "brackets immediately after the class's name. This indicates to static type " "checkers that the class is generic. At runtime, the type parameters can be " -"retrieved from the class's :attr:`~type.__type_params__` attribute. " -"See :ref:`generic-classes` for more." +"retrieved from the class's :attr:`~type.__type_params__` attribute. See :ref:" +"`generic-classes` for more." msgstr "" #: ../../reference/compound_stmts.rst:1470 @@ -2179,9 +2178,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1645 msgid "" -":ref:`Functions ` (including :ref:`coroutines `), :ref:`classes ` and :ref:`type aliases ` may contain a " -"type parameter list::" +":ref:`Functions ` (including :ref:`coroutines `), :ref:" +"`classes ` and :ref:`type aliases ` may contain a type " +"parameter list::" msgstr "" #: ../../reference/compound_stmts.rst:1649 @@ -2238,9 +2237,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:1678 msgid "" -"Generic functions, classes, and type aliases have " -"a :attr:`~definition.__type_params__` attribute listing their type " -"parameters." +"Generic functions, classes, and type aliases have a :attr:`~definition." +"__type_params__` attribute listing their type parameters." msgstr "" #: ../../reference/compound_stmts.rst:1681 @@ -2383,8 +2381,8 @@ msgid "" "Here ``annotation-def`` indicates an :ref:`annotation scope `, which is not actually bound to any name at runtime. (One other " "liberty is taken in the translation: the syntax does not go through " -"attribute access on the :mod:`typing` module, but creates an instance " -"of :data:`typing.TypeVar` directly.)" +"attribute access on the :mod:`typing` module, but creates an instance of :" +"data:`typing.TypeVar` directly.)" msgstr "" #: ../../reference/compound_stmts.rst:1760 @@ -2412,8 +2410,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:1771 msgid "" -"Except for the :ref:`lazy evaluation ` of " -"the :class:`~typing.TypeVar` bound, this is equivalent to::" +"Except for the :ref:`lazy evaluation ` of the :class:" +"`~typing.TypeVar` bound, this is equivalent to::" msgstr "" #: ../../reference/compound_stmts.rst:1774 @@ -2476,9 +2474,9 @@ msgstr "" #: ../../reference/compound_stmts.rst:1815 msgid "" -"Here again ``annotation-def`` (not a real keyword) indicates " -"an :ref:`annotation scope `, and the name " -"``TYPE_PARAMS_OF_Bag`` is not actually bound at runtime." +"Here again ``annotation-def`` (not a real keyword) indicates an :ref:" +"`annotation scope `, and the name ``TYPE_PARAMS_OF_Bag`` " +"is not actually bound at runtime." msgstr "" #: ../../reference/compound_stmts.rst:1819 @@ -2565,9 +2563,9 @@ msgstr "註解" #: ../../reference/compound_stmts.rst:1865 msgid "" -"The exception is propagated to the invocation stack unless there is " -"a :keyword:`finally` clause which happens to raise another exception. That " -"new exception causes the old one to be lost." +"The exception is propagated to the invocation stack unless there is a :" +"keyword:`finally` clause which happens to raise another exception. That new " +"exception causes the old one to be lost." msgstr "" #: ../../reference/compound_stmts.rst:1869 @@ -2639,8 +2637,8 @@ msgstr "" #: ../../reference/compound_stmts.rst:1895 msgid "" -"The standard library classes :class:`dict` " -"and :class:`types.MappingProxyType` are mappings." +"The standard library classes :class:`dict` and :class:`types." +"MappingProxyType` are mappings." msgstr "" #: ../../reference/compound_stmts.rst:1898 From 65a524048915c38bff746e725257f89306dc34b0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Aug 2025 00:19:13 +0000 Subject: [PATCH 08/13] sync with cpython 4ad36035 --- library/difflib.po | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/library/difflib.po b/library/difflib.po index c0d1130505..f47345cb45 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-08-08 00:17+0000\n" "PO-Revision-Date: 2016-11-19 00:29+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -404,15 +404,14 @@ msgstr "" #: ../../library/difflib.rst:354 msgid "" -"`Pattern Matching: The Gestalt Approach `_" +"`Pattern Matching: The Gestalt Approach `_" msgstr "" #: ../../library/difflib.rst:355 msgid "" "Discussion of a similar algorithm by John W. Ratcliff and D. E. Metzener. " -"This was published in `Dr. Dobb's Journal `_ in " -"July, 1988." +"This was published in Dr. Dobb's Journal in July, 1988." msgstr "" #: ../../library/difflib.rst:362 @@ -781,7 +780,7 @@ msgstr "" #: ../../library/difflib.rst:649 msgid "The :class:`Differ` class has this constructor:" -msgstr ":class:`Differ` 類別有這個建構函式:" +msgstr ":class:`Differ` 類別有這個建構函式:" #: ../../library/difflib.rst:655 msgid "" From 30cbc8d475fb79637a1cdc0786d5e26cb756d3f0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 9 Aug 2025 00:18:16 +0000 Subject: [PATCH 09/13] sync with cpython aa4525fc --- extending/extending.po | 8 +- library/functions.po | 5 +- library/typing.po | 576 +++++++++++++++++++-------------------- library/unittest.mock.po | 9 +- 4 files changed, 295 insertions(+), 303 deletions(-) diff --git a/extending/extending.po b/extending/extending.po index 9818750cbd..b8532c668c 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-06 00:17+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+0000\n" "PO-Revision-Date: 2025-02-17 14:34+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -505,9 +505,9 @@ msgstr "" #: ../../extending/extending.rst:242 msgid "" -"Since :c:data:`!SpamError` is a global variable, it will be overwitten every " -"time the module is reinitialized, when the :c:data:`Py_mod_exec` function is " -"called." +"Since :c:data:`!SpamError` is a global variable, it will be overwritten " +"every time the module is reinitialized, when the :c:data:`Py_mod_exec` " +"function is called." msgstr "" #: ../../extending/extending.rst:245 diff --git a/library/functions.po b/library/functions.po index fb90fa4b56..fee1a48f99 100644 --- a/library/functions.po +++ b/library/functions.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+0000\n" "PO-Revision-Date: 2024-05-06 17:06+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2738,8 +2738,9 @@ msgstr "" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" #: ../../library/functions.rst:1568 +#, fuzzy msgid "" -"The arguments must have numeric types. With mixed operand types, the " +"When arguments are builtin numeric types with mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " "operands, the result has the same type as the operands (after coercion) " "unless the second argument is negative; in that case, all arguments are " diff --git a/library/typing.po b/library/typing.po index 2306bfda2b..d2b8a3b8c1 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-06 02:41+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+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-" @@ -55,8 +55,8 @@ msgstr "" msgid "" "The function ``surface_area_of_cube`` takes an argument expected to be an " "instance of :class:`float`, as indicated by the :term:`type hint` " -"``edge_length: float``. The function is expected to return an instance " -"of :class:`str`, as indicated by the ``-> str`` hint." +"``edge_length: float``. The function is expected to return an instance of :" +"class:`str`, as indicated by the ``-> str`` hint." msgstr "" "函式 ``surface_area_of_cube`` 需要一個引數且預期是一個 :class:`float` 的實" "例,如 ``edge_length: float`` 所指出的\\ :term:`型別提示 `。這個函" @@ -73,17 +73,18 @@ msgstr "" #: ../../library/typing.rst:42 msgid "" -"New features are frequently added to the ``typing`` module. " -"The :pypi:`typing_extensions` package provides backports of these new " -"features to older versions of Python." +"New features are frequently added to the ``typing`` module. The :pypi:" +"`typing_extensions` package provides backports of these new features to " +"older versions of Python." msgstr "" "新功能會頻繁的新增至 ``typing`` 模組中。:pypi:`typing_extensions` 套件為這些" "新功能提供了 backport(向後移植的)版本,提供給舊版本的 Python 使用。" #: ../../library/typing.rst:48 +#, fuzzy msgid "" -"`\"Typing cheat sheet\" `_" +"`Typing cheat sheet `_" msgstr "" "`\"型別小抄 (Typing cheat sheet)\" `_" @@ -93,9 +94,10 @@ msgid "A quick overview of type hints (hosted at the mypy docs)" msgstr "型別提示的快速預覽(發布於 mypy 的文件中)" #: ../../library/typing.rst:51 +#, fuzzy msgid "" -"\"Type System Reference\" section of `the mypy docs `_" +"Type System Reference section of `the mypy docs `_" msgstr "" "`mypy 文件 `_\\ 的 \"型別系" "統參考資料 (Type System Reference)\" 章節" @@ -110,7 +112,8 @@ msgstr "" "多數 Python 型別檢查器中廣為使用。(某些部分依然是特定給 mypy 使用。)" #: ../../library/typing.rst:56 -msgid "`\"Static Typing with Python\" `_" +#, fuzzy +msgid "`Static Typing with Python `_" msgstr "" "`\"Python 的靜態型別 (Static Typing)\" `_" @@ -128,10 +131,11 @@ msgid "Specification for the Python Type System" msgstr "Python 型別系統的技術規範" #: ../../library/typing.rst:66 +#, fuzzy msgid "" "The canonical, up-to-date specification of the Python type system can be " -"found at `\"Specification for the Python type system\" `_." +"found at `Specification for the Python type system `_." msgstr "" "關於 Python 型別系統標準的 (canonical)、最新的技術規範可以在\\ `「Python 型別" "系統的技術規範」 `_\\ 找" @@ -147,9 +151,9 @@ msgid "" "an instance of :class:`TypeAliasType`. In this example, ``Vector`` and " "``list[float]`` will be treated equivalently by static type checkers::" msgstr "" -"一個型別別名被定義來使用 :keyword:`type` 陳述式,其建立" -"了 :class:`TypeAliasType` 的實例。在這個範例中,``Vector`` 及 " -"``list[float]`` 會被當作和靜態型別檢查器一樣同等對待: ::" +"一個型別別名被定義來使用 :keyword:`type` 陳述式,其建立了 :class:" +"`TypeAliasType` 的實例。在這個範例中,``Vector`` 及 ``list[float]`` 會被當作" +"和靜態型別檢查器一樣同等對待: ::" #: ../../library/typing.rst:79 msgid "" @@ -376,16 +380,15 @@ msgstr "註釋 callable 物件" #: ../../library/typing.rst:210 msgid "" -"Functions -- or other :term:`callable` objects -- can be annotated " -"using :class:`collections.abc.Callable` or " -"deprecated :data:`typing.Callable`. ``Callable[[int], str]`` signifies a " -"function that takes a single parameter of type :class:`int` and returns " -"a :class:`str`." +"Functions -- or other :term:`callable` objects -- can be annotated using :" +"class:`collections.abc.Callable` or deprecated :data:`typing.Callable`. " +"``Callable[[int], str]`` signifies a function that takes a single parameter " +"of type :class:`int` and returns a :class:`str`." msgstr "" -"函式,或者是其他 :term:`callable` 物件,可以使" -"用 :class:`collections.abc.Callable` 或以棄用的 :data:`typing.Callable` 進行" -"註釋。 ``Callable[[int], str]`` 象徵為一個函式,可以接受一個型別" -"為 :class:`int` 的引數,並回傳一個 :class:`str`。" +"函式,或者是其他 :term:`callable` 物件,可以使用 :class:`collections.abc." +"Callable` 或以棄用的 :data:`typing.Callable` 進行註釋。 ``Callable[[int], " +"str]`` 象徵為一個函式,可以接受一個型別為 :class:`int` 的引數,並回傳一個 :" +"class:`str`。" #: ../../library/typing.rst:215 ../../library/typing.rst:3161 #: ../../library/typing.rst:3341 @@ -443,8 +446,8 @@ msgid "" "``Callable`` cannot express complex signatures such as functions that take a " "variadic number of arguments, :ref:`overloaded functions `, or " "functions that have keyword-only parameters. However, these signatures can " -"be expressed by defining a :class:`Protocol` class with " -"a :meth:`~object.__call__` method:" +"be expressed by defining a :class:`Protocol` class with a :meth:`~object." +"__call__` method:" msgstr "" "``Callable`` 不如有可變數量引數的函式、:func:`overloaded functions " "`、或是僅限關鍵字參數的函式,可以表示複雜簽名。然而,這些簽名可以透" @@ -494,11 +497,11 @@ msgstr "" #: ../../library/typing.rst:285 ../../library/typing.rst:3831 msgid "" -"``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. " -"See :pep:`612` for more details." +"``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. See :" +"pep:`612` for more details." msgstr "" -"``Callable`` 現已支援 :class:`ParamSpec` 以及 :data:`Concatenate`。請參" -"閱 :pep:`612` 閱讀詳細內容。" +"``Callable`` 現已支援 :class:`ParamSpec` 以及 :data:`Concatenate`。請參閱 :" +"pep:`612` 閱讀詳細內容。" #: ../../library/typing.rst:290 msgid "" @@ -603,10 +606,9 @@ msgstr "" #: ../../library/typing.rst:356 msgid "" ":class:`list` only accepts one type argument, so a type checker would emit " -"an error on the ``y`` assignment above. " -"Similarly, :class:`~collections.abc.Mapping` only accepts two type " -"arguments: the first indicates the type of the keys, and the second " -"indicates the type of the values." +"an error on the ``y`` assignment above. Similarly, :class:`~collections.abc." +"Mapping` only accepts two type arguments: the first indicates the type of " +"the keys, and the second indicates the type of the values." msgstr "" ":class:`list` 只接受一個型別引數,所以型別檢查器可能在上述 ``y`` 賦值 " "(assignment) 觸發錯誤。類似的範例,:class:`~collections.abc.Mapping` 只接受兩" @@ -617,8 +619,8 @@ msgstr "" msgid "" "Unlike most other Python containers, however, it is common in idiomatic " "Python code for tuples to have elements which are not all of the same type. " -"For this reason, tuples are special-cased in Python's typing " -"system. :class:`tuple` accepts *any number* of type arguments::" +"For this reason, tuples are special-cased in Python's typing system. :class:" +"`tuple` accepts *any number* of type arguments::" msgstr "" "然而,與其他多數的 Python 容器不同,在慣用的 (idiomatic) Python 程式碼中,元" "組可以擁有不完全相同型別的元素是相當常見的。為此,元組在 Python 的加註型別系" @@ -678,10 +680,9 @@ msgstr "類別物件的型別" #: ../../library/typing.rst:403 msgid "" "A variable annotated with ``C`` may accept a value of type ``C``. In " -"contrast, a variable annotated with ``type[C]`` (or " -"deprecated :class:`typing.Type[C] `) may accept values that are " -"classes themselves -- specifically, it will accept the *class object* of " -"``C``. For example::" +"contrast, a variable annotated with ``type[C]`` (or deprecated :class:" +"`typing.Type[C] `) may accept values that are classes themselves -- " +"specifically, it will accept the *class object* of ``C``. For example::" msgstr "" "一個變數被註釋為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解" "為 ``type[C]`` \\ (或已棄用的 :class:`typing.Type[C] `)\\ 可以接受本" @@ -720,9 +721,8 @@ msgstr "" #: ../../library/typing.rst:429 msgid "" -"The only legal parameters for :class:`type` are " -"classes, :data:`Any`, :ref:`type variables `, and unions of any of " -"these types. For example::" +"The only legal parameters for :class:`type` are classes, :data:`Any`, :ref:" +"`type variables `, and unions of any of these types. For example::" msgstr "" ":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 " "`\\ 以及這些型別任意組合成的聯集。舉例來說: ::" @@ -740,8 +740,8 @@ msgstr "" #: ../../library/typing.rst:441 msgid "" -"``type[Any]`` is equivalent to :class:`type`, which is the root of " -"Python's :ref:`metaclass hierarchy `." +"``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :" +"ref:`metaclass hierarchy `." msgstr "" "``type[Any]`` 等價於 :class:`type` ,其為 Python :ref:`metaclass 階層結構 " "(hierachy) `。" @@ -752,9 +752,9 @@ msgstr "" #: ../../library/typing.rst:450 msgid "" -"A generator can be annotated using the generic " -"type :class:`Generator[YieldType, SendType, ReturnType] " -"`. For example::" +"A generator can be annotated using the generic type :class:" +"`Generator[YieldType, SendType, ReturnType] `. " +"For example::" msgstr "" #: ../../library/typing.rst:454 @@ -801,9 +801,8 @@ msgstr "" #: ../../library/typing.rst:478 msgid "" "Simple generators that only ever yield values can also be annotated as " -"having a return type of either :class:`Iterable[YieldType] " -"` or :class:`Iterator[YieldType] " -"`::" +"having a return type of either :class:`Iterable[YieldType] ` or :class:`Iterator[YieldType] `::" msgstr "" #: ../../library/typing.rst:483 @@ -818,8 +817,8 @@ msgstr "" msgid "" "Async generators are handled in a similar fashion, but don't expect a " "``ReturnType`` type argument (:class:`AsyncGenerator[YieldType, SendType] " -"`). The ``SendType`` argument defaults " -"to :const:`!None`, so the following definitions are equivalent::" +"`). The ``SendType`` argument defaults to :" +"const:`!None`, so the following definitions are equivalent::" msgstr "" #: ../../library/typing.rst:494 @@ -837,9 +836,9 @@ msgstr "" #: ../../library/typing.rst:504 msgid "" -"As in the synchronous case, :class:`AsyncIterable[YieldType] " -"` and :class:`AsyncIterator[YieldType] " -"` are available as well::" +"As in the synchronous case, :class:`AsyncIterable[YieldType] ` and :class:`AsyncIterator[YieldType] ` are available as well::" msgstr "" #: ../../library/typing.rst:509 @@ -908,8 +907,8 @@ msgstr "" #: ../../library/typing.rst:557 msgid "" "Generic classes implicitly inherit from :class:`Generic`. For compatibility " -"with Python 3.11 and lower, it is also possible to inherit explicitly " -"from :class:`Generic` to indicate a generic class::" +"with Python 3.11 and lower, it is also possible to inherit explicitly from :" +"class:`Generic` to indicate a generic class::" msgstr "" "泛型類別隱性繼承了 :class:`Generic`。為了相容 Python 3.11 及更早版本,也可以" "明確的繼承 :class:`Generic` 並指出是一個泛型類別: ::" @@ -943,8 +942,8 @@ msgstr "" #: ../../library/typing.rst:577 msgid "" -"A generic type can have any number of type variables. All varieties " -"of :class:`TypeVar` are permissible as parameters for a generic type::" +"A generic type can have any number of type variables. All varieties of :" +"class:`TypeVar` are permissible as parameters for a generic type::" msgstr "" "一個泛型型別可以有任意數量的型別變數。所有種類的 :class:`TypeVar` 都可以作為" "泛型型別的參數: ::" @@ -1089,9 +1088,9 @@ msgid "" "substitute a :class:`ParamSpec`::" msgstr "" "使用者定義的參數運算式 (parameter expression) 泛型一樣有支援,透過 ``[**P]`` " -"格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續" -"被 :mod:`!typing` 模組視為一個特定的型別變數。對此,其中一個例外是一個型別列" -"表可以替代 :class:`ParamSpec`: ::" +"格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續被 :" +"mod:`!typing` 模組視為一個特定的型別變數。對此,其中一個例外是一個型別列表可" +"以替代 :class:`ParamSpec`: ::" #: ../../library/typing.rst:671 msgid "" @@ -1169,11 +1168,11 @@ msgstr "" #: ../../library/typing.rst:703 msgid "" -":class:`Generic` can now be parameterized over parameter expressions. " -"See :class:`ParamSpec` and :pep:`612` for more details." +":class:`Generic` can now be parameterized over parameter expressions. See :" +"class:`ParamSpec` and :pep:`612` for more details." msgstr "" -":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請" -"見 :class:`ParamSpec` 以及 :pep:`612`。" +":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請見 :class:" +"`ParamSpec` 以及 :pep:`612`。" #: ../../library/typing.rst:707 msgid "" @@ -1196,8 +1195,8 @@ msgid "" "every type as being compatible with :data:`Any` and :data:`Any` as being " "compatible with every type." msgstr "" -":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容" -"於 :data:`Any` 且 :data:`Any` 也可以相容於每個型別。" +":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容於 :" +"data:`Any` 且 :data:`Any` 也可以相容於每個型別。" #: ../../library/typing.rst:720 msgid "" @@ -1227,11 +1226,11 @@ msgstr "" #: ../../library/typing.rst:738 msgid "" -"Notice that no type checking is performed when assigning a value of " -"type :data:`Any` to a more precise type. For example, the static type " -"checker did not report an error when assigning ``a`` to ``s`` even though " -"``s`` was declared to be of type :class:`str` and receives an :class:`int` " -"value at runtime!" +"Notice that no type checking is performed when assigning a value of type :" +"data:`Any` to a more precise type. For example, the static type checker did " +"not report an error when assigning ``a`` to ``s`` even though ``s`` was " +"declared to be of type :class:`str` and receives an :class:`int` value at " +"runtime!" msgstr "" "請注意,當賦予型別為 :data:`Any` 的值更精確的型別時,將不會執行任何型別檢查。" "舉例來說,靜態型別檢查器不會在 runtime 中,將 ``a`` 賦值給 ``s`` 的情況下回報" @@ -1272,8 +1271,8 @@ msgid "" "subtype of every other type." msgstr "" ":data:`Any` 的行為對比 :class:`object` 的行為。與 :data:`Any` 相似,所有的型" -"別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦" -"然::class:`object` 並\\ *不是*\\一個其他型別的子型別。" +"別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦然::" +"class:`object` 並\\ *不是*\\一個其他型別的子型別。" #: ../../library/typing.rst:765 msgid "" @@ -1330,16 +1329,16 @@ msgstr "" #: ../../library/typing.rst:798 msgid "" -"This requirement previously also applied to abstract base classes, such " -"as :class:`~collections.abc.Iterable`. The problem with this approach is " -"that a class had to be explicitly marked to support them, which is " -"unpythonic and unlike what one would normally do in idiomatic dynamically " -"typed Python code. For example, this conforms to :pep:`484`::" +"This requirement previously also applied to abstract base classes, such as :" +"class:`~collections.abc.Iterable`. The problem with this approach is that a " +"class had to be explicitly marked to support them, which is unpythonic and " +"unlike what one would normally do in idiomatic dynamically typed Python " +"code. For example, this conforms to :pep:`484`::" msgstr "" "這個需求之前也被運用在抽象基底類別,例如 :class:`~collections.abc.Iterable`。" "這種方式的問題在於,一個類別需要顯式的標記來支援他們,這並不符合 Python 風" -"格,也不像一個常見的慣用動態型別 Python 程式碼。舉例來說,下列程式碼符" -"合 :pep:`484`: ::" +"格,也不像一個常見的慣用動態型別 Python 程式碼。舉例來說,下列程式碼符合 :" +"pep:`484`: ::" #: ../../library/typing.rst:804 msgid "" @@ -1486,10 +1485,9 @@ msgstr "" #: ../../library/typing.rst:877 msgid "" -"Note that, despite its name, ``AnyStr`` has nothing to do with " -"the :class:`Any` type, nor does it mean \"any string\". In particular, " -"``AnyStr`` and ``str | bytes`` are different from each other and have " -"different use cases::" +"Note that, despite its name, ``AnyStr`` has nothing to do with the :class:" +"`Any` type, nor does it mean \"any string\". In particular, ``AnyStr`` and " +"``str | bytes`` are different from each other and have different use cases::" msgstr "" "請注意,儘管他的名稱相近,``AnyStr`` 與 :class:`Any` 型別無關,更不代表是「任" "何字串」的意思。尤其,``AnyStr`` 與 ``str | bytes`` 兩者不同且具有不同的使用" @@ -1511,8 +1509,8 @@ msgstr "" #: ../../library/typing.rst:892 msgid "" "Deprecated in favor of the new :ref:`type parameter syntax `. " -"Use ``class A[T: (str, bytes)]: ...`` instead of importing ``AnyStr``. " -"See :pep:`695` for more details." +"Use ``class A[T: (str, bytes)]: ...`` instead of importing ``AnyStr``. See :" +"pep:`695` for more details." msgstr "" #: ../../library/typing.rst:897 @@ -1574,16 +1572,16 @@ msgstr "更多細節請見 :pep:`675`。" #: ../../library/typing.rst:940 msgid "" -":data:`!Never` and :data:`!NoReturn` represent the `bottom type `_, a type that has no members." +":data:`!Never` and :data:`!NoReturn` represent the `bottom type `_, a type that has no members." msgstr "" ":data:`!Never` 和 :data:`!NoReturn` 表示\\ `底部型別 (bottom type) `_,為一個沒有任何成員的型別。" #: ../../library/typing.rst:944 msgid "" -"They can be used to indicate that a function never returns, such " -"as :func:`sys.exit`::" +"They can be used to indicate that a function never returns, such as :func:" +"`sys.exit`::" msgstr "它們可以被用來代表一個不會回傳的函式,像是 :func:`sys.exit`: ::" #: ../../library/typing.rst:947 @@ -1603,8 +1601,8 @@ msgid "" "Or to define a function that should never be called, as there are no valid " "arguments, such as :func:`assert_never`::" msgstr "" -"或被用來定義一個不應被呼叫的函式,因為不會有有效的引數,、像" -"是 :func:`assert_never`: ::" +"或被用來定義一個不應被呼叫的函式,因為不會有有效的引數,、像是 :func:" +"`assert_never`: ::" #: ../../library/typing.rst:956 msgid "" @@ -1789,17 +1787,17 @@ msgstr "更多細節請見 :pep:`613`。" msgid "" ":data:`TypeAlias` is deprecated in favor of the :keyword:`type` statement, " "which creates instances of :class:`TypeAliasType` and which natively " -"supports forward references. Note that while :data:`TypeAlias` " -"and :class:`TypeAliasType` serve similar purposes and have similar names, " -"they are distinct and the latter is not the type of the former. Removal " -"of :data:`TypeAlias` is not currently planned, but users are encouraged to " -"migrate to :keyword:`type` statements." -msgstr "" -":data:`TypeAlias` 被棄用,請改用 :keyword:`type` 陳述式來建" -"立 :class:`TypeAliasType` 的實例,其自然可以支援傳遞參照的使用。請注意,雖" -"然 :data:`TypeAlias` 以及 :class:`TypeAliasType` 提供相似的用途且具有相似的名" -"稱,他們是不同的,且後者不是前者的型別。現在還沒有移除 :data:`TypeAlias` 的計" -"畫,但鼓勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。" +"supports forward references. Note that while :data:`TypeAlias` and :class:" +"`TypeAliasType` serve similar purposes and have similar names, they are " +"distinct and the latter is not the type of the former. Removal of :data:" +"`TypeAlias` is not currently planned, but users are encouraged to migrate " +"to :keyword:`type` statements." +msgstr "" +":data:`TypeAlias` 被棄用,請改用 :keyword:`type` 陳述式來建立 :class:" +"`TypeAliasType` 的實例,其自然可以支援傳遞參照的使用。請注意,雖然 :data:" +"`TypeAlias` 以及 :class:`TypeAliasType` 提供相似的用途且具有相似的名稱,他們" +"是不同的,且後者不是前者的型別。現在還沒有移除 :data:`TypeAlias` 的計畫,但鼓" +"勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。" #: ../../library/typing.rst:1084 msgid "Special forms" @@ -1959,9 +1957,9 @@ msgid "" "a :ref:`Callable `. The last parameter to " "``Concatenate`` must be a :class:`ParamSpec` or ellipsis (``...``)." msgstr "" -"``Concatenate`` 可以被用在\\ :ref:`可呼叫物件 `\\ " -"與 :class:`ParamSpec` 的接合 (conjunction) 並註釋一個高階的 Callable 物件可以" -"新增、移除、轉換另一個 Callable 物件的參數。使用方法是依照這個格式 " +"``Concatenate`` 可以被用在\\ :ref:`可呼叫物件 `\\ 與 :" +"class:`ParamSpec` 的接合 (conjunction) 並註釋一個高階的 Callable 物件可以新" +"增、移除、轉換另一個 Callable 物件的參數。使用方法是依照這個格式 " "``Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable]``。``Concatenate`` " "目前只在 :ref:`Callable 物件 `\\ 中第一個引數使用時有" "效。``Concatenate`` 的最後一個參數必須為一個 :class:`ParamSpec` 或是刪節號 " @@ -1969,13 +1967,13 @@ msgstr "" #: ../../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 " -"used to indicate that ``with_lock`` expects a callable which takes in a " -"``Lock`` as the first argument, and returns a callable with a different type " -"signature. In this case, the :class:`ParamSpec` indicates that the returned " -"callable's parameter types are dependent on the parameter types of the " -"callable being passed in::" +"For example, to annotate a decorator ``with_lock`` which provides a :class:" +"`threading.Lock` to the decorated function, ``Concatenate`` can be used to " +"indicate that ``with_lock`` expects a callable which takes in a ``Lock`` as " +"the first argument, and returns a callable with a different type signature. " +"In this case, the :class:`ParamSpec` indicates that the returned callable's " +"parameter types are dependent on the parameter types of the callable being " +"passed in::" msgstr "" "舉例來說,註釋一個為裝飾過後的函式提供 :class:`threading.Lock` 的裝飾器 " "``with_lock``,``Concatenate`` 可以用於指出 ``with_lock`` 預期一個 Callable " @@ -2150,16 +2148,15 @@ msgstr ":data:`ClassVar` 只接受型別請不得使用下標。" #: ../../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 " -"change Python runtime behavior, but it can be used by third-party type " -"checkers. For example, a type checker might flag the following code as an " -"error::" +":data:`ClassVar` is not a class itself, and should not be used with :func:" +"`isinstance` or :func:`issubclass`. :data:`ClassVar` does not change Python " +"runtime behavior, but it can be used by third-party type checkers. For " +"example, a type checker might flag the following code as an error::" msgstr "" -":data:`ClassVar` 並不代表該類別本身,而且不應該和 :func:`isinstance` 或" -"是 :func:`issubclass` 一起使用。:data:`ClassVar` 不會改變 Python runtime 的行" -"為,但它可以被第三方的型別檢查器使用。舉例來說,一個型別檢查器可能會標記下方" -"的程式碼為一個錯誤: ::" +":data:`ClassVar` 並不代表該類別本身,而且不應該和 :func:`isinstance` 或是 :" +"func:`issubclass` 一起使用。:data:`ClassVar` 不會改變 Python runtime 的行為," +"但它可以被第三方的型別檢查器使用。舉例來說,一個型別檢查器可能會標記下方的程" +"式碼為一個錯誤: ::" #: ../../library/typing.rst:1285 msgid "" @@ -2216,8 +2213,8 @@ msgid "" "This is mainly useful for ``total=False`` TypedDicts. See :class:`TypedDict` " "and :pep:`655` for more details." msgstr "" -"主要用於 ``total=False`` 的 TypedDict。更多細節請見 :class:`TypedDict` " -"與 :pep:`655`。" +"主要用於 ``total=False`` 的 TypedDict。更多細節請見 :class:`TypedDict` 與 :" +"pep:`655`。" #: ../../library/typing.rst:1333 msgid "" @@ -2379,8 +2376,8 @@ msgstr "" #: ../../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`::" +"type alias, to avoid forcing evaluation of the underlying :class:" +"`TypeAliasType`::" msgstr "" #: ../../library/typing.rst:1430 @@ -2493,8 +2490,8 @@ msgstr "" #: ../../library/typing.rst:1487 msgid "" -"If you want to retrieve the original type wrapped by ``Annotated``, use " -"the :attr:`!__origin__` attribute:" +"If you want to retrieve the original type wrapped by ``Annotated``, use the :" +"attr:`!__origin__` attribute:" msgstr "" #: ../../library/typing.rst:1490 @@ -2567,9 +2564,9 @@ msgstr "" #: ../../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[...]`` " -"or :data:`TypeGuard` as its return type to alert static type checkers to " -"this intention. ``TypeIs`` usually has more intuitive behavior than " +"type predicate. Such a function should use ``TypeIs[...]`` or :data:" +"`TypeGuard` as its return type to alert static type checkers to this " +"intention. ``TypeIs`` usually has more intuitive behavior than " "``TypeGuard``, but it cannot be used when the input and output types are " "incompatible (e.g., ``list[object]`` to ``list[int]``) or when the function " "does not return ``True`` for all instances of the narrowed type." @@ -2646,8 +2643,8 @@ msgstr "" #: ../../library/typing.rst:1590 msgid "" -"``TypeIs`` also works with type variables. For more information, " -"see :pep:`742` (Narrowing types with ``TypeIs``)." +"``TypeIs`` also works with type variables. For more information, see :pep:" +"`742` (Narrowing types with ``TypeIs``)." msgstr "" #: ../../library/typing.rst:1600 @@ -3081,9 +3078,9 @@ msgstr "" #: ../../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 " -"the :data:`typing.NoDefault` singleton, except that it does not force " -"evaluation of the :ref:`lazily evaluated ` default value." +"equivalent to checking whether :attr:`__default__` is not the :data:`typing." +"NoDefault` singleton, except that it does not force evaluation of the :ref:" +"`lazily evaluated ` default value." msgstr "" #: ../../library/typing.rst:1899 @@ -3294,9 +3291,9 @@ msgstr "" #: ../../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 " -"the :data:`typing.NoDefault` singleton, except that it does not force " -"evaluation of the :ref:`lazily evaluated ` default value." +"equivalent to checking whether :attr:`__default__` is not the :data:`typing." +"NoDefault` singleton, except that it does not force evaluation of the :ref:" +"`lazily evaluated ` default value." msgstr "" #: ../../library/typing.rst:2039 @@ -3389,15 +3386,15 @@ msgstr "" #: ../../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 " +"Since ``ParamSpec`` captures both positional and keyword parameters, ``P." +"args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its " "components. ``P.args`` represents the tuple of positional parameters in a " "given call and should only be used to annotate ``*args``. ``P.kwargs`` " "represents the mapping of keyword parameters to their values in a given " "call, and should be only be used to annotate ``**kwargs``. Both attributes " "require the annotated parameter to be in scope. At runtime, ``P.args`` and " -"``P.kwargs`` are instances respectively of :class:`ParamSpecArgs` " -"and :class:`ParamSpecKwargs`." +"``P.kwargs`` are instances respectively of :class:`ParamSpecArgs` and :class:" +"`ParamSpecKwargs`." msgstr "" #: ../../library/typing.rst:2113 @@ -3406,25 +3403,25 @@ msgstr "" #: ../../library/typing.rst:2117 msgid "" -"The default value of the parameter specification, " -"or :data:`typing.NoDefault` if it has no default." +"The default value of the parameter specification, or :data:`typing." +"NoDefault` if it has no default." msgstr "" #: ../../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 " -"the :data:`typing.NoDefault` singleton, except that it does not force " -"evaluation of the :ref:`lazily evaluated ` default value." +"is equivalent to checking whether :attr:`__default__` is not the :data:" +"`typing.NoDefault` singleton, except that it does not force evaluation of " +"the :ref:`lazily evaluated ` default value." msgstr "" #: ../../library/typing.rst:2131 msgid "" "Parameter specification variables created with ``covariant=True`` or " "``contravariant=True`` can be used to declare covariant or contravariant " -"generic types. The ``bound`` argument is also accepted, similar " -"to :class:`TypeVar`. However the actual semantics of these keywords are yet " -"to be decided." +"generic types. The ``bound`` argument is also accepted, similar to :class:" +"`TypeVar`. However the actual semantics of these keywords are yet to be " +"decided." msgstr "" #: ../../library/typing.rst:2141 @@ -3445,11 +3442,10 @@ msgstr ":data:`Concatenate`" #: ../../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``, " -"and ``P.kwargs`` is an instance of ``ParamSpecKwargs``. They are intended " -"for runtime introspection and have no special meaning to static type " -"checkers." +"Arguments and keyword arguments attributes of a :class:`ParamSpec`. The ``P." +"args`` attribute of a ``ParamSpec`` is an instance of ``ParamSpecArgs``, and " +"``P.kwargs`` is an instance of ``ParamSpecKwargs``. They are intended for " +"runtime introspection and have no special meaning to static type checkers." msgstr "" #: ../../library/typing.rst:2166 @@ -3800,11 +3796,11 @@ msgstr "" #: ../../library/typing.rst:2393 msgid "" -"See :pep:`544` for more details. Protocol classes decorated " -"with :func:`runtime_checkable` (described later) act as simple-minded " -"runtime protocols that check only the presence of given attributes, ignoring " -"their type signatures. Protocol classes without this decorator cannot be " -"used as the second argument to :func:`isinstance` or :func:`issubclass`." +"See :pep:`544` for more details. Protocol classes decorated with :func:" +"`runtime_checkable` (described later) act as simple-minded runtime protocols " +"that check only the presence of given attributes, ignoring their type " +"signatures. Protocol classes without this decorator cannot be used as the " +"second argument to :func:`isinstance` or :func:`issubclass`." msgstr "" #: ../../library/typing.rst:2399 @@ -3849,8 +3845,8 @@ msgstr "" 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 " -"ponies\" in :mod:`collections.abc` such " -"as :class:`~collections.abc.Iterable`. For example::" +"ponies\" in :mod:`collections.abc` such as :class:`~collections.abc." +"Iterable`. For example::" msgstr "" #: ../../library/typing.rst:2424 @@ -3889,12 +3885,12 @@ msgstr "" #: ../../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 " -"example, :class:`ssl.SSLObject` is a class, therefore it passes " -"an :func:`issubclass` check against :ref:`Callable `. " -"However, the ``ssl.SSLObject.__init__`` method exists only to raise " -"a :exc:`TypeError` with a more informative message, therefore making it " -"impossible to call (instantiate) :class:`ssl.SSLObject`." +"methods or attributes, not their type signatures or types. For example, :" +"class:`ssl.SSLObject` is a class, therefore it passes an :func:`issubclass` " +"check against :ref:`Callable `. However, the ``ssl." +"SSLObject.__init__`` method exists only to raise a :exc:`TypeError` with a " +"more informative message, therefore making it impossible to call " +"(instantiate) :class:`ssl.SSLObject`." msgstr "" #: ../../library/typing.rst:2452 @@ -3920,9 +3916,8 @@ 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 " "onto a runtime-checkable protocol will still work, but will have no impact " -"on :func:`isinstance` checks comparing objects to the protocol. " -"See :ref:`\"What's new in Python 3.12\" ` for more " -"details." +"on :func:`isinstance` checks comparing objects to the protocol. See :ref:" +"`What's new in Python 3.12 ` for more details." msgstr "" #: ../../library/typing.rst:2480 @@ -3964,10 +3959,10 @@ msgstr "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})" #: ../../library/typing.rst:2504 msgid "" -"This functional syntax allows defining keys which are not " -"valid :ref:`identifiers `, for example because they are " -"keywords or contain hyphens, or when key names must not be :ref:`mangled " -"` like regular private names::" +"This functional syntax allows defining keys which are not valid :ref:" +"`identifiers `, for example because they are keywords or " +"contain hyphens, or when key names must not be :ref:`mangled ` like regular private names::" msgstr "" #: ../../library/typing.rst:2509 @@ -4179,10 +4174,9 @@ msgstr "" #: ../../library/typing.rst:2612 msgid "" -"A ``TypedDict`` can be introspected via annotations dicts " -"(see :ref:`annotations-howto` for more information on annotations best " -"practices), :attr:`__total__`, :attr:`__required_keys__`, " -"and :attr:`__optional_keys__`." +"A ``TypedDict`` can be introspected via annotations dicts (see :ref:" +"`annotations-howto` for more information on annotations best practices), :" +"attr:`__total__`, :attr:`__required_keys__`, and :attr:`__optional_keys__`." msgstr "" #: ../../library/typing.rst:2618 @@ -4227,8 +4221,8 @@ msgstr "" #: ../../library/typing.rst:2647 msgid "" -"``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` " -"return :class:`frozenset` objects containing required and non-required keys, " +"``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` return :" +"class:`frozenset` objects containing required and non-required keys, " "respectively." msgstr "" @@ -4306,8 +4300,8 @@ msgstr "" #: ../../library/typing.rst:2704 msgid "" -"Added support for marking individual keys as :data:`Required` " -"or :data:`NotRequired`. See :pep:`655`." +"Added support for marking individual keys as :data:`Required` or :data:" +"`NotRequired`. See :pep:`655`." msgstr "" #: ../../library/typing.rst:2708 @@ -4524,9 +4518,9 @@ msgstr "" #: ../../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)::" +"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:2867 @@ -4553,8 +4547,8 @@ msgstr "" #: ../../library/typing.rst:2884 msgid "" -"Decorator to mark an object as providing :func:`dataclass " -"`-like behavior." +"Decorator to mark an object as providing :func:`dataclass `-like behavior." msgstr "" #: ../../library/typing.rst:2887 @@ -4639,9 +4633,9 @@ msgstr "" #: ../../library/typing.rst:2928 msgid "" "The ``CustomerModel`` classes defined above will be treated by type checkers " -"similarly to classes created with :func:`@dataclasses.dataclass " -"`. For example, type checkers will assume these " -"classes have ``__init__`` methods that accept ``id`` and ``name``." +"similarly to classes created with :func:`@dataclasses.dataclass `. For example, type checkers will assume these classes have " +"``__init__`` methods that accept ``id`` and ``name``." msgstr "" #: ../../library/typing.rst:2934 @@ -4817,8 +4811,8 @@ msgid "" "only, since they will be overwritten by the non-``@overload``-decorated " "definition. The non-``@overload``-decorated definition, meanwhile, will be " "used at runtime but should be ignored by a type checker. At runtime, " -"calling an ``@overload``-decorated function directly will " -"raise :exc:`NotImplementedError`." +"calling an ``@overload``-decorated function directly will raise :exc:" +"`NotImplementedError`." msgstr "" #: ../../library/typing.rst:3039 @@ -4860,8 +4854,8 @@ msgstr "" #: ../../library/typing.rst:3058 msgid "" -"Overloaded functions can now be introspected at runtime " -"using :func:`get_overloads`." +"Overloaded functions can now be introspected at runtime using :func:" +"`get_overloads`." msgstr "" #: ../../library/typing.rst:3065 @@ -5099,8 +5093,8 @@ msgstr "" #: ../../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)." +"with ``T``, unless *include_extras* is set to ``True`` (see :class:" +"`Annotated` for more information)." msgstr "" #: ../../library/typing.rst:3240 @@ -5112,8 +5106,8 @@ msgstr "" #: ../../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 " -"as :exc:`NameError`. For example, this can happen with imported :ref:`type " +"are not valid Python code, this function will raise an exception such as :" +"exc:`NameError`. For example, this can happen with imported :ref:`type " "aliases ` that include forward references, or with names " "imported under :data:`if TYPE_CHECKING `." msgstr "" @@ -5123,8 +5117,8 @@ msgid "" "Added ``include_extras`` parameter as part of :pep:`593`. See the " "documentation on :data:`Annotated` for more information." msgstr "" -"新增 ``include_extras`` 參數(如 :pep:`593` 中所述)。更多資訊請" -"見 :data:`Annotated` 的文件。" +"新增 ``include_extras`` 參數(如 :pep:`593` 中所述)。更多資訊請見 :data:" +"`Annotated` 的文件。" #: ../../library/typing.rst:3255 msgid "" @@ -5142,9 +5136,9 @@ msgstr "" #: ../../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 " -"of :class:`ParamSpecArgs` or :class:`ParamSpecKwargs`, return the " -"underlying :class:`ParamSpec`. Return ``None`` for unsupported objects." +"it will be normalized to the original class. If ``X`` is an instance of :" +"class:`ParamSpecArgs` or :class:`ParamSpecKwargs`, return the underlying :" +"class:`ParamSpec`. Return ``None`` for unsupported objects." msgstr "" #: ../../library/typing.rst:3271 ../../library/typing.rst:3295 @@ -5361,9 +5355,8 @@ msgstr "" 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 " -"releases prior to removal. The aliases are guaranteed to remain in " -"the :mod:`!typing` module without deprecation warnings until at least Python " -"3.14." +"releases prior to removal. The aliases are guaranteed to remain in the :mod:" +"`!typing` module without deprecation warnings until at least Python 3.14." msgstr "" #: ../../library/typing.rst:3443 @@ -5389,8 +5382,8 @@ msgstr "" #: ../../library/typing.rst:3459 msgid "" -":class:`builtins.dict ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.dict ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3465 @@ -5400,15 +5393,15 @@ msgstr "棄用 :class:`list` 的別名。" #: ../../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` " -"or :class:`~collections.abc.Iterable` rather than to use :class:`list` " -"or :class:`!typing.List`." +"collection type such as :class:`~collections.abc.Sequence` or :class:" +"`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!" +"typing.List`." msgstr "" #: ../../library/typing.rst:3472 msgid "" -":class:`builtins.list ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.list ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3478 @@ -5418,14 +5411,14 @@ msgstr "棄用 :class:`builtins.set ` 的別名。" #: ../../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`." +"collection type such as :class:`collections.abc.Set` rather than to use :" +"class:`set` or :class:`typing.Set`." msgstr "" #: ../../library/typing.rst:3484 msgid "" -":class:`builtins.set ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.set ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3490 @@ -5444,14 +5437,14 @@ msgstr "棄用 :class:`tuple` 的別名。" #: ../../library/typing.rst:3501 msgid "" -":class:`tuple` and ``Tuple`` are special-cased in the type system; " -"see :ref:`annotating-tuples` for more details." +":class:`tuple` and ``Tuple`` are special-cased in the type system; see :ref:" +"`annotating-tuples` for more details." msgstr "" #: ../../library/typing.rst:3504 msgid "" -":class:`builtins.tuple ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.tuple ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3510 @@ -5466,8 +5459,8 @@ msgstr "" #: ../../library/typing.rst:3517 msgid "" -":class:`builtins.type ` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`builtins.type ` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3524 @@ -5480,8 +5473,8 @@ msgstr "棄用 :class:`collections.defaultdict` 的別名。" #: ../../library/typing.rst:3532 msgid "" -":class:`collections.defaultdict` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.defaultdict` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3538 @@ -5490,8 +5483,8 @@ msgstr "棄用 :class:`collections.OrderedDict` 的別名。" #: ../../library/typing.rst:3542 msgid "" -":class:`collections.OrderedDict` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.OrderedDict` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3548 @@ -5500,8 +5493,8 @@ msgstr "棄用 :class:`collections.ChainMap` 的別名。" #: ../../library/typing.rst:3552 msgid "" -":class:`collections.ChainMap` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.ChainMap` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3558 @@ -5510,8 +5503,8 @@ msgstr "棄用 :class:`collections.Counter` 的別名。" #: ../../library/typing.rst:3562 msgid "" -":class:`collections.Counter` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.Counter` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3568 @@ -5520,8 +5513,8 @@ msgstr "棄用 :class:`collections.deque` 的別名。" #: ../../library/typing.rst:3572 msgid "" -":class:`collections.deque` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.deque` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3579 @@ -5536,16 +5529,16 @@ msgstr "" #: ../../library/typing.rst:3587 msgid "" -"These types (and the corresponding functions) are generic " -"over :data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or " +"These types (and the corresponding functions) are generic over :data:" +"`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or " "``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or " "``Match[bytes]``." msgstr "" #: ../../library/typing.rst:3592 msgid "" -"Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. " -"See :pep:`585` and :ref:`types-genericalias`." +"Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3598 @@ -5589,14 +5582,14 @@ msgstr "棄用 :class:`collections.abc.Set` 的別名。" #: ../../library/typing.rst:3628 msgid "" -":class:`collections.abc.Set` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Set` now supports subscripting (``[]``). See :pep:" +"`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3634 msgid "" -"This type represents the types :class:`bytes`, :class:`bytearray`, " -"and :class:`memoryview` of byte sequences." +"This type represents the types :class:`bytes`, :class:`bytearray`, and :" +"class:`memoryview` of byte sequences." msgstr "" #: ../../library/typing.rst:3637 @@ -5611,8 +5604,8 @@ msgstr "棄用 :class:`collections.abc.Collection` 的別名。" #: ../../library/typing.rst:3646 msgid "" -":class:`collections.abc.Collection` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Collection` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3652 @@ -5621,8 +5614,8 @@ msgstr "棄用 :class:`collections.abc.Container` 的別名。" #: ../../library/typing.rst:3654 msgid "" -":class:`collections.abc.Container` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Container` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3660 @@ -5631,8 +5624,8 @@ msgstr "棄用 :class:`collections.abc.ItemsView` 的別名。" #: ../../library/typing.rst:3662 msgid "" -":class:`collections.abc.ItemsView` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.ItemsView` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3668 @@ -5641,8 +5634,8 @@ msgstr "棄用 :class:`collections.abc.KeysView` 的別名。" #: ../../library/typing.rst:3670 msgid "" -":class:`collections.abc.KeysView` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.KeysView` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3676 @@ -5651,8 +5644,8 @@ msgstr "棄用 :class:`collections.abc.Mapping` 的別名。" #: ../../library/typing.rst:3678 msgid "" -":class:`collections.abc.Mapping` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Mapping` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3684 @@ -5691,8 +5684,8 @@ msgstr "棄用 :class:`collections.abc.MutableSet` 的別名。" #: ../../library/typing.rst:3712 msgid "" -":class:`collections.abc.MutableSet` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.MutableSet` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3718 @@ -5701,8 +5694,8 @@ msgstr "棄用 :class:`collections.abc.Sequence` 的別名。" #: ../../library/typing.rst:3720 msgid "" -":class:`collections.abc.Sequence` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Sequence` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3726 @@ -5711,8 +5704,8 @@ msgstr "棄用 :class:`collections.abc.ValuesView` 的別名。" #: ../../library/typing.rst:3728 msgid "" -":class:`collections.abc.ValuesView` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.ValuesView` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3735 @@ -5725,15 +5718,14 @@ msgstr "棄用 :class:`collections.abc.Coroutine` 的別名。" #: ../../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." +"See :ref:`annotating-generators-and-coroutines` for details on using :class:" +"`collections.abc.Coroutine` and ``typing.Coroutine`` in type annotations." msgstr "" #: ../../library/typing.rst:3747 msgid "" -":class:`collections.abc.Coroutine` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Coroutine` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3753 @@ -5742,9 +5734,9 @@ msgstr "棄用 :class:`collections.abc.AsyncGenerator` 的別名。" #: ../../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." +"See :ref:`annotating-generators-and-coroutines` for details on using :class:" +"`collections.abc.AsyncGenerator` and ``typing.AsyncGenerator`` in type " +"annotations." msgstr "" #: ../../library/typing.rst:3761 @@ -5783,8 +5775,8 @@ msgstr "棄用 :class:`collections.abc.Awaitable` 的別名。" #: ../../library/typing.rst:3795 msgid "" -":class:`collections.abc.Awaitable` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Awaitable` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3802 @@ -5797,8 +5789,8 @@ msgstr "棄用 :class:`collections.abc.Iterable` 的別名。" #: ../../library/typing.rst:3808 msgid "" -":class:`collections.abc.Iterable` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Iterable` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3814 @@ -5807,8 +5799,8 @@ msgstr "棄用 :class:`collections.abc.Iterator` 的別名。" #: ../../library/typing.rst:3816 msgid "" -":class:`collections.abc.Iterator` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Iterator` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3822 @@ -5817,15 +5809,14 @@ msgstr "棄用 :class:`collections.abc.Callable` 的別名。" #: ../../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." +"See :ref:`annotating-callables` for details on how to use :class:" +"`collections.abc.Callable` and ``typing.Callable`` in type annotations." msgstr "" #: ../../library/typing.rst:3827 msgid "" -":class:`collections.abc.Callable` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Callable` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3837 @@ -5834,15 +5825,14 @@ msgstr "棄用 :class:`collections.abc.Generator` 的別名。" #: ../../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." +"See :ref:`annotating-generators-and-coroutines` for details on using :class:" +"`collections.abc.Generator` and ``typing.Generator`` in type annotations." msgstr "" #: ../../library/typing.rst:3843 msgid "" -":class:`collections.abc.Generator` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Generator` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3847 @@ -5863,8 +5853,8 @@ msgstr "棄用 :class:`collections.abc.Reversible` 的別名。" #: ../../library/typing.rst:3861 msgid "" -":class:`collections.abc.Reversible` now supports subscripting (``[]``). " -"See :pep:`585` and :ref:`types-genericalias`." +":class:`collections.abc.Reversible` now supports subscripting (``[]``). See :" +"pep:`585` and :ref:`types-genericalias`." msgstr "" #: ../../library/typing.rst:3867 @@ -5885,8 +5875,8 @@ msgstr "" #: ../../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, " +"The first type parameter, ``T_co``, represents the type returned by the :" +"meth:`~object.__enter__` method. The optional second type parameter, " "``ExitT_co``, which defaults to ``bool | None``, represents the type " "returned by the :meth:`~object.__exit__` method." msgstr "" @@ -5907,8 +5897,8 @@ msgstr "" #: ../../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, " +"The first type parameter, ``T_co``, represents the type returned by the :" +"meth:`~object.__aenter__` method. The optional second type parameter, " "``AExitT_co``, which defaults to ``bool | None``, represents the type " "returned by the :meth:`~object.__aexit__` method." msgstr "" diff --git a/library/unittest.mock.po b/library/unittest.mock.po index 6fe3d592f0..0cc1d43f72 100644 --- a/library/unittest.mock.po +++ b/library/unittest.mock.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2025-08-09 00:16+0000\n" "PO-Revision-Date: 2024-02-19 21:27+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -722,13 +722,14 @@ msgid "Setting :attr:`side_effect` to ``None`` clears it:" msgstr "將 :attr:`side_effect` 設定為 ``None`` 可以清除它:" #: ../../library/unittest.mock.rst:639 +#, fuzzy msgid "" "This is either ``None`` (if the mock hasn't been called), or the arguments " "that the mock was last called with. This will be in the form of a tuple: the " "first member, which can also be accessed through the ``args`` property, is " -"any ordered arguments the mock was called with (or an empty tuple) and the " -"second member, which can also be accessed through the ``kwargs`` property, " -"is any keyword arguments (or an empty dictionary)." +"any positional arguments the mock was called with (or an empty tuple) and " +"the second member, which can also be accessed through the ``kwargs`` " +"property, is any keyword arguments (or an empty dictionary)." msgstr "" "這會是 ``None``\\ (如果 mock 尚未被呼叫),或是 mock 上次被呼叫時使用的引" "數。這將以元組的形式呈現:第一個成員 (member),其可以通過 ``args`` 屬性存取," From c93aff8ae21bdf7b81550e2803bb87b9ad231018 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 10 Aug 2025 00:20:32 +0000 Subject: [PATCH 10/13] sync with cpython a64c9488 --- howto/a-conceptual-overview-of-asyncio.po | 811 ++++++++++++++++++++++ howto/index.po | 62 +- library/asyncio-future.po | 92 +-- library/asyncio-task.po | 388 +++++------ library/asyncio.po | 66 +- library/time.po | 9 +- 6 files changed, 1123 insertions(+), 305 deletions(-) create mode 100644 howto/a-conceptual-overview-of-asyncio.po diff --git a/howto/a-conceptual-overview-of-asyncio.po b/howto/a-conceptual-overview-of-asyncio.po new file mode 100644 index 0000000000..16c9752003 --- /dev/null +++ b/howto/a-conceptual-overview-of-asyncio.po @@ -0,0 +1,811 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:5 +msgid "A Conceptual Overview of :mod:`!asyncio`" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:7 +msgid "" +"This :ref:`HOWTO ` article seeks to help you build a sturdy mental " +"model of how :mod:`asyncio` fundamentally works, helping you understand the " +"how and why behind the recommended patterns." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:11 +msgid "" +"You might be curious about some key :mod:`!asyncio` concepts. You'll be " +"comfortably able to answer these questions by the end of this article:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:15 +msgid "What's happening behind the scenes when an object is awaited?" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:16 +msgid "" +"How does :mod:`!asyncio` differentiate between a task which doesn't need CPU-" +"time (such as a network request or file read) as opposed to a task that does " +"(such as computing n-factorial)?" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:19 +msgid "" +"How to write an asynchronous variant of an operation, such as an async sleep " +"or database request." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:24 +msgid "" +"The `guide `_ that inspired this HOWTO article, by Alexander Nordin." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:26 +msgid "" +"This in-depth `YouTube tutorial series `_ on ``asyncio`` " +"created by Python core team member, Łukasz Langa." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:29 +msgid "" +"`500 Lines or Less: A Web Crawler With asyncio Coroutines `_ by A. Jesse Jiryu " +"Davis and Guido van Rossum." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:35 +msgid "A conceptual overview part 1: the high-level" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:37 +msgid "" +"In part 1, we'll cover the main, high-level building blocks of :mod:`!" +"asyncio`: the event loop, coroutine functions, coroutine objects, tasks and " +"``await``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:42 +msgid "Event Loop" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:44 +msgid "" +"Everything in :mod:`!asyncio` happens relative to the event loop. It's the " +"star of the show. It's like an orchestra conductor. It's behind the scenes " +"managing resources. Some power is explicitly granted to it, but a lot of its " +"ability to get things done comes from the respect and cooperation of its " +"worker bees." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:51 +msgid "" +"In more technical terms, the event loop contains a collection of jobs to be " +"run. Some jobs are added directly by you, and some indirectly by :mod:`!" +"asyncio`. The event loop takes a job from its backlog of work and invokes it " +"(or \"gives it control\"), similar to calling a function, and then that job " +"runs. Once it pauses or completes, it returns control to the event loop. The " +"event loop will then select another job from its pool and invoke it. You can " +"*roughly* think of the collection of jobs as a queue: jobs are added and " +"then processed one at a time, generally (but not always) in order. This " +"process repeats indefinitely with the event loop cycling endlessly onwards. " +"If there are no more jobs pending execution, the event loop is smart enough " +"to rest and avoid needlessly wasting CPU cycles, and will come back when " +"there's more work to be done." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:65 +msgid "" +"Effective execution relies on jobs sharing well and cooperating; a greedy " +"job could hog control and leave the other jobs to starve, rendering the " +"overall event loop approach rather useless." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:71 +msgid "" +"import asyncio\n" +"\n" +"# This creates an event loop and indefinitely cycles through\n" +"# its collection of jobs.\n" +"event_loop = asyncio.new_event_loop()\n" +"event_loop.run_forever()" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:80 +msgid "Asynchronous functions and coroutines" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:82 +msgid "This is a basic, boring Python function::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:84 +msgid "" +"def hello_printer():\n" +" print(\n" +" \"Hi, I am a lowly, simple printer, though I have all I \"\n" +" \"need in life -- \\nfresh paper and my dearly beloved octopus \"\n" +" \"partner in crime.\"\n" +" )" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:91 +msgid "Calling a regular function invokes its logic or body::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:93 +msgid "" +">>> hello_printer()\n" +"Hi, I am a lowly, simple printer, though I have all I need in life --\n" +"fresh paper and my dearly beloved octopus partner in crime." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:97 +msgid "" +"The :ref:`async def `, as opposed to just a plain ``def``, makes " +"this an asynchronous function (or \"coroutine function\"). Calling it " +"creates and returns a :ref:`coroutine ` object." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:103 +msgid "" +"async def loudmouth_penguin(magic_number: int):\n" +" print(\n" +" \"I am a super special talking penguin. Far cooler than that printer. " +"\"\n" +" f\"By the way, my lucky number is: {magic_number}.\"\n" +" )" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:109 +msgid "" +"Calling the async function, ``loudmouth_penguin``, does not execute the " +"print statement; instead, it creates a coroutine object::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:112 +msgid "" +">>> loudmouth_penguin(magic_number=3)\n" +"" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:115 +msgid "" +"The terms \"coroutine function\" and \"coroutine object\" are often " +"conflated as coroutine. That can be confusing! In this article, coroutine " +"specifically refers to a coroutine object, or more precisely, an instance " +"of :data:`types.CoroutineType` (native coroutine). Note that coroutines can " +"also exist as instances of :class:`collections.abc.Coroutine` -- a " +"distinction that matters for type checking." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:124 +msgid "" +"A coroutine represents the function's body or logic. A coroutine has to be " +"explicitly started; again, merely creating the coroutine does not start it. " +"Notably, the coroutine can be paused and resumed at various points within " +"the function's body. That pausing and resuming ability is what allows for " +"asynchronous behavior!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:131 +msgid "" +"Coroutines and coroutine functions were built by leveraging the " +"functionality of :term:`generators ` and :term:" +"`generator functions `. Recall, a generator function is a " +"function that :keyword:`yield`\\s, like this one::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:137 +msgid "" +"def get_random_number():\n" +" # This would be a bad random number generator!\n" +" print(\"Hi\")\n" +" yield 1\n" +" print(\"Hello\")\n" +" yield 7\n" +" print(\"Howdy\")\n" +" yield 4\n" +" ..." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:147 +msgid "" +"Similar to a coroutine function, calling a generator function does not run " +"it. Instead, it creates a generator object::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:150 +msgid "" +">>> get_random_number()\n" +"" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:153 +msgid "" +"You can proceed to the next ``yield`` of a generator by using the built-in " +"function :func:`next`. In other words, the generator runs, then pauses. For " +"example::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:158 +msgid "" +">>> generator = get_random_number()\n" +">>> next(generator)\n" +"Hi\n" +"1\n" +">>> next(generator)\n" +"Hello\n" +"7" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:168 +msgid "Tasks" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:170 +msgid "" +"Roughly speaking, :ref:`tasks ` are coroutines (not " +"coroutine functions) tied to an event loop. A task also maintains a list of " +"callback functions whose importance will become clear in a moment when we " +"discuss :keyword:`await`. The recommended way to create tasks is via :func:" +"`asyncio.create_task`." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:176 +msgid "" +"Creating a task automatically schedules it for execution (by adding a " +"callback to run it in the event loop's to-do list, that is, collection of " +"jobs)." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:179 +msgid "" +"Since there's only one event loop (in each thread), :mod:`!asyncio` takes " +"care of associating the task with the event loop for you. As such, there's " +"no need to specify the event loop." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:185 +msgid "" +"coroutine = loudmouth_penguin(magic_number=5)\n" +"# This creates a Task object and schedules its execution via the event " +"loop.\n" +"task = asyncio.create_task(coroutine)" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:189 +msgid "" +"Earlier, we manually created the event loop and set it to run forever. In " +"practice, it's recommended to use (and common to see) :func:`asyncio.run`, " +"which takes care of managing the event loop and ensuring the provided " +"coroutine finishes before advancing. For example, many async programs follow " +"this setup::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:195 +msgid "" +"import asyncio\n" +"\n" +"async def main():\n" +" # Perform all sorts of wacky, wild asynchronous things...\n" +" ...\n" +"\n" +"if __name__ == \"__main__\":\n" +" asyncio.run(main())\n" +" # The program will not reach the following print statement until the\n" +" # coroutine main() finishes.\n" +" print(\"coroutine main() is done!\")" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:207 +msgid "" +"It's important to be aware that the task itself is not added to the event " +"loop, only a callback to the task is. This matters if the task object you " +"created is garbage collected before it's called by the event loop. For " +"example, consider this program:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:213 +msgid "" +"async def hello():\n" +" print(\"hello!\")\n" +"\n" +"async def main():\n" +" asyncio.create_task(hello())\n" +" # Other asynchronous instructions which run for a while\n" +" # and cede control to the event loop...\n" +" ...\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:227 +msgid "" +"Because there's no reference to the task object created on line 5, it " +"*might* be garbage collected before the event loop invokes it. Later " +"instructions in the coroutine ``main()`` hand control back to the event loop " +"so it can invoke other jobs. When the event loop eventually tries to run the " +"task, it might fail and discover the task object does not exist! This can " +"also happen even if a coroutine keeps a reference to a task but completes " +"before that task finishes. When the coroutine exits, local variables go out " +"of scope and may be subject to garbage collection. In practice, ``asyncio`` " +"and Python's garbage collector work pretty hard to ensure this sort of thing " +"doesn't happen. But that's no reason to be reckless!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:243 +msgid "await" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:245 +msgid "" +":keyword:`await` is a Python keyword that's commonly used in one of two " +"different ways::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:248 +msgid "" +"await task\n" +"await coroutine" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:251 +msgid "" +"In a crucial way, the behavior of ``await`` depends on the type of object " +"being awaited." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:254 +msgid "" +"Awaiting a task will cede control from the current task or coroutine to the " +"event loop. In the process of relinquishing control, a few important things " +"happen. We'll use the following code example to illustrate::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:259 +msgid "" +"async def plant_a_tree():\n" +" dig_the_hole_task = asyncio.create_task(dig_the_hole())\n" +" await dig_the_hole_task\n" +"\n" +" # Other instructions associated with planting a tree.\n" +" ..." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:266 +msgid "" +"In this example, imagine the event loop has passed control to the start of " +"the coroutine ``plant_a_tree()``. As seen above, the coroutine creates a " +"task and then awaits it. The ``await dig_the_hole_task`` instruction adds a " +"callback (which will resume ``plant_a_tree()``) to the ``dig_the_hole_task`` " +"object's list of callbacks. And then, the instruction cedes control to the " +"event loop. Some time later, the event loop will pass control to " +"``dig_the_hole_task`` and the task will finish whatever it needs to do. Once " +"the task finishes, it will add its various callbacks to the event loop, in " +"this case, a call to resume ``plant_a_tree()``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:277 +msgid "" +"Generally speaking, when the awaited task finishes (``dig_the_hole_task``), " +"the original task or coroutine (``plant_a_tree()``) is added back to the " +"event loops to-do list to be resumed." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:281 +msgid "" +"This is a basic, yet reliable mental model. In practice, the control " +"handoffs are slightly more complex, but not by much. In part 2, we'll walk " +"through the details that make this possible." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:285 +msgid "" +"**Unlike tasks, awaiting a coroutine does not hand control back to the event " +"loop!** Wrapping a coroutine in a task first, then awaiting that would cede " +"control. The behavior of ``await coroutine`` is effectively the same as " +"invoking a regular, synchronous Python function. Consider this program::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:293 +msgid "" +"import asyncio\n" +"\n" +"async def coro_a():\n" +" print(\"I am coro_a(). Hi!\")\n" +"\n" +"async def coro_b():\n" +" print(\"I am coro_b(). I sure hope no one hogs the event loop...\")\n" +"\n" +"async def main():\n" +" task_b = asyncio.create_task(coro_b())\n" +" num_repeats = 3\n" +" for _ in range(num_repeats):\n" +" await coro_a()\n" +" await task_b\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:310 +msgid "" +"The first statement in the coroutine ``main()`` creates ``task_b`` and " +"schedules it for execution via the event loop. Then, ``coro_a()`` is " +"repeatedly awaited. Control never cedes to the event loop which is why we " +"see the output of all three ``coro_a()`` invocations before ``coro_b()``'s " +"output:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:316 +msgid "" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_b(). I sure hope no one hogs the event loop..." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:323 +msgid "" +"If we change ``await coro_a()`` to ``await asyncio.create_task(coro_a())``, " +"the behavior changes. The coroutine ``main()`` cedes control to the event " +"loop with that statement. The event loop then proceeds through its backlog " +"of work, calling ``task_b`` and then the task which wraps ``coro_a()`` " +"before resuming the coroutine ``main()``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:330 +msgid "" +"I am coro_b(). I sure hope no one hogs the event loop...\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:337 +msgid "" +"This behavior of ``await coroutine`` can trip a lot of people up! That " +"example highlights how using only ``await coroutine`` could unintentionally " +"hog control from other tasks and effectively stall the event loop. :func:" +"`asyncio.run` can help you detect such occurences via the ``debug=True`` " +"flag which accordingly enables :ref:`debug mode `. Among " +"other things, it will log any coroutines that monopolize execution for 100ms " +"or longer." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:347 +msgid "" +"The design intentionally trades off some conceptual clarity around usage of " +"``await`` for improved performance. Each time a task is awaited, control " +"needs to be passed all the way up the call stack to the event loop. That " +"might sound minor, but in a large program with many ``await``'s and a deep " +"callstack that overhead can add up to a meaningful performance drag." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:356 +msgid "A conceptual overview part 2: the nuts and bolts" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:358 +msgid "" +"Part 2 goes into detail on the mechanisms :mod:`!asyncio` uses to manage " +"control flow. This is where the magic happens. You'll come away from this " +"section knowing what ``await`` does behind the scenes and how to make your " +"own asynchronous operators." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:366 +msgid "The inner workings of coroutines" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:368 +msgid ":mod:`!asyncio` leverages four components to pass around control." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:370 +msgid "" +":meth:`coroutine.send(arg) ` is the method used to start or " +"resume a coroutine. If the coroutine was paused and is now being resumed, " +"the argument ``arg`` will be sent in as the return value of the ``yield`` " +"statement which originally paused it. If the coroutine is being used for the " +"first time (as opposed to being resumed) ``arg`` must be ``None``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:378 +msgid "" +"class Rock:\n" +" def __await__(self):\n" +" value_sent_in = yield 7\n" +" print(f\"Rock.__await__ resuming with value: {value_sent_in}.\")\n" +" return value_sent_in\n" +"\n" +"async def main():\n" +" print(\"Beginning coroutine main().\")\n" +" rock = Rock()\n" +" print(\"Awaiting rock...\")\n" +" value_from_rock = await rock\n" +" print(f\"Coroutine received value: {value_from_rock} from rock.\")\n" +" return 23\n" +"\n" +"coroutine = main()\n" +"intermediate_result = coroutine.send(None)\n" +"print(f\"Coroutine paused and returned intermediate value: " +"{intermediate_result}.\")\n" +"\n" +"print(f\"Resuming coroutine and sending in value: 42.\")\n" +"try:\n" +" coroutine.send(42)\n" +"except StopIteration as e:\n" +" returned_value = e.value\n" +"print(f\"Coroutine main() finished and provided value: {returned_value}.\")" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:406 +msgid "" +":ref:`yield `, like usual, pauses execution and returns control " +"to the caller. In the example above, the ``yield``, on line 3, is called by " +"``... = await rock`` on line 11. More broadly speaking, ``await`` calls the :" +"meth:`~object.__await__` method of the given object. ``await`` also does one " +"more very special thing: it propagates (or \"passes along\") any ``yield``\\ " +"s it receives up the call-chain. In this case, that's back to ``... = " +"coroutine.send(None)`` on line 16." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:416 +msgid "" +"The coroutine is resumed via the ``coroutine.send(42)`` call on line 21. The " +"coroutine picks back up from where it ``yield``\\ ed (or paused) on line 3 " +"and executes the remaining statements in its body. When a coroutine " +"finishes, it raises a :exc:`StopIteration` exception with the return value " +"attached in the :attr:`~StopIteration.value` attribute." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:422 +msgid "That snippet produces this output:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:424 +msgid "" +"Beginning coroutine main().\n" +"Awaiting rock...\n" +"Coroutine paused and returned intermediate value: 7.\n" +"Resuming coroutine and sending in value: 42.\n" +"Rock.__await__ resuming with value: 42.\n" +"Coroutine received value: 42 from rock.\n" +"Coroutine main() finished and provided value: 23." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:434 +msgid "" +"It's worth pausing for a moment here and making sure you followed the " +"various ways that control flow and values were passed. A lot of important " +"ideas were covered and it's worth ensuring your understanding is firm." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:438 +msgid "" +"The only way to yield (or effectively cede control) from a coroutine is to " +"``await`` an object that ``yield``\\ s in its ``__await__`` method. That " +"might sound odd to you. You might be thinking:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:442 +msgid "" +"1. What about a ``yield`` directly within the coroutine function? The " +"coroutine function becomes an :ref:`async generator function `, a different beast entirely." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:447 +msgid "" +"2. What about a :ref:`yield from ` within the coroutine function " +"to a (plain) generator? That causes the error: ``SyntaxError: yield from not " +"allowed in a coroutine.`` This was intentionally designed for the sake of " +"simplicity -- mandating only one way of using coroutines. Initially " +"``yield`` was barred as well, but was re-accepted to allow for async " +"generators. Despite that, ``yield from`` and ``await`` effectively do the " +"same thing." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:458 +msgid "Futures" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:460 +msgid "" +"A :ref:`future ` is an object meant to represent a " +"computation's status and result. The term is a nod to the idea of something " +"still to come or not yet happened, and the object is a way to keep an eye on " +"that something." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:465 +msgid "" +"A future has a few important attributes. One is its state which can be " +"either \"pending\", \"cancelled\" or \"done\". Another is its result, which " +"is set when the state transitions to done. Unlike a coroutine, a future does " +"not represent the actual computation to be done; instead, it represents the " +"status and result of that computation, kind of like a status light (red, " +"yellow or green) or indicator." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:472 +msgid "" +":class:`asyncio.Task` subclasses :class:`asyncio.Future` in order to gain " +"these various capabilities. The prior section said tasks store a list of " +"callbacks, which wasn't entirely accurate. It's actually the ``Future`` " +"class that implements this logic, which ``Task`` inherits." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:479 +msgid "" +"Futures may also be used directly (not via tasks). Tasks mark themselves as " +"done when their coroutine is complete. Futures are much more versatile and " +"will be marked as done when you say so. In this way, they're the flexible " +"interface for you to make your own conditions for waiting and resuming." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:487 +msgid "A homemade asyncio.sleep" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:489 +msgid "" +"We'll go through an example of how you could leverage a future to create " +"your own variant of asynchronous sleep (``async_sleep``) which mimics :func:" +"`asyncio.sleep`." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:493 +msgid "" +"This snippet registers a few tasks with the event loop and then awaits a " +"coroutine wrapped in a task: ``async_sleep(3)``. We want that task to finish " +"only after three seconds have elapsed, but without preventing other tasks " +"from running." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:500 +msgid "" +"async def other_work():\n" +" print(\"I like work. Work work.\")\n" +"\n" +"async def main():\n" +" # Add a few other tasks to the event loop, so there's something\n" +" # to do while asynchronously sleeping.\n" +" work_tasks = [\n" +" asyncio.create_task(other_work()),\n" +" asyncio.create_task(other_work()),\n" +" asyncio.create_task(other_work())\n" +" ]\n" +" print(\n" +" \"Beginning asynchronous sleep at time: \"\n" +" f\"{datetime.datetime.now().strftime(\"%H:%M:%S\")}.\"\n" +" )\n" +" await asyncio.create_task(async_sleep(3))\n" +" print(\n" +" \"Done asynchronous sleep at time: \"\n" +" f\"{datetime.datetime.now().strftime(\"%H:%M:%S\")}.\"\n" +" )\n" +" # asyncio.gather effectively awaits each task in the collection.\n" +" await asyncio.gather(*work_tasks)" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:524 +msgid "" +"Below, we use a future to enable custom control over when that task will be " +"marked as done. If :meth:`future.set_result() ` " +"(the method responsible for marking that future as done) is never called, " +"then this task will never finish. We've also enlisted the help of another " +"task, which we'll see in a moment, that will monitor how much time has " +"elapsed and, accordingly, call ``future.set_result()``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:535 +msgid "" +"async def async_sleep(seconds: float):\n" +" future = asyncio.Future()\n" +" time_to_wake = time.time() + seconds\n" +" # Add the watcher-task to the event loop.\n" +" watcher_task = asyncio.create_task(_sleep_watcher(future, " +"time_to_wake))\n" +" # Block until the future is marked as done.\n" +" await future" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:543 +msgid "" +"Below, we'll use a rather bare object, ``YieldToEventLoop()``, to ``yield`` " +"from ``__await__`` in order to cede control to the event loop. This is " +"effectively the same as calling ``asyncio.sleep(0)``, but this approach " +"offers more clarity, not to mention it's somewhat cheating to use ``asyncio." +"sleep`` when showcasing how to implement it!" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:549 +msgid "" +"As usual, the event loop cycles through its tasks, giving them control and " +"receiving control back when they pause or finish. The ``watcher_task``, " +"which runs the coroutine ``_sleep_watcher(...)``, will be invoked once per " +"full cycle of the event loop. On each resumption, it'll check the time and " +"if not enough has elapsed, then it'll pause once again and hand control back " +"to the event loop. Eventually, enough time will have elapsed, and " +"``_sleep_watcher(...)`` will mark the future as done, and then itself finish " +"too by breaking out of the infinite ``while`` loop. Given this helper task " +"is only invoked once per cycle of the event loop, you'd be correct to note " +"that this asynchronous sleep will sleep *at least* three seconds, rather " +"than exactly three seconds. Note this is also of true of ``asyncio.sleep``." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:565 +msgid "" +"class YieldToEventLoop:\n" +" def __await__(self):\n" +" yield\n" +"\n" +"async def _sleep_watcher(future, time_to_wake):\n" +" while True:\n" +" if time.time() >= time_to_wake:\n" +" # This marks the future as done.\n" +" future.set_result(None)\n" +" break\n" +" else:\n" +" await YieldToEventLoop()" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:578 +msgid "Here is the full program's output:" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:580 +msgid "" +"$ python custom-async-sleep.py\n" +"Beginning asynchronous sleep at time: 14:52:22.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"Done asynchronous sleep at time: 14:52:25." +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:589 +msgid "" +"You might feel this implementation of asynchronous sleep was unnecessarily " +"convoluted. And, well, it was. The example was meant to showcase the " +"versatility of futures with a simple example that could be mimicked for more " +"complex needs. For reference, you could implement it without futures, like " +"so::" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:596 +msgid "" +"async def simpler_async_sleep(seconds):\n" +" time_to_wake = time.time() + seconds\n" +" while True:\n" +" if time.time() >= time_to_wake:\n" +" return\n" +" else:\n" +" await YieldToEventLoop()" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:604 +msgid "" +"But, that's all for now. Hopefully you're ready to more confidently dive " +"into some async programming or check out advanced topics in the :mod:`rest " +"of the documentation `." +msgstr "" diff --git a/howto/index.po b/howto/index.po index d2b94700c4..76a2da176b 100644 --- a/howto/index.po +++ b/howto/index.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-04 00:13+0000\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2021-07-05 12:45+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,11 +20,11 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" "X-Generator: Poedit 2.4.3\n" -#: ../../howto/index.rst:3 +#: ../../howto/index.rst:5 msgid "Python HOWTOs" msgstr "Python 如何達成任務" -#: ../../howto/index.rst:5 +#: ../../howto/index.rst:7 msgid "" "Python HOWTOs are documents that cover a specific topic in-depth. Modeled on " "the Linux Documentation Project's HOWTO collection, this collection is an " @@ -35,106 +35,110 @@ msgstr "" "定的主題。以 Linux 說明文件專案的 HOWTO 系列為模範,本系列的目標是提供比 " "Python 函式庫參考手冊更實用的說明文件。" -#: ../../howto/index.rst:38 +#: ../../howto/index.rst:41 msgid "General:" msgstr "" -#: ../../howto/index.rst:40 +#: ../../howto/index.rst:43 +msgid ":ref:`a-conceptual-overview-of-asyncio`" +msgstr "" + +#: ../../howto/index.rst:44 msgid ":ref:`annotations-howto`" msgstr ":ref:`annotations-howto`" -#: ../../howto/index.rst:41 +#: ../../howto/index.rst:45 msgid ":ref:`argparse-tutorial`" msgstr ":ref:`argparse-tutorial`" -#: ../../howto/index.rst:42 +#: ../../howto/index.rst:46 msgid ":ref:`descriptorhowto`" msgstr ":ref:`descriptorhowto`" -#: ../../howto/index.rst:43 +#: ../../howto/index.rst:47 msgid ":ref:`enum-howto`" msgstr ":ref:`enum-howto`" -#: ../../howto/index.rst:44 +#: ../../howto/index.rst:48 msgid ":ref:`functional-howto`" msgstr ":ref:`functional-howto`" -#: ../../howto/index.rst:45 +#: ../../howto/index.rst:49 msgid ":ref:`ipaddress-howto`" msgstr ":ref:`ipaddress-howto`" -#: ../../howto/index.rst:46 +#: ../../howto/index.rst:50 msgid ":ref:`logging-howto`" msgstr ":ref:`logging-howto`" -#: ../../howto/index.rst:47 +#: ../../howto/index.rst:51 msgid ":ref:`logging-cookbook`" msgstr ":ref:`logging-cookbook`" -#: ../../howto/index.rst:48 +#: ../../howto/index.rst:52 msgid ":ref:`regex-howto`" msgstr ":ref:`regex-howto`" -#: ../../howto/index.rst:49 +#: ../../howto/index.rst:53 msgid ":ref:`sortinghowto`" msgstr ":ref:`sortinghowto`" -#: ../../howto/index.rst:50 +#: ../../howto/index.rst:54 msgid ":ref:`unicode-howto`" msgstr ":ref:`unicode-howto`" -#: ../../howto/index.rst:51 +#: ../../howto/index.rst:55 msgid ":ref:`urllib-howto`" msgstr ":ref:`urllib-howto`" -#: ../../howto/index.rst:53 +#: ../../howto/index.rst:57 msgid "Advanced development:" msgstr "" -#: ../../howto/index.rst:55 +#: ../../howto/index.rst:59 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../howto/index.rst:56 +#: ../../howto/index.rst:60 msgid ":ref:`freethreading-python-howto`" msgstr ":ref:`freethreading-python-howto`" -#: ../../howto/index.rst:57 +#: ../../howto/index.rst:61 msgid ":ref:`freethreading-extensions-howto`" msgstr ":ref:`freethreading-extensions-howto`" -#: ../../howto/index.rst:58 +#: ../../howto/index.rst:62 msgid ":ref:`isolating-extensions-howto`" msgstr ":ref:`isolating-extensions-howto`" -#: ../../howto/index.rst:59 +#: ../../howto/index.rst:63 msgid ":ref:`python_2.3_mro`" msgstr ":ref:`python_2.3_mro`" -#: ../../howto/index.rst:60 +#: ../../howto/index.rst:64 msgid ":ref:`socket-howto`" msgstr ":ref:`socket-howto`" -#: ../../howto/index.rst:61 +#: ../../howto/index.rst:65 msgid ":ref:`timerfd-howto`" msgstr ":ref:`timerfd-howto`" -#: ../../howto/index.rst:62 +#: ../../howto/index.rst:66 msgid ":ref:`cporting-howto`" msgstr ":ref:`cporting-howto`" -#: ../../howto/index.rst:64 +#: ../../howto/index.rst:68 msgid "Debugging and profiling:" msgstr "" -#: ../../howto/index.rst:66 +#: ../../howto/index.rst:70 msgid ":ref:`gdb`" msgstr ":ref:`gdb`" -#: ../../howto/index.rst:67 +#: ../../howto/index.rst:71 msgid ":ref:`instrumentation`" msgstr ":ref:`instrumentation`" -#: ../../howto/index.rst:68 +#: ../../howto/index.rst:72 msgid ":ref:`perf_profiling`" msgstr ":ref:`perf_profiling`" diff --git a/library/asyncio-future.po b/library/asyncio-future.po index 94e7426522..4d8e563a85 100644 --- a/library/asyncio-future.po +++ b/library/asyncio-future.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2022-01-25 01:29+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -132,18 +132,18 @@ msgstr "" "如果 *future* 不是類 Future 物件且 *loop* 未被指定,同時沒有正在執行的事件迴" "圈,則會發出棄用警告。" -#: ../../library/asyncio-future.rst:79 +#: ../../library/asyncio-future.rst:80 msgid "Future Object" msgstr "Future 物件" -#: ../../library/asyncio-future.rst:83 +#: ../../library/asyncio-future.rst:84 msgid "" "A Future represents an eventual result of an asynchronous operation. Not " "thread-safe." msgstr "" "一個 Future 代表一個非同步運算的最終結果。並不支援執行緒安全 (thread-safe)。" -#: ../../library/asyncio-future.rst:86 +#: ../../library/asyncio-future.rst:87 msgid "" "Future is an :term:`awaitable` object. Coroutines can await on Future " "objects until they either have a result or an exception set, or until they " @@ -152,7 +152,7 @@ msgstr "" "Future 是一個 :term:`awaitable` 物件。協程可以等待 Future 物件直到它們有結果" "或例外被設置、或者被取消。一個 Future 可被多次等待而結果都會是相同的。" -#: ../../library/asyncio-future.rst:91 +#: ../../library/asyncio-future.rst:92 msgid "" "Typically Futures are used to enable low-level callback-based code (e.g. in " "protocols implemented using asyncio :ref:`transports `\\ )能夠與高階 async/await 程式互" "動。" -#: ../../library/asyncio-future.rst:96 +#: ../../library/asyncio-future.rst:97 msgid "" "The rule of thumb is to never expose Future objects in user-facing APIs, and " "the recommended way to create a Future object is to call :meth:`loop." @@ -173,21 +173,21 @@ msgstr "" "meth:`loop.create_future` 來建立 Future 物件。如此一來,不同實作的事件迴圈可" "以注入自己最佳化實作的 Future 物件。" -#: ../../library/asyncio-future.rst:102 +#: ../../library/asyncio-future.rst:103 msgid "Added support for the :mod:`contextvars` module." msgstr "加入對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-future.rst:105 +#: ../../library/asyncio-future.rst:106 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "如果未指定 *loop* 並且沒有正在執行的事件迴圈則會發出棄用警告。" -#: ../../library/asyncio-future.rst:111 +#: ../../library/asyncio-future.rst:112 msgid "Return the result of the Future." msgstr "回傳 Future 的結果。" -#: ../../library/asyncio-future.rst:113 +#: ../../library/asyncio-future.rst:114 msgid "" "If the Future is *done* and has a result set by the :meth:`set_result` " "method, the result value is returned." @@ -195,7 +195,7 @@ msgstr "" "如果 Future 狀態為 *done*\\ (完成),並擁有 :meth:`set_result` 方法設定的一" "個結果,則回傳該結果之值。" -#: ../../library/asyncio-future.rst:116 +#: ../../library/asyncio-future.rst:117 msgid "" "If the Future is *done* and has an exception set by the :meth:" "`set_exception` method, this method raises the exception." @@ -203,7 +203,7 @@ msgstr "" "如果 Future 狀態為 *done*,並擁有 :meth:`set_exception` 方法設定的一個例外," "那麼這個方法會引發該例外。" -#: ../../library/asyncio-future.rst:119 ../../library/asyncio-future.rst:207 +#: ../../library/asyncio-future.rst:120 ../../library/asyncio-future.rst:208 msgid "" "If the Future has been *cancelled*, this method raises a :exc:" "`CancelledError` exception." @@ -211,31 +211,31 @@ msgstr "" "如果 Future 已被 *cancelled*\\ (取消),此方法會引發一個 :exc:" "`CancelledError` 例外。" -#: ../../library/asyncio-future.rst:122 +#: ../../library/asyncio-future.rst:123 msgid "" "If the Future's result isn't yet available, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" "如果 Future 的結果還不可用,此方法會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:127 +#: ../../library/asyncio-future.rst:128 msgid "Mark the Future as *done* and set its result." msgstr "將 Future 標記為 *done* 並設定其結果。" -#: ../../library/asyncio-future.rst:129 ../../library/asyncio-future.rst:136 +#: ../../library/asyncio-future.rst:130 ../../library/asyncio-future.rst:137 msgid "" "Raises an :exc:`InvalidStateError` error if the Future is already *done*." msgstr "如果 Future 已經 *done* 則引發一個 :exc:`InvalidStateError` 錯誤。" -#: ../../library/asyncio-future.rst:134 +#: ../../library/asyncio-future.rst:135 msgid "Mark the Future as *done* and set an exception." msgstr "將 Future 標記為 *done* 並設定一個例外。" -#: ../../library/asyncio-future.rst:141 +#: ../../library/asyncio-future.rst:142 msgid "Return ``True`` if the Future is *done*." msgstr "如果 Future 已為 *done* 則回傳 ``True``。" -#: ../../library/asyncio-future.rst:143 +#: ../../library/asyncio-future.rst:144 msgid "" "A Future is *done* if it was *cancelled* or if it has a result or an " "exception set with :meth:`set_result` or :meth:`set_exception` calls." @@ -243,18 +243,18 @@ msgstr "" "如果 Future 有被 *cancelled*、:meth:`set_result` 有被呼叫來為其設定結果、或 :" "meth:`set_exception` 有被呼叫為其設定例外,那麼它就是 *done*。" -#: ../../library/asyncio-future.rst:149 +#: ../../library/asyncio-future.rst:150 msgid "Return ``True`` if the Future was *cancelled*." msgstr "如果 Future 已經被 *cancelled* 則回傳 ``True``。" -#: ../../library/asyncio-future.rst:151 +#: ../../library/asyncio-future.rst:152 msgid "" "The method is usually used to check if a Future is not *cancelled* before " "setting a result or an exception for it::" msgstr "" "這個方法通常在為 Future 設定結果或例外前用來確認它還沒被 *cancelled*: ::" -#: ../../library/asyncio-future.rst:154 +#: ../../library/asyncio-future.rst:155 msgid "" "if not fut.cancelled():\n" " fut.set_result(42)" @@ -262,15 +262,15 @@ msgstr "" "if not fut.cancelled():\n" " fut.set_result(42)" -#: ../../library/asyncio-future.rst:159 +#: ../../library/asyncio-future.rst:160 msgid "Add a callback to be run when the Future is *done*." msgstr "新增一個在 Future 為 *done* 時執行的回呼函式。" -#: ../../library/asyncio-future.rst:161 +#: ../../library/asyncio-future.rst:162 msgid "The *callback* is called with the Future object as its only argument." msgstr "呼叫 *callback* 並附帶做為唯一引數的 Future 物件。" -#: ../../library/asyncio-future.rst:164 +#: ../../library/asyncio-future.rst:165 msgid "" "If the Future is already *done* when this method is called, the callback is " "scheduled with :meth:`loop.call_soon`." @@ -278,7 +278,7 @@ msgstr "" "如果呼叫這個方法時 Future 已經為 *done*,回呼函式會被 :meth:`loop.call_soon` " "排程。" -#: ../../library/asyncio-future.rst:167 +#: ../../library/asyncio-future.rst:168 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *callback* to run in. The current " @@ -287,40 +287,40 @@ msgstr "" "可選僅限關鍵字引數 *context* 用來指定一個讓 *callback* 執行於其中的客製化 :" "class:`contextvars.Context` 物件。如果沒有提供 *context*,則使用目前情境。" -#: ../../library/asyncio-future.rst:171 +#: ../../library/asyncio-future.rst:172 msgid "" ":func:`functools.partial` can be used to pass parameters to the callback, e." "g.::" msgstr "可以用 :func:`functools.partial` 傳遞引數給回呼函式,例如: ::" -#: ../../library/asyncio-future.rst:174 +#: ../../library/asyncio-future.rst:175 msgid "" "# Call 'print(\"Future:\", fut)' when \"fut\" is done.\n" "fut.add_done_callback(\n" " functools.partial(print, \"Future:\"))" msgstr "" -#: ../../library/asyncio-future.rst:178 +#: ../../library/asyncio-future.rst:179 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." msgstr "加入僅限關鍵字參數 *context*。更多細節請參閱 :pep:`567`。" -#: ../../library/asyncio-future.rst:184 +#: ../../library/asyncio-future.rst:185 msgid "Remove *callback* from the callbacks list." msgstr "從回呼列表中移除 *callback*。" -#: ../../library/asyncio-future.rst:186 +#: ../../library/asyncio-future.rst:187 msgid "" "Returns the number of callbacks removed, which is typically 1, unless a " "callback was added more than once." msgstr "回傳被移除的回呼函式數量,通常為 1,除非一個回呼函式被多次加入。" -#: ../../library/asyncio-future.rst:191 +#: ../../library/asyncio-future.rst:192 msgid "Cancel the Future and schedule callbacks." msgstr "取消 Future 並為回呼函式排程。" -#: ../../library/asyncio-future.rst:193 +#: ../../library/asyncio-future.rst:194 msgid "" "If the Future is already *done* or *cancelled*, return ``False``. Otherwise, " "change the Future's state to *cancelled*, schedule the callbacks, and return " @@ -329,33 +329,33 @@ msgstr "" "如果 Future 已經是 *done* 或 *cancelled*,回傳 ``False``。否則將 Future 狀態" "改為 *cancelled* 並在為回呼函式排程後回傳 ``True``。" -#: ../../library/asyncio-future.rst:197 +#: ../../library/asyncio-future.rst:198 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-future.rst:202 +#: ../../library/asyncio-future.rst:203 msgid "Return the exception that was set on this Future." msgstr "回傳被設定於此 Future 的例外。" -#: ../../library/asyncio-future.rst:204 +#: ../../library/asyncio-future.rst:205 msgid "" "The exception (or ``None`` if no exception was set) is returned only if the " "Future is *done*." msgstr "" "只有 Future 在 *done* 時才回傳例外(如果沒有設定例外則回傳 ``None``\\ )。" -#: ../../library/asyncio-future.rst:210 +#: ../../library/asyncio-future.rst:211 msgid "" "If the Future isn't *done* yet, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" "如果 Future 還不為 *done*,此方法會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:215 +#: ../../library/asyncio-future.rst:216 msgid "Return the event loop the Future object is bound to." msgstr "回傳已被 Future 物件繫結 (bind) 的事件迴圈。" -#: ../../library/asyncio-future.rst:222 +#: ../../library/asyncio-future.rst:223 msgid "" "This example creates a Future object, creates and schedules an asynchronous " "Task to set result for the Future, and waits until the Future has a result::" @@ -363,7 +363,7 @@ msgstr "" "這個例子建立一個 Future 物件,建立一個非同步 Task 並為其排程以設定 Future 結" "果,然後等待 Future 結果出現: ::" -#: ../../library/asyncio-future.rst:226 +#: ../../library/asyncio-future.rst:227 msgid "" "async def set_after(fut, delay, value):\n" " # Sleep for *delay* seconds.\n" @@ -394,7 +394,7 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-future.rst:257 +#: ../../library/asyncio-future.rst:258 msgid "" "The Future object was designed to mimic :class:`concurrent.futures.Future`. " "Key differences include:" @@ -402,7 +402,7 @@ msgstr "" "該 Future 物件是為了模仿 :class:`concurrent.futures.Future` 而設計。主要差異" "包含:" -#: ../../library/asyncio-future.rst:260 +#: ../../library/asyncio-future.rst:261 msgid "" "unlike asyncio Futures, :class:`concurrent.futures.Future` instances cannot " "be awaited." @@ -410,7 +410,7 @@ msgstr "" "與 asyncio 的 Future 不同,:class:`concurrent.futures.Future` 實例不可被等" "待。" -#: ../../library/asyncio-future.rst:263 +#: ../../library/asyncio-future.rst:264 msgid "" ":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` do not " "accept the *timeout* argument." @@ -418,7 +418,7 @@ msgstr "" ":meth:`asyncio.Future.result` 和 :meth:`asyncio.Future.exception` 不接受 " "*timeout* 引數。" -#: ../../library/asyncio-future.rst:266 +#: ../../library/asyncio-future.rst:267 msgid "" ":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` raise an :" "exc:`InvalidStateError` exception when the Future is not *done*." @@ -426,7 +426,7 @@ msgstr "" "Future 不為 *done* 時 :meth:`asyncio.Future.result` 和 :meth:`asyncio.Future." "exception` 會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:270 +#: ../../library/asyncio-future.rst:271 msgid "" "Callbacks registered with :meth:`asyncio.Future.add_done_callback` are not " "called immediately. They are scheduled with :meth:`loop.call_soon` instead." @@ -434,7 +434,7 @@ msgstr "" "使用 :meth:`asyncio.Future.add_done_callback` 註冊的回呼函式不會立即呼叫,而" "是被 :meth:`loop.call_soon` 排程。" -#: ../../library/asyncio-future.rst:274 +#: ../../library/asyncio-future.rst:275 msgid "" "asyncio Future is not compatible with the :func:`concurrent.futures.wait` " "and :func:`concurrent.futures.as_completed` functions." @@ -442,7 +442,7 @@ msgstr "" "asyncio Future 不能與 :func:`concurrent.futures.wait` 和 :func:`concurrent." "futures.as_completed` 函式相容。" -#: ../../library/asyncio-future.rst:278 +#: ../../library/asyncio-future.rst:279 msgid "" ":meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument, but :" "meth:`concurrent.futures.Future.cancel` does not." diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 9d69ab5503..07925812b0 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-14 00:15+0000\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -199,8 +199,8 @@ msgstr "" #: ../../library/asyncio-task.rst:110 msgid "" -"The :class:`asyncio.TaskGroup` class provides a more modern alternative " -"to :func:`create_task`. Using this API, the last example becomes::" +"The :class:`asyncio.TaskGroup` class provides a more modern alternative to :" +"func:`create_task`. Using this API, the last example becomes::" msgstr "" #: ../../library/asyncio-task.rst:114 @@ -234,8 +234,8 @@ msgstr "" #: ../../library/asyncio-task.rst:139 msgid "" -"We say that an object is an **awaitable** object if it can be used in " -"an :keyword:`await` expression. Many asyncio APIs are designed to accept " +"We say that an object is an **awaitable** object if it can be used in an :" +"keyword:`await` expression. Many asyncio APIs are designed to accept " "awaitables." msgstr "" @@ -295,9 +295,8 @@ msgstr "" #: ../../library/asyncio-task.rst:183 msgid "" -"When a coroutine is wrapped into a *Task* with functions " -"like :func:`asyncio.create_task` the coroutine is automatically scheduled to " -"run soon::" +"When a coroutine is wrapped into a *Task* with functions like :func:`asyncio." +"create_task` the coroutine is automatically scheduled to run soon::" msgstr "" #: ../../library/asyncio-task.rst:187 @@ -367,8 +366,8 @@ msgstr "" #: ../../library/asyncio-task.rst:230 msgid "" -"A good example of a low-level function that returns a Future object " -"is :meth:`loop.run_in_executor`." +"A good example of a low-level function that returns a Future object is :meth:" +"`loop.run_in_executor`." msgstr "" #: ../../library/asyncio-task.rst:235 @@ -387,22 +386,21 @@ msgstr "" #: ../../library/asyncio-task.rst:246 msgid "" -"If *name* is not ``None``, it is set as the name of the task " -"using :meth:`Task.set_name`." +"If *name* is not ``None``, it is set as the name of the task using :meth:" +"`Task.set_name`." msgstr "" #: ../../library/asyncio-task.rst:249 msgid "" -"An optional keyword-only *context* argument allows specifying a " -"custom :class:`contextvars.Context` for the *coro* to run in. The current " -"context copy is created when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a custom :" +"class:`contextvars.Context` for the *coro* to run in. The current context " +"copy is created when no *context* is provided." msgstr "" #: ../../library/asyncio-task.rst:253 msgid "" -"The task is executed in the loop returned " -"by :func:`get_running_loop`, :exc:`RuntimeError` is raised if there is no " -"running loop in current thread." +"The task is executed in the loop returned by :func:`get_running_loop`, :exc:" +"`RuntimeError` is raised if there is no running loop in current thread." msgstr "" #: ../../library/asyncio-task.rst:259 @@ -437,11 +435,11 @@ msgid "" " task.add_done_callback(background_tasks.discard)" msgstr "" -#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1192 +#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1193 msgid "Added the *name* parameter." msgstr "新增 *name* 參數。" -#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1199 +#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1200 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" @@ -451,30 +449,28 @@ msgstr "" #: ../../library/asyncio-task.rst:297 msgid "" -"Tasks can easily and safely be cancelled. When a task is " -"cancelled, :exc:`asyncio.CancelledError` will be raised in the task at the " -"next opportunity." +"Tasks can easily and safely be cancelled. When a task is cancelled, :exc:" +"`asyncio.CancelledError` will be raised in the task at the next opportunity." msgstr "" #: ../../library/asyncio-task.rst:301 msgid "" "It is recommended that coroutines use ``try/finally`` blocks to robustly " "perform clean-up logic. In case :exc:`asyncio.CancelledError` is explicitly " -"caught, it should generally be propagated when clean-up is " -"complete. :exc:`asyncio.CancelledError` directly " -"subclasses :exc:`BaseException` so most code will not need to be aware of it." +"caught, it should generally be propagated when clean-up is complete. :exc:" +"`asyncio.CancelledError` directly subclasses :exc:`BaseException` so most " +"code will not need to be aware of it." msgstr "" #: ../../library/asyncio-task.rst:307 msgid "" -"The asyncio components that enable structured concurrency, " -"like :class:`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented " -"using cancellation internally and might misbehave if a coroutine " -"swallows :exc:`asyncio.CancelledError`. Similarly, user code should not " -"generally call :meth:`uncancel `. However, in cases " -"when suppressing :exc:`asyncio.CancelledError` is truly desired, it is " -"necessary to also call ``uncancel()`` to completely remove the cancellation " -"state." +"The asyncio components that enable structured concurrency, like :class:" +"`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented using " +"cancellation internally and might misbehave if a coroutine swallows :exc:" +"`asyncio.CancelledError`. Similarly, user code should not generally call :" +"meth:`uncancel `. However, in cases when suppressing :" +"exc:`asyncio.CancelledError` is truly desired, it is necessary to also call " +"``uncancel()`` to completely remove the cancellation state." msgstr "" #: ../../library/asyncio-task.rst:319 @@ -496,10 +492,10 @@ msgstr "" #: ../../library/asyncio-task.rst:335 msgid "" -"Create a task in this task group. The signature matches that " -"of :func:`asyncio.create_task`. If the task group is inactive (e.g. not yet " -"entered, already finished, or in the process of shutting down), we will " -"close the given ``coro``." +"Create a task in this task group. The signature matches that of :func:" +"`asyncio.create_task`. If the task group is inactive (e.g. not yet entered, " +"already finished, or in the process of shutting down), we will close the " +"given ``coro``." msgstr "" #: ../../library/asyncio-task.rst:343 @@ -518,8 +514,8 @@ msgid "" " async with asyncio.TaskGroup() as tg:\n" " task1 = tg.create_task(some_coro(...))\n" " task2 = tg.create_task(another_coro(...))\n" -" print(f\"Both tasks have completed now: {task1.result()}, " -"{task2.result()}\")" +" print(f\"Both tasks have completed now: {task1.result()}, {task2." +"result()}\")" msgstr "" #: ../../library/asyncio-task.rst:353 @@ -536,11 +532,11 @@ msgid "" "The first time any of the tasks belonging to the group fails with an " "exception other than :exc:`asyncio.CancelledError`, the remaining tasks in " "the group are cancelled. No further tasks can then be added to the group. At " -"this point, if the body of the ``async with`` statement is still active " -"(i.e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " -"containing the ``async with`` statement is also cancelled. The " -"resulting :exc:`asyncio.CancelledError` will interrupt an ``await``, but it " -"will not bubble out of the containing ``async with`` statement." +"this point, if the body of the ``async with`` statement is still active (i." +"e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " +"containing the ``async with`` statement is also cancelled. The resulting :" +"exc:`asyncio.CancelledError` will interrupt an ``await``, but it will not " +"bubble out of the containing ``async with`` statement." msgstr "" #: ../../library/asyncio-task.rst:370 @@ -553,24 +549,23 @@ msgstr "" #: ../../library/asyncio-task.rst:377 msgid "" -"Two base exceptions are treated specially: If any task fails " -"with :exc:`KeyboardInterrupt` or :exc:`SystemExit`, the task group still " -"cancels the remaining tasks and waits for them, but then the " -"initial :exc:`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead " -"of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`." +"Two base exceptions are treated specially: If any task fails with :exc:" +"`KeyboardInterrupt` or :exc:`SystemExit`, the task group still cancels the " +"remaining tasks and waits for them, but then the initial :exc:" +"`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead of :exc:" +"`ExceptionGroup` or :exc:`BaseExceptionGroup`." msgstr "" #: ../../library/asyncio-task.rst:383 msgid "" -"If the body of the ``async with`` statement exits with an exception " -"(so :meth:`~object.__aexit__` is called with an exception set), this is " -"treated the same as if one of the tasks failed: the remaining tasks are " -"cancelled and then waited for, and non-cancellation exceptions are grouped " -"into an exception group and raised. The exception passed " -"into :meth:`~object.__aexit__`, unless it is :exc:`asyncio.CancelledError`, " -"is also included in the exception group. The same special case is made " -"for :exc:`KeyboardInterrupt` and :exc:`SystemExit` as in the previous " -"paragraph." +"If the body of the ``async with`` statement exits with an exception (so :" +"meth:`~object.__aexit__` is called with an exception set), this is treated " +"the same as if one of the tasks failed: the remaining tasks are cancelled " +"and then waited for, and non-cancellation exceptions are grouped into an " +"exception group and raised. The exception passed into :meth:`~object." +"__aexit__`, unless it is :exc:`asyncio.CancelledError`, is also included in " +"the exception group. The same special case is made for :exc:" +"`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph." msgstr "" #: ../../library/asyncio-task.rst:395 @@ -587,16 +582,15 @@ msgstr "" #: ../../library/asyncio-task.rst:403 msgid "" "In the case where a task group is cancelled externally and also must raise " -"an :exc:`ExceptionGroup`, it will call the parent " -"task's :meth:`~asyncio.Task.cancel` method. This ensures that " -"a :exc:`asyncio.CancelledError` will be raised at the next :keyword:`await`, " -"so the cancellation is not lost." +"an :exc:`ExceptionGroup`, it will call the parent task's :meth:`~asyncio." +"Task.cancel` method. This ensures that a :exc:`asyncio.CancelledError` will " +"be raised at the next :keyword:`await`, so the cancellation is not lost." msgstr "" #: ../../library/asyncio-task.rst:409 msgid "" -"Task groups preserve the cancellation count reported " -"by :meth:`asyncio.Task.cancelling`." +"Task groups preserve the cancellation count reported by :meth:`asyncio.Task." +"cancelling`." msgstr "" #: ../../library/asyncio-task.rst:414 @@ -863,12 +857,12 @@ msgstr "" #: ../../library/asyncio-task.rst:618 msgid "" -"When using this factory " -"(via :meth:`loop.set_task_factory(asyncio.eager_task_factory) " -"`), coroutines begin execution synchronously " -"during :class:`Task` construction. Tasks are only scheduled on the event " -"loop if they block. This can be a performance improvement as the overhead of " -"loop scheduling is avoided for coroutines that complete synchronously." +"When using this factory (via :meth:`loop.set_task_factory(asyncio." +"eager_task_factory) `), coroutines begin execution " +"synchronously during :class:`Task` construction. Tasks are only scheduled on " +"the event loop if they block. This can be a performance improvement as the " +"overhead of loop scheduling is avoided for coroutines that complete " +"synchronously." msgstr "" #: ../../library/asyncio-task.rst:624 @@ -896,15 +890,15 @@ msgstr "" #: ../../library/asyncio-task.rst:644 msgid "" "*custom_task_constructor* must be a *callable* with the signature matching " -"the signature of :class:`Task.__init__ `. The callable must return " -"a :class:`asyncio.Task`-compatible object." +"the signature of :class:`Task.__init__ `. The callable must return a :" +"class:`asyncio.Task`-compatible object." msgstr "" #: ../../library/asyncio-task.rst:648 msgid "" "This function returns a *callable* intended to be used as a task factory of " -"an event loop via :meth:`loop.set_task_factory(factory) " -"`)." +"an event loop via :meth:`loop.set_task_factory(factory) `)." msgstr "" #: ../../library/asyncio-task.rst:655 @@ -913,8 +907,8 @@ msgstr "" #: ../../library/asyncio-task.rst:659 msgid "" -"Protect an :ref:`awaitable object ` from " -"being :meth:`cancelled `." +"Protect an :ref:`awaitable object ` from being :meth:" +"`cancelled `." msgstr "" #: ../../library/asyncio-task.rst:662 ../../library/asyncio-task.rst:829 @@ -946,8 +940,8 @@ msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " "``something()``, the cancellation did not happen. Although its caller is " -"still cancelled, so the \"await\" expression still raises " -"a :exc:`CancelledError`." +"still cancelled, so the \"await\" expression still raises a :exc:" +"`CancelledError`." msgstr "" #: ../../library/asyncio-task.rst:679 @@ -1010,8 +1004,8 @@ msgstr "" #: ../../library/asyncio-task.rst:721 msgid "" -"In either case, the context manager can be rescheduled after creation " -"using :meth:`Timeout.reschedule`." +"In either case, the context manager can be rescheduled after creation using :" +"meth:`Timeout.reschedule`." msgstr "" #: ../../library/asyncio-task.rst:726 @@ -1027,16 +1021,16 @@ msgstr "" #: ../../library/asyncio-task.rst:730 msgid "" "If ``long_running_task`` takes more than 10 seconds to complete, the context " -"manager will cancel the current task and handle the " -"resulting :exc:`asyncio.CancelledError` internally, transforming it into " -"a :exc:`TimeoutError` which can be caught and handled." +"manager will cancel the current task and handle the resulting :exc:`asyncio." +"CancelledError` internally, transforming it into a :exc:`TimeoutError` which " +"can be caught and handled." msgstr "" #: ../../library/asyncio-task.rst:737 msgid "" -"The :func:`asyncio.timeout` context manager is what transforms " -"the :exc:`asyncio.CancelledError` into a :exc:`TimeoutError`, which means " -"the :exc:`TimeoutError` can only be caught *outside* of the context manager." +"The :func:`asyncio.timeout` context manager is what transforms the :exc:" +"`asyncio.CancelledError` into a :exc:`TimeoutError`, which means the :exc:" +"`TimeoutError` can only be caught *outside* of the context manager." msgstr "" #: ../../library/asyncio-task.rst:742 @@ -1157,8 +1151,8 @@ msgstr "" #: ../../library/asyncio-task.rst:838 msgid "" -"To avoid the task :meth:`cancellation `, wrap it " -"in :func:`shield`." +"To avoid the task :meth:`cancellation `, wrap it in :func:" +"`shield`." msgstr "" #: ../../library/asyncio-task.rst:841 @@ -1264,8 +1258,8 @@ msgstr "" #: ../../library/asyncio-task.rst:919 msgid "" "The function will return when any future finishes by raising an exception. " -"If no future raises an exception then it is equivalent " -"to :const:`ALL_COMPLETED`." +"If no future raises an exception then it is equivalent to :const:" +"`ALL_COMPLETED`." msgstr "" #: ../../library/asyncio-task.rst:924 @@ -1295,11 +1289,11 @@ msgstr "" #: ../../library/asyncio-task.rst:945 msgid "" -"The object returned by ``as_completed()`` can be iterated as " -"an :term:`asynchronous iterator` or a plain :term:`iterator`. When " -"asynchronous iteration is used, the originally-supplied awaitables are " -"yielded if they are tasks or futures. This makes it easy to correlate " -"previously-scheduled tasks with their results. Example::" +"The object returned by ``as_completed()`` can be iterated as an :term:" +"`asynchronous iterator` or a plain :term:`iterator`. When asynchronous " +"iteration is used, the originally-supplied awaitables are yielded if they " +"are tasks or futures. This makes it easy to correlate previously-scheduled " +"tasks with their results. Example::" msgstr "" #: ../../library/asyncio-task.rst:951 @@ -1530,17 +1524,17 @@ msgstr "" msgid "Return ``True`` if *obj* is a coroutine object." msgstr "" -#: ../../library/asyncio-task.rst:1140 +#: ../../library/asyncio-task.rst:1141 msgid "Task Object" msgstr "Task 物件" -#: ../../library/asyncio-task.rst:1144 +#: ../../library/asyncio-task.rst:1145 msgid "" "A :class:`Future-like ` object that runs a Python :ref:`coroutine " "`. Not thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1147 +#: ../../library/asyncio-task.rst:1148 msgid "" "Tasks are used to run coroutines in event loops. If a coroutine awaits on a " "Future, the Task suspends the execution of the coroutine and waits for the " @@ -1548,21 +1542,21 @@ msgid "" "wrapped coroutine resumes." msgstr "" -#: ../../library/asyncio-task.rst:1153 +#: ../../library/asyncio-task.rst:1154 msgid "" "Event loops use cooperative scheduling: an event loop runs one Task at a " "time. While a Task awaits for the completion of a Future, the event loop " "runs other Tasks, callbacks, or performs IO operations." msgstr "" -#: ../../library/asyncio-task.rst:1158 +#: ../../library/asyncio-task.rst:1159 msgid "" "Use the high-level :func:`asyncio.create_task` function to create Tasks, or " "the low-level :meth:`loop.create_task` or :func:`ensure_future` functions. " "Manual instantiation of Tasks is discouraged." msgstr "" -#: ../../library/asyncio-task.rst:1163 +#: ../../library/asyncio-task.rst:1164 msgid "" "To cancel a running Task use the :meth:`cancel` method. Calling it will " "cause the Task to throw a :exc:`CancelledError` exception into the wrapped " @@ -1570,28 +1564,28 @@ msgid "" "cancellation, the Future object will be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1168 +#: ../../library/asyncio-task.rst:1169 msgid "" ":meth:`cancelled` can be used to check if the Task was cancelled. The method " -"returns ``True`` if the wrapped coroutine did not suppress " -"the :exc:`CancelledError` exception and was actually cancelled." +"returns ``True`` if the wrapped coroutine did not suppress the :exc:" +"`CancelledError` exception and was actually cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1173 +#: ../../library/asyncio-task.rst:1174 msgid "" -":class:`asyncio.Task` inherits from :class:`Future` all of its APIs " -"except :meth:`Future.set_result` and :meth:`Future.set_exception`." +":class:`asyncio.Task` inherits from :class:`Future` all of its APIs except :" +"meth:`Future.set_result` and :meth:`Future.set_exception`." msgstr "" -#: ../../library/asyncio-task.rst:1177 +#: ../../library/asyncio-task.rst:1178 msgid "" -"An optional keyword-only *context* argument allows specifying a " -"custom :class:`contextvars.Context` for the *coro* to run in. If no " -"*context* is provided, the Task copies the current context and later runs " -"its coroutine in the copied context." +"An optional keyword-only *context* argument allows specifying a custom :" +"class:`contextvars.Context` for the *coro* to run in. If no *context* is " +"provided, the Task copies the current context and later runs its coroutine " +"in the copied context." msgstr "" -#: ../../library/asyncio-task.rst:1182 +#: ../../library/asyncio-task.rst:1183 msgid "" "An optional keyword-only *eager_start* argument allows eagerly starting the " "execution of the :class:`asyncio.Task` at task creation time. If set to " @@ -1601,96 +1595,96 @@ msgid "" "eagerly and will skip scheduling to the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1189 +#: ../../library/asyncio-task.rst:1190 msgid "Added support for the :mod:`contextvars` module." msgstr "新增對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-task.rst:1195 +#: ../../library/asyncio-task.rst:1196 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" -#: ../../library/asyncio-task.rst:1202 +#: ../../library/asyncio-task.rst:1203 msgid "Added the *eager_start* parameter." msgstr "新增 *eager_start* 參數。" -#: ../../library/asyncio-task.rst:1207 +#: ../../library/asyncio-task.rst:1208 msgid "Return ``True`` if the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1209 +#: ../../library/asyncio-task.rst:1210 msgid "" "A Task is *done* when the wrapped coroutine either returned a value, raised " "an exception, or the Task was cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1214 +#: ../../library/asyncio-task.rst:1215 msgid "Return the result of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1216 +#: ../../library/asyncio-task.rst:1217 msgid "" "If the Task is *done*, the result of the wrapped coroutine is returned (or " "if the coroutine raised an exception, that exception is re-raised.)" msgstr "" -#: ../../library/asyncio-task.rst:1220 ../../library/asyncio-task.rst:1234 +#: ../../library/asyncio-task.rst:1221 ../../library/asyncio-task.rst:1235 msgid "" "If the Task has been *cancelled*, this method raises a :exc:`CancelledError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1223 +#: ../../library/asyncio-task.rst:1224 msgid "" -"If the Task's result isn't yet available, this method raises " -"an :exc:`InvalidStateError` exception." +"If the Task's result isn't yet available, this method raises an :exc:" +"`InvalidStateError` exception." msgstr "" -#: ../../library/asyncio-task.rst:1228 +#: ../../library/asyncio-task.rst:1229 msgid "Return the exception of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1230 +#: ../../library/asyncio-task.rst:1231 msgid "" "If the wrapped coroutine raised an exception that exception is returned. If " "the wrapped coroutine returned normally this method returns ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1237 +#: ../../library/asyncio-task.rst:1238 msgid "" "If the Task isn't *done* yet, this method raises an :exc:`InvalidStateError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1242 +#: ../../library/asyncio-task.rst:1243 msgid "Add a callback to be run when the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1244 ../../library/asyncio-task.rst:1253 +#: ../../library/asyncio-task.rst:1245 ../../library/asyncio-task.rst:1254 msgid "This method should only be used in low-level callback-based code." msgstr "" -#: ../../library/asyncio-task.rst:1246 +#: ../../library/asyncio-task.rst:1247 msgid "" "See the documentation of :meth:`Future.add_done_callback` for more details." msgstr "" -#: ../../library/asyncio-task.rst:1251 +#: ../../library/asyncio-task.rst:1252 msgid "Remove *callback* from the callbacks list." msgstr "" -#: ../../library/asyncio-task.rst:1255 +#: ../../library/asyncio-task.rst:1256 msgid "" "See the documentation of :meth:`Future.remove_done_callback` for more " "details." msgstr "" -#: ../../library/asyncio-task.rst:1260 +#: ../../library/asyncio-task.rst:1261 msgid "Return the list of stack frames for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1262 +#: ../../library/asyncio-task.rst:1263 msgid "" "If the wrapped coroutine is not done, this returns the stack where it is " "suspended. If the coroutine has completed successfully or was cancelled, " @@ -1698,15 +1692,15 @@ msgid "" "this returns the list of traceback frames." msgstr "" -#: ../../library/asyncio-task.rst:1268 +#: ../../library/asyncio-task.rst:1269 msgid "The frames are always ordered from oldest to newest." msgstr "" -#: ../../library/asyncio-task.rst:1270 +#: ../../library/asyncio-task.rst:1271 msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" -#: ../../library/asyncio-task.rst:1272 +#: ../../library/asyncio-task.rst:1273 msgid "" "The optional *limit* argument sets the maximum number of frames to return; " "by default all available frames are returned. The ordering of the returned " @@ -1715,113 +1709,113 @@ msgid "" "are returned. (This matches the behavior of the traceback module.)" msgstr "" -#: ../../library/asyncio-task.rst:1281 +#: ../../library/asyncio-task.rst:1282 msgid "Print the stack or traceback for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1283 +#: ../../library/asyncio-task.rst:1284 msgid "" "This produces output similar to that of the traceback module for the frames " "retrieved by :meth:`get_stack`." msgstr "" -#: ../../library/asyncio-task.rst:1286 +#: ../../library/asyncio-task.rst:1287 msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "" -#: ../../library/asyncio-task.rst:1288 +#: ../../library/asyncio-task.rst:1289 msgid "" "The *file* argument is an I/O stream to which the output is written; by " "default output is written to :data:`sys.stdout`." msgstr "" -#: ../../library/asyncio-task.rst:1293 +#: ../../library/asyncio-task.rst:1294 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:1297 +#: ../../library/asyncio-task.rst:1298 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" -#: ../../library/asyncio-task.rst:1304 +#: ../../library/asyncio-task.rst:1305 msgid "Newly added eager task execution means result may be ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1308 +#: ../../library/asyncio-task.rst:1309 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" -#: ../../library/asyncio-task.rst:1315 +#: ../../library/asyncio-task.rst:1316 msgid "Return the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1317 +#: ../../library/asyncio-task.rst:1318 msgid "" "If no name has been explicitly assigned to the Task, the default asyncio " "Task implementation generates a default name during instantiation." msgstr "" -#: ../../library/asyncio-task.rst:1325 +#: ../../library/asyncio-task.rst:1326 msgid "Set the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1327 +#: ../../library/asyncio-task.rst:1328 msgid "" "The *value* argument can be any object, which is then converted to a string." msgstr "" -#: ../../library/asyncio-task.rst:1330 +#: ../../library/asyncio-task.rst:1331 msgid "" -"In the default Task implementation, the name will be visible in " -"the :func:`repr` output of a task object." +"In the default Task implementation, the name will be visible in the :func:" +"`repr` output of a task object." msgstr "" -#: ../../library/asyncio-task.rst:1337 +#: ../../library/asyncio-task.rst:1338 msgid "Request the Task to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1339 +#: ../../library/asyncio-task.rst:1340 msgid "" "If the Task is already *done* or *cancelled*, return ``False``, otherwise, " "return ``True``." msgstr "" -#: ../../library/asyncio-task.rst:1342 +#: ../../library/asyncio-task.rst:1343 msgid "" "The method arranges for a :exc:`CancelledError` exception to be thrown into " "the wrapped coroutine on the next cycle of the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1345 +#: ../../library/asyncio-task.rst:1346 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " -"CancelledError`` ... :keyword:`finally` block. Therefore, " -"unlike :meth:`Future.cancel`, :meth:`Task.cancel` does not guarantee that " -"the Task will be cancelled, although suppressing cancellation completely is " -"not common and is actively discouraged. Should the coroutine nevertheless " -"decide to suppress the cancellation, it needs to call :meth:`Task.uncancel` " -"in addition to catching the exception." +"CancelledError`` ... :keyword:`finally` block. Therefore, unlike :meth:" +"`Future.cancel`, :meth:`Task.cancel` does not guarantee that the Task will " +"be cancelled, although suppressing cancellation completely is not common and " +"is actively discouraged. Should the coroutine nevertheless decide to " +"suppress the cancellation, it needs to call :meth:`Task.uncancel` in " +"addition to catching the exception." msgstr "" -#: ../../library/asyncio-task.rst:1355 +#: ../../library/asyncio-task.rst:1356 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-task.rst:1358 +#: ../../library/asyncio-task.rst:1359 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" -#: ../../library/asyncio-task.rst:1363 +#: ../../library/asyncio-task.rst:1364 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" msgstr "" -#: ../../library/asyncio-task.rst:1366 +#: ../../library/asyncio-task.rst:1367 msgid "" "async def cancel_me():\n" " print('cancel_me(): before sleep')\n" @@ -1858,41 +1852,41 @@ msgid "" "# main(): cancel_me is cancelled now" msgstr "" -#: ../../library/asyncio-task.rst:1402 +#: ../../library/asyncio-task.rst:1403 msgid "Return ``True`` if the Task is *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:1404 +#: ../../library/asyncio-task.rst:1405 msgid "" -"The Task is *cancelled* when the cancellation was requested " -"with :meth:`cancel` and the wrapped coroutine propagated " -"the :exc:`CancelledError` exception thrown into it." +"The Task is *cancelled* when the cancellation was requested with :meth:" +"`cancel` and the wrapped coroutine propagated the :exc:`CancelledError` " +"exception thrown into it." msgstr "" -#: ../../library/asyncio-task.rst:1410 +#: ../../library/asyncio-task.rst:1411 msgid "Decrement the count of cancellation requests to this Task." msgstr "" -#: ../../library/asyncio-task.rst:1412 +#: ../../library/asyncio-task.rst:1413 msgid "Returns the remaining number of cancellation requests." msgstr "" -#: ../../library/asyncio-task.rst:1414 +#: ../../library/asyncio-task.rst:1415 msgid "" -"Note that once execution of a cancelled task completed, further calls " -"to :meth:`uncancel` are ineffective." +"Note that once execution of a cancelled task completed, further calls to :" +"meth:`uncancel` are ineffective." msgstr "" -#: ../../library/asyncio-task.rst:1419 +#: ../../library/asyncio-task.rst:1420 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. In particular, if a Task gets successfully uncancelled, this " -"allows for elements of structured concurrency like :ref:`taskgroups` " -"and :func:`asyncio.timeout` to continue running, isolating cancellation to " -"the respective structured block. For example::" +"allows for elements of structured concurrency like :ref:`taskgroups` and :" +"func:`asyncio.timeout` to continue running, isolating cancellation to the " +"respective structured block. For example::" msgstr "" -#: ../../library/asyncio-task.rst:1426 +#: ../../library/asyncio-task.rst:1427 msgid "" "async def make_request_with_timeout():\n" " try:\n" @@ -1906,42 +1900,42 @@ msgid "" " await unrelated_code()" msgstr "" -#: ../../library/asyncio-task.rst:1437 +#: ../../library/asyncio-task.rst:1438 msgid "" "While the block with ``make_request()`` and ``make_another_request()`` might " "get cancelled due to the timeout, ``unrelated_code()`` should continue " -"running even in case of the timeout. This is implemented " -"with :meth:`uncancel`. :class:`TaskGroup` context managers " -"use :func:`uncancel` in a similar fashion." +"running even in case of the timeout. This is implemented with :meth:" +"`uncancel`. :class:`TaskGroup` context managers use :func:`uncancel` in a " +"similar fashion." msgstr "" -#: ../../library/asyncio-task.rst:1443 +#: ../../library/asyncio-task.rst:1444 msgid "" -"If end-user code is, for some reason, suppressing cancellation by " -"catching :exc:`CancelledError`, it needs to call this method to remove the " +"If end-user code is, for some reason, suppressing cancellation by catching :" +"exc:`CancelledError`, it needs to call this method to remove the " "cancellation state." msgstr "" -#: ../../library/asyncio-task.rst:1447 +#: ../../library/asyncio-task.rst:1448 msgid "" "When this method decrements the cancellation count to zero, the method " -"checks if a previous :meth:`cancel` call had arranged " -"for :exc:`CancelledError` to be thrown into the task. If it hasn't been " -"thrown yet, that arrangement will be rescinded (by resetting the internal " +"checks if a previous :meth:`cancel` call had arranged for :exc:" +"`CancelledError` to be thrown into the task. If it hasn't been thrown yet, " +"that arrangement will be rescinded (by resetting the internal " "``_must_cancel`` flag)." msgstr "" -#: ../../library/asyncio-task.rst:1453 +#: ../../library/asyncio-task.rst:1454 msgid "Changed to rescind pending cancellation requests upon reaching zero." msgstr "" -#: ../../library/asyncio-task.rst:1458 +#: ../../library/asyncio-task.rst:1459 msgid "" "Return the number of pending cancellation requests to this Task, i.e., the " "number of calls to :meth:`cancel` less the number of :meth:`uncancel` calls." msgstr "" -#: ../../library/asyncio-task.rst:1462 +#: ../../library/asyncio-task.rst:1463 msgid "" "Note that if this number is greater than zero but the Task is still " "executing, :meth:`cancelled` will still return ``False``. This is because " @@ -1950,7 +1944,7 @@ msgid "" "to zero." msgstr "" -#: ../../library/asyncio-task.rst:1468 +#: ../../library/asyncio-task.rst:1469 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. See :meth:`uncancel` for more details." diff --git a/library/asyncio.po b/library/asyncio.po index 1d0919783b..ffff473328 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -10,7 +10,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-08-10 00:19+0000\n" "PO-Revision-Date: 2025-07-06 17:13+0800\n" "Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,15 +21,15 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio.rst:91 +#: ../../library/asyncio.rst:96 msgid "High-level APIs" msgstr "高階 API" -#: ../../library/asyncio.rst:103 +#: ../../library/asyncio.rst:108 msgid "Low-level APIs" msgstr "低階 API" -#: ../../library/asyncio.rst:114 +#: ../../library/asyncio.rst:119 msgid "Guides and Tutorials" msgstr "指南與教學" @@ -85,53 +85,61 @@ msgid "" msgstr "" "asyncio 往往是個建構 IO 密集型與高階層\\ **結構化**\\ 網路程式碼的完美選擇。" -#: ../../library/asyncio.rst:32 +#: ../../library/asyncio.rst:34 +msgid ":ref:`a-conceptual-overview-of-asyncio`" +msgstr "" + +#: ../../library/asyncio.rst:35 +msgid "Explanation of the fundamentals of asyncio." +msgstr "" + +#: ../../library/asyncio.rst:37 msgid "asyncio provides a set of **high-level** APIs to:" msgstr "asyncio 提供了一系列\\ **高階** API:" -#: ../../library/asyncio.rst:34 +#: ../../library/asyncio.rst:39 msgid "" ":ref:`run Python coroutines ` concurrently and have full control " "over their execution;" msgstr "" "並行地\\ :ref:`運行 Python 協程 (coroutine) ` 並擁有完整控制權;" -#: ../../library/asyncio.rst:37 +#: ../../library/asyncio.rst:42 msgid "perform :ref:`network IO and IPC `;" msgstr "執行\\ :ref:`網路 IO 與 IPC `;" -#: ../../library/asyncio.rst:39 +#: ../../library/asyncio.rst:44 msgid "control :ref:`subprocesses `;" msgstr "控制\\ :ref:`子行程 (subprocess) `;" -#: ../../library/asyncio.rst:41 +#: ../../library/asyncio.rst:46 msgid "distribute tasks via :ref:`queues `;" msgstr "透過\\ :ref:`佇列 (queue) ` 分配任務;" -#: ../../library/asyncio.rst:43 +#: ../../library/asyncio.rst:48 msgid ":ref:`synchronize ` concurrent code;" msgstr ":ref:`同步 `\\ 並行程式碼;" -#: ../../library/asyncio.rst:45 +#: ../../library/asyncio.rst:50 msgid "" "Additionally, there are **low-level** APIs for *library and framework " "developers* to:" msgstr "" "此外,還有一些給\\ *函式庫與框架 (framework) 開發者*\\ 的\\ **低階** API:" -#: ../../library/asyncio.rst:48 +#: ../../library/asyncio.rst:53 msgid "" "create and manage :ref:`event loops `, which provide " -"asynchronous APIs for :ref:`networking `, " -"running :ref:`subprocesses `, handling :ref:`OS " -"signals `, etc;" +"asynchronous APIs for :ref:`networking `, running :ref:" +"`subprocesses `, handling :ref:`OS signals " +"`, etc;" msgstr "" "建立與管理 :ref:`event loops(事件迴圈) `,它提供了能被" "用於\\ :ref:`網路 `、執行\\ :ref:`子行程 " "`、處理\\ :ref:`作業系統訊號 " "`\\ 等任務的非同步 API;" -#: ../../library/asyncio.rst:53 +#: ../../library/asyncio.rst:58 msgid "" "implement efficient protocols using :ref:`transports `;" @@ -139,7 +147,7 @@ msgstr "" "使用 :ref:`transports(asyncio 底層傳輸相關類別) `\\ 來實作高效能協定;" -#: ../../library/asyncio.rst:56 +#: ../../library/asyncio.rst:61 msgid "" ":ref:`bridge ` callback-based libraries and code with async/" "await syntax." @@ -159,18 +167,18 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/asyncio.rst:64 +#: ../../library/asyncio.rst:69 msgid "asyncio REPL" msgstr "asyncio REPL" -#: ../../library/asyncio.rst:65 +#: ../../library/asyncio.rst:70 msgid "" -"You can experiment with an ``asyncio`` concurrent context in " -"the :term:`REPL`:" +"You can experiment with an ``asyncio`` concurrent context in the :term:" +"`REPL`:" msgstr "" "你能在 :term:`REPL` 中對一個 ``asyncio`` 的並行情境 (context) 進行實驗:" -#: ../../library/asyncio.rst:67 +#: ../../library/asyncio.rst:72 msgid "" "$ python -m asyncio\n" "asyncio REPL ...\n" @@ -190,28 +198,28 @@ msgstr "" ">>> await asyncio.sleep(10, result='hello')\n" "'hello'" -#: ../../library/asyncio.rst:77 +#: ../../library/asyncio.rst:82 msgid "" "Raises an :ref:`auditing event ` ``cpython.run_stdin`` with no " "arguments." msgstr "產生一個 :ref:`稽核事件 ` ``cpython.run_stdin`` 且沒有引數。" -#: ../../library/asyncio.rst:79 +#: ../../library/asyncio.rst:84 msgid "(also 3.11.10, 3.10.15, 3.9.20, and 3.8.20) Emits audit events." msgstr "(也包括 3.11.10、3.10.15、3.9.20 及 3.8.20)發出稽核事件。" -#: ../../library/asyncio.rst:82 +#: ../../library/asyncio.rst:87 msgid "" "Uses PyREPL if possible, in which case :envvar:`PYTHONSTARTUP` is also " "executed. Emits audit events." msgstr "" -"可能的話使用 PyREPL,在這種情況下 :envvar:`PYTHONSTARTUP` 也會被執行。發出稽核" -"事件。" +"可能的話使用 PyREPL,在這種情況下 :envvar:`PYTHONSTARTUP` 也會被執行。發出稽" +"核事件。" -#: ../../library/asyncio.rst:90 +#: ../../library/asyncio.rst:95 msgid "Reference" msgstr "參閱" -#: ../../library/asyncio.rst:123 +#: ../../library/asyncio.rst:128 msgid "The source code for asyncio can be found in :source:`Lib/asyncio/`." msgstr "asyncio 的原始碼可以在 :source:`Lib/asyncio/` 中找到。" diff --git a/library/time.po b/library/time.po index f4ff4dcee8..d1f6d8d81b 100644 --- a/library/time.po +++ b/library/time.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-10 00:16+0000\n" +"POT-Creation-Date: 2025-08-10 00:19+0000\n" "PO-Revision-Date: 2024-11-20 15:25+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -532,8 +532,8 @@ msgid "" "only the difference between the results of two calls is valid." msgstr "" "回傳性能計數器的值(以帶有小數的秒數表示),即具有最高可用解析度來測量短時間" -"間隔的時鐘。它包括睡眠時經過的時間,且時鐘對於所有行程都會是相同。回傳值的參考點沒有定" -"義,因此只有兩次呼叫結果之間的差異才是有效的。" +"間隔的時鐘。它包括睡眠時經過的時間,且時鐘對於所有行程都會是相同。回傳值的參" +"考點沒有定義,因此只有兩次呼叫結果之間的差異才是有效的。" #: ../../library/time.rst:336 msgid "" @@ -1597,9 +1597,10 @@ msgid "High-resolution per-process timer from the CPU." msgstr "來自 CPU 的高解析度每個行程的計時器。" #: ../../library/time.rst:938 +#, fuzzy msgid "" "`International Atomic Time `_" +"division/how-utcnist-related-coordinated-universal-time-utc-international>`_" msgstr "" "`國際原子時間 `_" From 79d4b220193561b0c5b0c2abe1b43624e48d93aa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 12 Aug 2025 00:18:24 +0000 Subject: [PATCH 11/13] sync with cpython c1e1c880 --- c-api/hash.po | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c-api/hash.po b/c-api/hash.po index dcb8889a1b..d3322bf338 100644 --- a/c-api/hash.po +++ b/c-api/hash.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-08-12 00:17+0000\n" "PO-Revision-Date: 2024-04-30 00:20+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -62,6 +62,10 @@ msgstr "用於複數虛數部分的乘數。" msgid "Hash function definition used by :c:func:`PyHash_GetFuncDef`." msgstr ":c:func:`PyHash_GetFuncDef` 所使用的雜湊函式定義。" +#: ../../c-api/hash.rst:56 +msgid "Hash function." +msgstr "" + #: ../../c-api/hash.rst:60 msgid "Hash function name (UTF-8 encoded string)." msgstr "雜湊函式名稱(UTF-8 編碼字串)。" From 85e3e176dcb075d30fedc5d5ad7acc2ddd847c80 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Aug 2025 00:17:36 +0000 Subject: [PATCH 12/13] sync with cpython 30194914 --- howto/enum.po | 223 ++++++++++++------------- library/enum.po | 435 ++++++++++++++++++++++++++---------------------- 2 files changed, 343 insertions(+), 315 deletions(-) diff --git a/howto/enum.po b/howto/enum.po index 92490f02e6..31233ba902 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-08-13 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -315,15 +315,15 @@ msgstr "" #: ../../howto/enum.rst:154 msgid "" ">>> chores_for_ethan = {\n" -"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | " -"Weekday.FRIDAY,\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." +"FRIDAY,\n" "... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" msgstr "" ">>> chores_for_ethan = {\n" -"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | " -"Weekday.FRIDAY,\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." +"FRIDAY,\n" "... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" @@ -386,8 +386,8 @@ msgstr "" #: ../../howto/enum.rst:191 msgid "" -"Sometimes it's useful to access members in enumerations programmatically " -"(i.e. situations where ``Color.RED`` won't do because the exact color is not " +"Sometimes it's useful to access members in enumerations programmatically (i." +"e. situations where ``Color.RED`` won't do because the exact color is not " "known at program-writing time). ``Enum`` allows such access::" msgstr "" @@ -627,16 +627,16 @@ msgid "" ">>> list(Shape)\n" "[, , ]\n" ">>> list(Weekday)\n" -"[, , , " -", , , " -"]" +"[, , , , , , ]" msgstr "" ">>> list(Shape)\n" "[, , ]\n" ">>> list(Weekday)\n" -"[, , , " -", , , " -"]" +"[, , , , , , ]" #: ../../howto/enum.rst:319 msgid "" @@ -839,25 +839,24 @@ msgid "" "The rules for what is allowed are as follows: names that start and end with " "a single underscore are reserved by enum and cannot be used; all other " "attributes defined within an enumeration will become members of this " -"enumeration, with the exception of special methods " -"(:meth:`~object.__str__`, :meth:`~object.__add__`, etc.), descriptors " -"(methods are also descriptors), and variable names listed " -"in :attr:`~Enum._ignore_`." +"enumeration, with the exception of special methods (:meth:`~object." +"__str__`, :meth:`~object.__add__`, etc.), descriptors (methods are also " +"descriptors), and variable names listed in :attr:`~Enum._ignore_`." msgstr "" #: ../../howto/enum.rst:432 msgid "" -"Note: if your enumeration defines :meth:`~object.__new__` and/" -"or :meth:`~object.__init__`, any value(s) given to the enum member will be " -"passed into those methods. See `Planet`_ for an example." +"Note: if your enumeration defines :meth:`~object.__new__` and/or :meth:" +"`~object.__init__`, any value(s) given to the enum member will be passed " +"into those methods. See `Planet`_ for an example." msgstr "" #: ../../howto/enum.rst:438 msgid "" "The :meth:`~object.__new__` method, if defined, is used during creation of " "the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " -"which is used after class creation for lookup of existing members. " -"See :ref:`new-vs-init` for more details." +"which is used after class creation for lookup of existing members. See :ref:" +"`new-vs-init` for more details." msgstr "" #: ../../howto/enum.rst:445 @@ -939,8 +938,8 @@ msgstr "" #: ../../howto/enum.rst:486 msgid "" -"When inheriting from a :class:`~dataclasses.dataclass`, " -"the :meth:`~Enum.__repr__` omits the inherited class' name. For example::" +"When inheriting from a :class:`~dataclasses.dataclass`, the :meth:`~Enum." +"__repr__` omits the inherited class' name. For example::" msgstr "" #: ../../howto/enum.rst:489 @@ -1041,10 +1040,9 @@ msgstr "" #: ../../howto/enum.rst:547 msgid "" -"It is possible to modify how enum members are pickled/unpickled by " -"defining :meth:`~object.__reduce_ex__` in the enumeration class. The " -"default method is by-value, but enums with complicated values may want to " -"use by-name::" +"It is possible to modify how enum members are pickled/unpickled by defining :" +"meth:`~object.__reduce_ex__` in the enumeration class. The default method " +"is by-value, but enums with complicated values may want to use by-name::" msgstr "" #: ../../howto/enum.rst:551 @@ -1153,10 +1151,10 @@ msgstr "" #: ../../howto/enum.rst:611 msgid "" -"The new pickle protocol 4 also, in some circumstances, relies " -"on :attr:`~type.__qualname__` being set to the location where pickle will be " -"able to find the class. For example, if the class was made available in " -"class SomeData in the global scope::" +"The new pickle protocol 4 also, in some circumstances, relies on :attr:" +"`~type.__qualname__` being set to the location where pickle will be able to " +"find the class. For example, if the class was made available in class " +"SomeData in the global scope::" msgstr "" #: ../../howto/enum.rst:616 @@ -1259,10 +1257,10 @@ msgstr "IntEnum" #: ../../howto/enum.rst:667 msgid "" -"The first variation of :class:`Enum` that is provided is also a subclass " -"of :class:`int`. Members of an :class:`IntEnum` can be compared to " -"integers; by extension, integer enumerations of different types can also be " -"compared to each other::" +"The first variation of :class:`Enum` that is provided is also a subclass of :" +"class:`int`. Members of an :class:`IntEnum` can be compared to integers; by " +"extension, integer enumerations of different types can also be compared to " +"each other::" msgstr "" #: ../../howto/enum.rst:672 @@ -1371,9 +1369,9 @@ msgid "" "The next variation of :class:`Enum` provided, :class:`IntFlag`, is also " "based on :class:`int`. The difference being :class:`IntFlag` members can be " "combined using the bitwise operators (&, \\|, ^, ~) and the result is still " -"an :class:`IntFlag` member, if possible. " -"Like :class:`IntEnum`, :class:`IntFlag` members are also integers and can be " -"used wherever an :class:`int` is used." +"an :class:`IntFlag` member, if possible. Like :class:`IntEnum`, :class:" +"`IntFlag` members are also integers and can be used wherever an :class:`int` " +"is used." msgstr "" #: ../../howto/enum.rst:733 @@ -1463,8 +1461,8 @@ msgstr "" #: ../../howto/enum.rst:781 msgid "" "Another important difference between :class:`IntFlag` and :class:`Enum` is " -"that if no flags are set (the value is 0), its boolean evaluation " -"is :data:`False`::" +"that if no flags are set (the value is 0), its boolean evaluation is :data:" +"`False`::" msgstr "" #: ../../howto/enum.rst:784 @@ -1532,10 +1530,10 @@ msgstr "Flag" #: ../../howto/enum.rst:817 msgid "" "The last variation is :class:`Flag`. Like :class:`IntFlag`, :class:`Flag` " -"members can be combined using the bitwise operators (&, \\|, ^, ~). " -"Unlike :class:`IntFlag`, they cannot be combined with, nor compared against, " -"any other :class:`Flag` enumeration, nor :class:`int`. While it is possible " -"to specify the values directly it is recommended to use :class:`auto` as the " +"members can be combined using the bitwise operators (&, \\|, ^, ~). Unlike :" +"class:`IntFlag`, they cannot be combined with, nor compared against, any " +"other :class:`Flag` enumeration, nor :class:`int`. While it is possible to " +"specify the values directly it is recommended to use :class:`auto` as the " "value and let :class:`Flag` select an appropriate value." msgstr "" @@ -1644,10 +1642,10 @@ msgid "" "For the majority of new code, :class:`Enum` and :class:`Flag` are strongly " "recommended, since :class:`IntEnum` and :class:`IntFlag` break some semantic " "promises of an enumeration (by being comparable to integers, and thus by " -"transitivity to other unrelated enumerations). :class:`IntEnum` " -"and :class:`IntFlag` should be used only in cases where :class:`Enum` " -"and :class:`Flag` will not do; for example, when integer constants are " -"replaced with enumerations, or for interoperability with other systems." +"transitivity to other unrelated enumerations). :class:`IntEnum` and :class:" +"`IntFlag` should be used only in cases where :class:`Enum` and :class:`Flag` " +"will not do; for example, when integer constants are replaced with " +"enumerations, or for interoperability with other systems." msgstr "" #: ../../howto/enum.rst:886 @@ -1671,8 +1669,8 @@ msgstr "" #: ../../howto/enum.rst:894 msgid "" "This demonstrates how similar derived enumerations can be defined; for " -"example a :class:`!FloatEnum` that mixes in :class:`float` instead " -"of :class:`int`." +"example a :class:`!FloatEnum` that mixes in :class:`float` instead of :class:" +"`int`." msgstr "" #: ../../howto/enum.rst:897 @@ -1681,24 +1679,24 @@ msgstr "一些規則:" #: ../../howto/enum.rst:899 msgid "" -"When subclassing :class:`Enum`, mix-in types must appear before " -"the :class:`Enum` class itself in the sequence of bases, as in " -"the :class:`IntEnum` example above." +"When subclassing :class:`Enum`, mix-in types must appear before the :class:" +"`Enum` class itself in the sequence of bases, as in the :class:`IntEnum` " +"example above." msgstr "" #: ../../howto/enum.rst:902 msgid "" -"Mix-in types must be subclassable. For example, :class:`bool` " -"and :class:`range` are not subclassable and will throw an error during Enum " -"creation if used as the mix-in type." +"Mix-in types must be subclassable. For example, :class:`bool` and :class:" +"`range` are not subclassable and will throw an error during Enum creation if " +"used as the mix-in type." msgstr "" #: ../../howto/enum.rst:905 msgid "" "While :class:`Enum` can have members of any type, once you mix in an " -"additional type, all the members must have values of that type, " -"e.g. :class:`int` above. This restriction does not apply to mix-ins which " -"only add methods and don't specify another type." +"additional type, all the members must have values of that type, e.g. :class:" +"`int` above. This restriction does not apply to mix-ins which only add " +"methods and don't specify another type." msgstr "" #: ../../howto/enum.rst:909 @@ -1710,30 +1708,30 @@ msgstr "" #: ../../howto/enum.rst:912 msgid "" -"A ``data type`` is a mixin that defines :meth:`~object.__new__`, or " -"a :class:`~dataclasses.dataclass`" +"A ``data type`` is a mixin that defines :meth:`~object.__new__`, or a :class:" +"`~dataclasses.dataclass`" msgstr "" #: ../../howto/enum.rst:914 msgid "" -"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` " -"class's :meth:`~object.__str__` and :meth:`~object.__repr__` respectively; " -"other codes (such as ``%i`` or ``%h`` for IntEnum) treat the enum member as " -"its mixed-in type." +"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` class's :meth:" +"`~object.__str__` and :meth:`~object.__repr__` respectively; other codes " +"(such as ``%i`` or ``%h`` for IntEnum) treat the enum member as its mixed-in " +"type." msgstr "" #: ../../howto/enum.rst:917 msgid "" -":ref:`Formatted string literals `, :meth:`str.format`, " -"and :func:`format` will use the enum's :meth:`~object.__str__` method." +":ref:`Formatted string literals `, :meth:`str.format`, and :func:" +"`format` will use the enum's :meth:`~object.__str__` method." msgstr "" #: ../../howto/enum.rst:922 msgid "" "Because :class:`IntEnum`, :class:`IntFlag`, and :class:`StrEnum` are " -"designed to be drop-in replacements for existing constants, " -"their :meth:`~object.__str__` method has been reset to their data " -"types' :meth:`~object.__str__` method." +"designed to be drop-in replacements for existing constants, their :meth:" +"`~object.__str__` method has been reset to their data types' :meth:`~object." +"__str__` method." msgstr "" #: ../../howto/enum.rst:930 @@ -1744,8 +1742,8 @@ msgstr "" msgid "" ":meth:`~object.__new__` must be used whenever you want to customize the " "actual value of the :class:`Enum` member. Any other modifications may go in " -"either :meth:`~object.__new__` or :meth:`~object.__init__`, " -"with :meth:`~object.__init__` being preferred." +"either :meth:`~object.__new__` or :meth:`~object.__init__`, with :meth:" +"`~object.__init__` being preferred." msgstr "" #: ../../howto/enum.rst:936 @@ -1802,9 +1800,9 @@ msgstr "" #: ../../howto/enum.rst:976 msgid "" ":meth:`~object.__new__`, if specified, must create and return the enum " -"members; it is also a very good idea to set the " -"member's :attr:`~Enum._value_` appropriately. Once all the members are " -"created it is no longer used." +"members; it is also a very good idea to set the member's :attr:`~Enum." +"_value_` appropriately. Once all the members are created it is no longer " +"used." msgstr "" #: ../../howto/enum.rst:982 @@ -1827,9 +1825,9 @@ msgstr "" #: ../../howto/enum.rst:988 msgid "" -":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or " -"a :class:`str`, that will not be transformed into members, and will be " -"removed from the final class" +":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" +"class:`str`, that will not be transformed into members, and will be removed " +"from the final class" msgstr "" #: ../../howto/enum.rst:991 @@ -1840,13 +1838,13 @@ msgstr "" #: ../../howto/enum.rst:993 msgid "" -":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " +":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr "" #: ../../howto/enum.rst:995 msgid "" -":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " +":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " "existing member. See `MultiValueEnum`_ for an example." msgstr "" @@ -1973,11 +1971,11 @@ msgstr "" #: ../../howto/enum.rst:1074 msgid "" -"Enum classes that are mixed with non-:class:`Enum` types (such " -"as :class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in " -"type's rules; otherwise, all members evaluate as :data:`True`. To make your " -"own enum's boolean evaluation depend on the member's value add the following " -"to your class::" +"Enum classes that are mixed with non-:class:`Enum` types (such as :class:" +"`int`, :class:`str`, etc.) are evaluated according to the mixed-in type's " +"rules; otherwise, all members evaluate as :data:`True`. To make your own " +"enum's boolean evaluation depend on the member's value add the following to " +"your class::" msgstr "" #: ../../howto/enum.rst:1080 @@ -2230,8 +2228,8 @@ msgstr "" #: ../../howto/enum.rst:1202 msgid "" "The default for Flag is ``STRICT``, the default for ``IntFlag`` is " -"``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see " -"``ssl.Options`` for an example of when ``KEEP`` is needed)." +"``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see ``ssl." +"Options`` for an example of when ``KEEP`` is needed)." msgstr "" #: ../../howto/enum.rst:1210 @@ -2240,8 +2238,8 @@ msgstr "Enums 和 Flags 有何不同?" #: ../../howto/enum.rst:1212 msgid "" -"Enums have a custom metaclass that affects many aspects of both " -"derived :class:`Enum` classes and their instances (members)." +"Enums have a custom metaclass that affects many aspects of both derived :" +"class:`Enum` classes and their instances (members)." msgstr "" #: ../../howto/enum.rst:1217 @@ -2250,14 +2248,14 @@ msgstr "Enum 類別" #: ../../howto/enum.rst:1219 msgid "" -"The :class:`EnumType` metaclass is responsible for providing " -"the :meth:`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " +"The :class:`EnumType` metaclass is responsible for providing the :meth:" +"`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " "and other methods that allow one to do things with an :class:`Enum` class " "that fail on a typical class, such as ``list(Color)`` or ``some_enum_var in " "Color``. :class:`EnumType` is responsible for ensuring that various other " -"methods on the final :class:`Enum` class are correct (such " -"as :meth:`~object.__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` " -"and :meth:`~object.__repr__`)." +"methods on the final :class:`Enum` class are correct (such as :meth:`~object." +"__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` and :meth:" +"`~object.__repr__`)." msgstr "" #: ../../howto/enum.rst:1228 @@ -2268,8 +2266,8 @@ msgstr "Flag 類別" msgid "" "Flags have an expanded view of aliasing: to be canonical, the value of a " "flag needs to be a power-of-two value, and not a duplicate name. So, in " -"addition to the :class:`Enum` definition of alias, a flag with no value " -"(a.k.a. ``0``) or with more than one power-of-two value (e.g. ``3``) is " +"addition to the :class:`Enum` definition of alias, a flag with no value (a.k." +"a. ``0``) or with more than one power-of-two value (e.g. ``3``) is " "considered an alias." msgstr "" @@ -2279,11 +2277,11 @@ msgstr "" #: ../../howto/enum.rst:1238 msgid "" -"The most interesting thing about enum members is that they are " -"singletons. :class:`EnumType` creates them all while it is creating the enum " -"class itself, and then puts a custom :meth:`~object.__new__` in place to " -"ensure that no new ones are ever instantiated by returning only the existing " -"member instances." +"The most interesting thing about enum members is that they are singletons. :" +"class:`EnumType` creates them all while it is creating the enum class " +"itself, and then puts a custom :meth:`~object.__new__` in place to ensure " +"that no new ones are ever instantiated by returning only the existing member " +"instances." msgstr "" #: ../../howto/enum.rst:1244 @@ -2342,11 +2340,10 @@ msgstr "" #: ../../howto/enum.rst:1273 msgid "" -"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, " -"and :class:`IntFlag` are expected to cover the majority of use-cases, they " -"cannot cover them all. Here are recipes for some different types of " -"enumerations that can be used directly, or as examples for creating one's " -"own." +"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, and :" +"class:`IntFlag` are expected to cover the majority of use-cases, they cannot " +"cover them all. Here are recipes for some different types of enumerations " +"that can be used directly, or as examples for creating one's own." msgstr "" #: ../../howto/enum.rst:1280 @@ -2438,8 +2435,8 @@ msgstr "" #: ../../howto/enum.rst:1323 msgid "" -"This is also a good example of why you might want to write your " -"own :meth:`~object.__repr__`::" +"This is also a good example of why you might want to write your own :meth:" +"`~object.__repr__`::" msgstr "" #: ../../howto/enum.rst:1326 @@ -2780,11 +2777,11 @@ msgid "" "... Period['day_%d' % i] = i\n" "...\n" ">>> list(Period)[:2]\n" -"[, ]\n" +"[, ]\n" ">>> list(Period)[-2:]\n" -"[, ]" +"[, ]" msgstr "" #: ../../howto/enum.rst:1558 diff --git a/library/enum.po b/library/enum.po index d6d9120849..acd468baa1 100644 --- a/library/enum.po +++ b/library/enum.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-23 00:17+0000\n" +"POT-Creation-Date: 2025-08-13 00:16+0000\n" "PO-Revision-Date: 2024-12-21 13:50+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -367,10 +367,16 @@ msgstr "" "員、正確處理重複、提供列舉類別的疊代等等。" #: ../../library/enum.rst:180 +msgid "" +"Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " +"as an alias." +msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。" + +#: ../../library/enum.rst:184 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" -#: ../../library/enum.rst:182 +#: ../../library/enum.rst:186 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" @@ -378,7 +384,7 @@ msgstr "查詢已存在的成員:" msgid "cls" msgstr "cls" -#: ../../library/enum.rst:184 ../../library/enum.rst:190 +#: ../../library/enum.rst:188 ../../library/enum.rst:194 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" @@ -386,17 +392,17 @@ msgstr "所呼叫的列舉類別。" msgid "value" msgstr "value" -#: ../../library/enum.rst:185 +#: ../../library/enum.rst:189 msgid "The value to lookup." msgstr "要查詢的值。" -#: ../../library/enum.rst:187 +#: ../../library/enum.rst:191 msgid "" "to use the ``cls`` enum to create a new enum (only if the existing enum does " "not have any members):" msgstr "使用 ``cls`` 列舉來建立新列舉(只有在現有列舉沒有任何成員時)" -#: ../../library/enum.rst:191 +#: ../../library/enum.rst:195 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" @@ -404,7 +410,7 @@ msgstr "要建立的新列舉的名稱。" msgid "names" msgstr "names" -#: ../../library/enum.rst:192 +#: ../../library/enum.rst:196 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" @@ -412,7 +418,7 @@ msgstr "新列舉的成員的名稱/值。" msgid "module" msgstr "module" -#: ../../library/enum.rst:193 +#: ../../library/enum.rst:197 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" @@ -420,7 +426,7 @@ msgstr "新列舉要建立在哪個模組名稱下。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:194 +#: ../../library/enum.rst:198 msgid "The actual location in the module where this Enum can be found." msgstr "這個列舉在模組裡實際上的位置。" @@ -428,7 +434,7 @@ msgstr "這個列舉在模組裡實際上的位置。" msgid "type" msgstr "type" -#: ../../library/enum.rst:195 +#: ../../library/enum.rst:199 msgid "A mix-in type for the new Enum." msgstr "新列舉的混合型別。" @@ -436,7 +442,7 @@ msgstr "新列舉的混合型別。" msgid "start" msgstr "start" -#: ../../library/enum.rst:196 +#: ../../library/enum.rst:200 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" @@ -444,16 +450,16 @@ msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" msgid "boundary" msgstr "boundary" -#: ../../library/enum.rst:197 +#: ../../library/enum.rst:201 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)" -#: ../../library/enum.rst:201 +#: ../../library/enum.rst:205 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" -#: ../../library/enum.rst:203 +#: ../../library/enum.rst:207 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -467,7 +473,7 @@ msgstr "" ">>> Color.RED.value in Color\n" "True" -#: ../../library/enum.rst:211 +#: ../../library/enum.rst:215 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." @@ -475,7 +481,7 @@ msgstr "" "在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 " "``TypeError``。" -#: ../../library/enum.rst:216 +#: ../../library/enum.rst:220 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" @@ -483,7 +489,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" -#: ../../library/enum.rst:219 +#: ../../library/enum.rst:223 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " @@ -495,13 +501,13 @@ msgstr "" "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:224 +#: ../../library/enum.rst:228 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" -#: ../../library/enum.rst:226 +#: ../../library/enum.rst:230 msgid "" ">>> Color['BLUE']\n" "" @@ -509,11 +515,11 @@ msgstr "" ">>> Color['BLUE']\n" "" -#: ../../library/enum.rst:231 +#: ../../library/enum.rst:235 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" -#: ../../library/enum.rst:233 +#: ../../library/enum.rst:237 msgid "" ">>> list(Color)\n" "[, , ]" @@ -521,11 +527,11 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../library/enum.rst:238 +#: ../../library/enum.rst:242 msgid "Returns the number of member in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" -#: ../../library/enum.rst:240 +#: ../../library/enum.rst:244 msgid "" ">>> len(Color)\n" "3" @@ -533,15 +539,15 @@ msgstr "" ">>> len(Color)\n" "3" -#: ../../library/enum.rst:245 +#: ../../library/enum.rst:249 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "回傳每個列舉名稱到其成員的對映,包括別名" -#: ../../library/enum.rst:249 +#: ../../library/enum.rst:253 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" -#: ../../library/enum.rst:251 +#: ../../library/enum.rst:255 msgid "" ">>> list(reversed(Color))\n" "[, , ]" @@ -549,37 +555,15 @@ msgstr "" ">>> list(reversed(Color))\n" "[, , ]" -#: ../../library/enum.rst:256 -msgid "" -"Adds a new name as an alias to an existing member. Raises a :exc:" -"`NameError` if the name is already assigned to a different member." -msgstr "" -"新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :" -"exc:`NameError`。" - #: ../../library/enum.rst:261 -msgid "" -"Adds a new value as an alias to an existing member. Raises a :exc:" -"`ValueError` if the value is already linked with a different member." -msgstr "" -"新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:" -"`ValueError`。" - -#: ../../library/enum.rst:266 -msgid "" -"Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " -"as an alias." -msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。" - -#: ../../library/enum.rst:271 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" -#: ../../library/enum.rst:275 +#: ../../library/enum.rst:265 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" -#: ../../library/enum.rst:277 +#: ../../library/enum.rst:267 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" @@ -587,11 +571,11 @@ msgstr "" ">>> Color.BLUE.name\n" "'BLUE'" -#: ../../library/enum.rst:282 +#: ../../library/enum.rst:272 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" -#: ../../library/enum.rst:284 +#: ../../library/enum.rst:274 msgid "" ">>> Color.RED.value\n" "1" @@ -599,15 +583,15 @@ msgstr "" ">>> Color.RED.value\n" "1" -#: ../../library/enum.rst:287 ../../library/enum.rst:307 +#: ../../library/enum.rst:277 ../../library/enum.rst:297 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。" -#: ../../library/enum.rst:289 +#: ../../library/enum.rst:279 msgid "Enum member values" msgstr "列舉成員的值" -#: ../../library/enum.rst:291 +#: ../../library/enum.rst:281 msgid "" "Member values can be anything: :class:`int`, :class:`str`, etc. If the " "exact value is unimportant you may use :class:`auto` instances and an " @@ -617,7 +601,7 @@ msgstr "" "重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :" "class:`auto`。" -#: ../../library/enum.rst:296 +#: ../../library/enum.rst:286 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " @@ -628,23 +612,23 @@ msgstr "" "`dict`、:class:`list` 或可變的 :class:`~dataclasses.dataclass`,它們在建立期" "間會對效能產生相對於列舉中可變的 / 不可雜湊的值總數量的二次方影響。" -#: ../../library/enum.rst:303 +#: ../../library/enum.rst:293 msgid "Name of the member." msgstr "成員名稱。" -#: ../../library/enum.rst:311 +#: ../../library/enum.rst:301 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)" -#: ../../library/enum.rst:316 +#: ../../library/enum.rst:306 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" -#: ../../library/enum.rst:319 +#: ../../library/enum.rst:309 msgid "" "``_ignore_`` is a list of names that will not become members, and whose " "names will also be removed from the completed enumeration. See :ref:" @@ -653,7 +637,7 @@ msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" -#: ../../library/enum.rst:325 +#: ../../library/enum.rst:315 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" @@ -661,7 +645,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 " "*self.__class__* 上定義的公開方法: ::" -#: ../../library/enum.rst:328 +#: ../../library/enum.rst:318 msgid "" ">>> from datetime import date\n" ">>> class Weekday(Enum):\n" @@ -701,11 +685,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:346 +#: ../../library/enum.rst:336 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:347 +#: ../../library/enum.rst:337 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -713,7 +697,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:348 +#: ../../library/enum.rst:338 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -721,17 +705,17 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:349 +#: ../../library/enum.rst:339 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:351 +#: ../../library/enum.rst:341 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" -#: ../../library/enum.rst:354 +#: ../../library/enum.rst:344 msgid "" ">>> from enum import auto\n" ">>> class PowersOfThree(Enum):\n" @@ -755,7 +739,7 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:367 +#: ../../library/enum.rst:357 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -763,19 +747,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:374 +#: ../../library/enum.rst:364 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:378 +#: ../../library/enum.rst:368 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:383 +#: ../../library/enum.rst:373 msgid "" "A *classmethod* for looking up values not found in *cls*. By default it " "does nothing, but can be overridden to implement custom search behavior::" @@ -783,7 +767,7 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:386 +#: ../../library/enum.rst:376 msgid "" ">>> from enum import StrEnum\n" ">>> class Build(StrEnum):\n" @@ -819,7 +803,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:405 +#: ../../library/enum.rst:395 msgid "" "By default, doesn't exist. If specified, either in the enum class " "definition or in a mixin class (such as ``int``), all values given in the " @@ -828,12 +812,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:413 +#: ../../library/enum.rst:403 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。" -#: ../../library/enum.rst:417 +#: ../../library/enum.rst:407 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -841,7 +825,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:422 +#: ../../library/enum.rst:412 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -849,7 +833,7 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:425 +#: ../../library/enum.rst:415 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -875,7 +859,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:438 +#: ../../library/enum.rst:428 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -883,7 +867,7 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:441 +#: ../../library/enum.rst:431 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -907,7 +891,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:453 +#: ../../library/enum.rst:443 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -915,7 +899,7 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:456 +#: ../../library/enum.rst:446 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -939,17 +923,62 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:468 +#: ../../library/enum.rst:458 msgid "" "Using :class:`auto` with :class:`Enum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`Enum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:471 +#: ../../library/enum.rst:461 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" -#: ../../library/enum.rst:476 +#: ../../library/enum.rst:465 +#, fuzzy +msgid "Adds a new name as an alias to an existing member::" +msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" + +#: ../../library/enum.rst:467 +#, fuzzy +msgid "" +">>> Color.RED._add_alias_(\"ERROR\")\n" +">>> Color.ERROR\n" +"" +msgstr "" +">>> Color.RED | Color.GREEN\n" +"" + +#: ../../library/enum.rst:471 +#, fuzzy +msgid "" +"Raises a :exc:`NameError` if the name is already assigned to a different " +"member." +msgstr "" +"新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :" +"exc:`NameError`。" + +#: ../../library/enum.rst:477 +#, fuzzy +msgid "Adds a new value as an alias to an existing member::" +msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" + +#: ../../library/enum.rst:479 +msgid "" +">>> Color.RED._add_value_alias_(42)\n" +">>> Color(42)\n" +"" +msgstr "" + +#: ../../library/enum.rst:483 +#, fuzzy +msgid "" +"Raises a :exc:`ValueError` if the value is already linked with a different " +"member." +msgstr "" +"新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:" +"`ValueError`。" + +#: ../../library/enum.rst:490 msgid "" "*IntEnum* is the same as :class:`Enum`, but its members are also integers " "and can be used anywhere that an integer can be used. If any integer " @@ -959,13 +988,13 @@ msgstr "" "*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數" "的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。" -#: ../../library/enum.rst:497 +#: ../../library/enum.rst:511 msgid "" "Using :class:`auto` with :class:`IntEnum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`IntEnum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:500 +#: ../../library/enum.rst:514 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -975,17 +1004,17 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:507 +#: ../../library/enum.rst:521 msgid "" "*StrEnum* is the same as :class:`Enum`, but its members are also strings and " "can be used in most of the same places that a string can be used. The result " "of any string operation performed on or with a *StrEnum* member is not part " "of the enumeration." msgstr "" -"*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使" -"用字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" +"*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使用" +"字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:528 +#: ../../library/enum.rst:542 msgid "" "There are places in the stdlib that check for an exact :class:`str` instead " "of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of " @@ -996,13 +1025,13 @@ msgstr "" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" "你需要使用 ``str(MyStrEnum.MY_MEMBER)``。" -#: ../../library/enum.rst:535 +#: ../../library/enum.rst:549 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr ":class:`StrEnum` 使用 :class:`auto` 會產生小寫的成員名稱當作值。" -#: ../../library/enum.rst:540 +#: ../../library/enum.rst:554 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -1012,7 +1041,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:548 +#: ../../library/enum.rst:562 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -1022,11 +1051,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:554 +#: ../../library/enum.rst:568 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:556 +#: ../../library/enum.rst:570 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1062,11 +1091,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:575 +#: ../../library/enum.rst:589 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:577 +#: ../../library/enum.rst:591 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1078,11 +1107,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:586 +#: ../../library/enum.rst:600 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:588 +#: ../../library/enum.rst:602 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1094,11 +1123,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:597 +#: ../../library/enum.rst:611 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:599 +#: ../../library/enum.rst:613 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1116,11 +1145,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:609 +#: ../../library/enum.rst:623 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:611 +#: ../../library/enum.rst:625 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1128,11 +1157,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:616 +#: ../../library/enum.rst:630 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:618 +#: ../../library/enum.rst:632 msgid "" ">>> purple & white\n" "\n" @@ -1144,11 +1173,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:625 +#: ../../library/enum.rst:639 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:627 +#: ../../library/enum.rst:641 msgid "" ">>> purple ^ white\n" "\n" @@ -1160,11 +1189,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:634 +#: ../../library/enum.rst:648 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:636 +#: ../../library/enum.rst:650 msgid "" ">>> ~white\n" "\n" @@ -1180,7 +1209,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:645 +#: ../../library/enum.rst:659 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1188,17 +1217,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:650 +#: ../../library/enum.rst:664 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr ":class:`Flag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:653 +#: ../../library/enum.rst:667 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是: ::" -#: ../../library/enum.rst:661 +#: ../../library/enum.rst:675 msgid "" "``IntFlag`` is the same as :class:`Flag`, but its members are also integers " "and can be used anywhere that an integer can be used." @@ -1206,13 +1235,13 @@ msgstr "" "``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" "數的地方。" -#: ../../library/enum.rst:675 +#: ../../library/enum.rst:689 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:678 +#: ../../library/enum.rst:692 msgid "" ">>> Color.RED + 2\n" "3" @@ -1220,32 +1249,32 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:681 +#: ../../library/enum.rst:695 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:683 +#: ../../library/enum.rst:697 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:684 +#: ../../library/enum.rst:698 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:686 +#: ../../library/enum.rst:700 msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now:" msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是:" -#: ../../library/enum.rst:693 +#: ../../library/enum.rst:707 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" ":class:`IntFlag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:698 +#: ../../library/enum.rst:712 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1255,7 +1284,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:702 +#: ../../library/enum.rst:716 msgid "" "Inversion of an :class:`!IntFlag` now returns a positive value that is the " "union of all flags not in the given flag, rather than a negative value. This " @@ -1264,7 +1293,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:708 +#: ../../library/enum.rst:722 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1272,15 +1301,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:711 +#: ../../library/enum.rst:725 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:712 +#: ../../library/enum.rst:726 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:714 +#: ../../library/enum.rst:728 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1289,7 +1318,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:723 +#: ../../library/enum.rst:737 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1297,11 +1326,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:728 +#: ../../library/enum.rst:742 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:730 +#: ../../library/enum.rst:744 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1325,13 +1354,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:744 +#: ../../library/enum.rst:758 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:747 +#: ../../library/enum.rst:761 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1353,7 +1382,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:759 +#: ../../library/enum.rst:773 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1361,7 +1390,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:762 +#: ../../library/enum.rst:776 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1389,24 +1418,24 @@ msgstr "" "ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " "combined values of 0x18 [use enum.show_flag_values(value) for details]" -#: ../../library/enum.rst:776 +#: ../../library/enum.rst:790 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:782 +#: ../../library/enum.rst:796 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:787 +#: ../../library/enum.rst:801 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "範圍外的值會引發 :exc:`ValueError`。這是 :class:`Flag` 的預設行為: ::" -#: ../../library/enum.rst:790 +#: ../../library/enum.rst:804 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1434,13 +1463,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:805 +#: ../../library/enum.rst:819 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:808 +#: ../../library/enum.rst:822 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1460,13 +1489,13 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:819 +#: ../../library/enum.rst:833 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:832 +#: ../../library/enum.rst:846 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" @@ -1474,7 +1503,7 @@ msgstr "" "範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " "的預設行為: ::" -#: ../../library/enum.rst:835 +#: ../../library/enum.rst:849 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1494,7 +1523,7 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:848 +#: ../../library/enum.rst:862 msgid "" "*EnumDict* is a subclass of :class:`dict` that is used as the namespace for " "defining enum classes (see :ref:`prepare`). It is exposed to allow " @@ -1508,7 +1537,7 @@ msgstr "" "如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" "稱和內部類別將無法被正確處理。" -#: ../../library/enum.rst:855 +#: ../../library/enum.rst:869 msgid "" "Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" "`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " @@ -1519,15 +1548,15 @@ msgstr "" "__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" "dict` 操作來繞過檢查,例如 :meth:`|= `。" -#: ../../library/enum.rst:862 +#: ../../library/enum.rst:876 msgid "A list of member names." msgstr "一個成員名稱的串列。" -#: ../../library/enum.rst:869 +#: ../../library/enum.rst:883 msgid "Supported ``__dunder__`` names" msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:871 +#: ../../library/enum.rst:885 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1535,7 +1564,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:874 +#: ../../library/enum.rst:888 msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " @@ -1545,38 +1574,26 @@ msgstr "" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:880 +#: ../../library/enum.rst:894 msgid "Supported ``_sunder_`` names" msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:882 -msgid "" -":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " -"member." -msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" - -#: ../../library/enum.rst:884 -msgid "" -":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " -"existing member." -msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" - -#: ../../library/enum.rst:886 +#: ../../library/enum.rst:896 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:887 +#: ../../library/enum.rst:897 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:888 +#: ../../library/enum.rst:898 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:890 +#: ../../library/enum.rst:900 msgid "" ":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" "class:`str`, that will not be transformed into members, and will be removed " @@ -1585,7 +1602,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:893 +#: ../../library/enum.rst:903 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1593,28 +1610,42 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:895 +#: ../../library/enum.rst:905 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" ":meth:`~Enum._generate_next_value_` -- 用來為列舉成員取得合適的值;可以被覆寫" -#: ../../library/enum.rst:900 +#: ../../library/enum.rst:910 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:903 +#: ../../library/enum.rst:913 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:906 +#: ../../library/enum.rst:916 +#, fuzzy +msgid "" +":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " +"member." +msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" + +#: ../../library/enum.rst:918 +#, fuzzy +msgid "" +":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " +"existing member." +msgstr ":meth:`~EnumType._add_value_alias_` -- 新增一個值作為現有成員的別名。" + +#: ../../library/enum.rst:921 msgid "" "While ``_sunder_`` names are generally reserved for the further development " "of the :class:`Enum` class and can not be used, some are explicitly allowed:" @@ -1622,30 +1653,30 @@ msgstr "" "雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" "用,但有些是明確允許的:" -#: ../../library/enum.rst:909 +#: ../../library/enum.rst:924 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" "``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " "`_" -#: ../../library/enum.rst:911 +#: ../../library/enum.rst:926 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:912 +#: ../../library/enum.rst:927 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:913 +#: ../../library/enum.rst:928 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" -#: ../../library/enum.rst:919 +#: ../../library/enum.rst:934 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:923 +#: ../../library/enum.rst:938 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " "call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an " @@ -1661,16 +1692,16 @@ msgstr "" "`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" "說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" -#: ../../library/enum.rst:931 +#: ../../library/enum.rst:946 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "*auto* 實例只有在最上層的賦值時才會被解析:" -#: ../../library/enum.rst:933 +#: ../../library/enum.rst:948 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:934 +#: ../../library/enum.rst:949 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1678,7 +1709,7 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:936 +#: ../../library/enum.rst:951 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" @@ -1686,19 +1717,19 @@ msgstr "" "``THREE = [auto(), -3]`` *無法*\\ 運作(\\ ``, -3`` 會被用來建立列" "舉成員 ``THREE``)" -#: ../../library/enum.rst:941 +#: ../../library/enum.rst:956 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:944 +#: ../../library/enum.rst:959 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:947 +#: ../../library/enum.rst:962 msgid "" "in 3.13 the default ``_generate_next_value_`` will always return the highest " "member value incremented by 1, and will fail if any member is an " @@ -1707,7 +1738,7 @@ msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" "是不相容的型別就會失敗。" -#: ../../library/enum.rst:953 +#: ../../library/enum.rst:968 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1716,7 +1747,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:957 +#: ../../library/enum.rst:972 msgid "" "the *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " @@ -1726,7 +1757,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:966 +#: ../../library/enum.rst:981 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1736,7 +1767,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:970 +#: ../../library/enum.rst:985 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1762,7 +1793,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:984 +#: ../../library/enum.rst:999 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1771,15 +1802,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:992 +#: ../../library/enum.rst:1007 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:998 +#: ../../library/enum.rst:1013 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:1004 +#: ../../library/enum.rst:1019 msgid "" "A decorator to change the :class:`str() ` and :func:`repr` of an enum " "to show its members as belonging to the module instead of its class. Should " @@ -1790,19 +1821,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:1013 +#: ../../library/enum.rst:1028 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:1021 +#: ../../library/enum.rst:1036 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:1023 +#: ../../library/enum.rst:1038 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:1025 +#: ../../library/enum.rst:1040 msgid "" "These three enum types are designed to be drop-in replacements for existing " "integer- and string-based values; as such, they have extra limitations:" @@ -1810,17 +1841,17 @@ msgstr "" "這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:1028 +#: ../../library/enum.rst:1043 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1030 +#: ../../library/enum.rst:1045 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "``__format__`` 因為使用 ``__str__``,也會使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1033 +#: ../../library/enum.rst:1048 msgid "" "If you do not need/want those limitations, you can either create your own " "base class by mixing in the ``int`` or ``str`` type yourself::" @@ -1828,7 +1859,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:1036 +#: ../../library/enum.rst:1051 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1838,11 +1869,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1040 +#: ../../library/enum.rst:1055 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1042 +#: ../../library/enum.rst:1057 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" From 91e85c2ae9da4e63d46eeb5a20d4dbd716e8e34a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 14 Aug 2025 00:17:29 +0000 Subject: [PATCH 13/13] sync with cpython 9417ea59 --- library/functions.po | 308 +++++++++++++++++----------------- library/locale.po | 386 ++++++++++++++++++++++++++----------------- 2 files changed, 394 insertions(+), 300 deletions(-) diff --git a/library/functions.po b/library/functions.po index fee1a48f99..59195e3e29 100644 --- a/library/functions.po +++ b/library/functions.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-09 00:16+0000\n" +"POT-Creation-Date: 2025-08-14 00:16+0000\n" "PO-Revision-Date: 2024-05-06 17:06+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2716,17 +2716,29 @@ msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` 模式被移除。" #: ../../library/functions.rst:1555 +msgid "Return the ordinal value of a character." +msgstr "" + +#: ../../library/functions.rst:1557 +#, fuzzy msgid "" -"Given a string representing one Unicode character, return an integer " -"representing the Unicode code point of that character. For example, " -"``ord('a')`` returns the integer ``97`` and ``ord('€')`` (Euro sign) returns " -"``8364``. This is the inverse of :func:`chr`." +"If the argument is a one-character string, return the Unicode code point of " +"that character. For example, ``ord('a')`` returns the integer ``97`` and " +"``ord('€')`` (Euro sign) returns ``8364``. This is the inverse of :func:" +"`chr`." msgstr "" "對於代表單個 Unicode 字元的字串,回傳代表它 Unicode 編碼位置的整數。例如 " "``ord('a')`` 回傳整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這" "是 :func:`chr` 的逆函式。" -#: ../../library/functions.rst:1563 +#: ../../library/functions.rst:1562 +msgid "" +"If the argument is a :class:`bytes` or :class:`bytearray` object of length " +"1, return its single byte value. For example, ``ord(b'a')`` returns the " +"integer ``97``." +msgstr "" + +#: ../../library/functions.rst:1569 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " "power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " @@ -2737,7 +2749,7 @@ msgstr "" "*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" -#: ../../library/functions.rst:1568 +#: ../../library/functions.rst:1574 #, fuzzy msgid "" "When arguments are builtin numeric types with mixed operand types, the " @@ -2762,7 +2774,7 @@ msgstr "" "`float` 的負數且指數為整數,則會得到一個浮點數的結果,例如 ``pow(-9, 2.0)`` " "會回傳 ``81.0``。" -#: ../../library/functions.rst:1580 +#: ../../library/functions.rst:1586 msgid "" "For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must " "also be of integer type and *mod* must be nonzero. If *mod* is present and " @@ -2775,11 +2787,11 @@ msgstr "" "與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " "*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" -#: ../../library/functions.rst:1586 +#: ../../library/functions.rst:1592 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" -#: ../../library/functions.rst:1588 +#: ../../library/functions.rst:1594 msgid "" ">>> pow(38, -1, mod=97)\n" "23\n" @@ -2791,7 +2803,7 @@ msgstr "" ">>> 23 * 38 % 97 == 1\n" "True" -#: ../../library/functions.rst:1593 +#: ../../library/functions.rst:1599 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2799,12 +2811,12 @@ msgstr "" "對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" "許模倒數的計算。" -#: ../../library/functions.rst:1598 +#: ../../library/functions.rst:1604 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "允許關鍵字引數。在此之前只支援位置引數。" -#: ../../library/functions.rst:1605 +#: ../../library/functions.rst:1611 msgid "" "Print *objects* to the text stream *file*, separated by *sep* and followed " "by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as " @@ -2813,7 +2825,7 @@ msgstr "" "將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" "給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" -#: ../../library/functions.rst:1609 +#: ../../library/functions.rst:1615 msgid "" "All non-keyword arguments are converted to strings like :func:`str` does and " "written to the stream, separated by *sep* and followed by *end*. Both *sep* " @@ -2826,7 +2838,7 @@ msgstr "" "以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" "寫入 *end*。" -#: ../../library/functions.rst:1615 +#: ../../library/functions.rst:1621 msgid "" "The *file* argument must be an object with a ``write(string)`` method; if it " "is not present or ``None``, :data:`sys.stdout` will be used. Since printed " @@ -2838,7 +2850,7 @@ msgstr "" "串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " "``file.write(...)``。" -#: ../../library/functions.rst:1620 +#: ../../library/functions.rst:1626 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2846,15 +2858,15 @@ msgstr "" "輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" "除。" -#: ../../library/functions.rst:1624 +#: ../../library/functions.rst:1630 msgid "Added the *flush* keyword argument." msgstr "增加了 *flush* 關鍵字引數。" -#: ../../library/functions.rst:1630 +#: ../../library/functions.rst:1636 msgid "Return a property attribute." msgstr "回傳 property 屬性。" -#: ../../library/functions.rst:1632 +#: ../../library/functions.rst:1638 msgid "" "*fget* is a function for getting an attribute value. *fset* is a function " "for setting an attribute value. *fdel* is a function for deleting an " @@ -2863,11 +2875,11 @@ msgstr "" "*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " "是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" -#: ../../library/functions.rst:1636 +#: ../../library/functions.rst:1642 msgid "A typical use is to define a managed attribute ``x``::" msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" -#: ../../library/functions.rst:1638 +#: ../../library/functions.rst:1644 msgid "" "class C:\n" " def __init__(self):\n" @@ -2899,7 +2911,7 @@ msgstr "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../library/functions.rst:1653 +#: ../../library/functions.rst:1659 msgid "" "If *c* is an instance of *C*, ``c.x`` will invoke the getter, ``c.x = " "value`` will invoke the setter, and ``del c.x`` the deleter." @@ -2907,7 +2919,7 @@ msgstr "" "如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會叫用取得器 (getter),``c.x = " "value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" -#: ../../library/functions.rst:1656 +#: ../../library/functions.rst:1662 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " @@ -2918,7 +2930,7 @@ msgstr "" "*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" "`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" -#: ../../library/functions.rst:1660 +#: ../../library/functions.rst:1666 msgid "" "class Parrot:\n" " def __init__(self):\n" @@ -2930,14 +2942,14 @@ msgid "" " return self._voltage" msgstr "" -#: ../../library/functions.rst:1669 +#: ../../library/functions.rst:1675 msgid "" "The ``@property`` decorator turns the :meth:`!voltage` method into a " "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" -#: ../../library/functions.rst:1677 +#: ../../library/functions.rst:1683 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -2945,7 +2957,7 @@ msgid "" "with an example:" msgstr "" -#: ../../library/functions.rst:1682 +#: ../../library/functions.rst:1688 msgid "" "class C:\n" " def __init__(self):\n" @@ -2981,36 +2993,36 @@ msgstr "" " def x(self):\n" " del self._x" -#: ../../library/functions.rst:1701 +#: ../../library/functions.rst:1707 msgid "" "This code is exactly equivalent to the first example. Be sure to give the " "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" -#: ../../library/functions.rst:1705 +#: ../../library/functions.rst:1711 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" -#: ../../library/functions.rst:1708 +#: ../../library/functions.rst:1714 msgid "The docstrings of property objects are now writeable." msgstr "" -#: ../../library/functions.rst:1713 +#: ../../library/functions.rst:1719 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." msgstr "" -#: ../../library/functions.rst:1724 +#: ../../library/functions.rst:1730 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:1730 +#: ../../library/functions.rst:1736 msgid "" "Return a string containing a printable representation of an object. For " "many types, this function makes an attempt to return a string that would " @@ -3023,11 +3035,11 @@ msgid "" "raise :exc:`RuntimeError`." msgstr "" -#: ../../library/functions.rst:1741 +#: ../../library/functions.rst:1747 msgid "This class has a custom representation that can be evaluated::" msgstr "" -#: ../../library/functions.rst:1743 +#: ../../library/functions.rst:1749 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3045,7 +3057,7 @@ msgstr "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" -#: ../../library/functions.rst:1754 +#: ../../library/functions.rst:1760 msgid "" "Return a reverse :term:`iterator`. *seq* must be an object which has a :" "meth:`~object.__reversed__` method or supports the sequence protocol (the :" @@ -3053,14 +3065,14 @@ msgid "" "with integer arguments starting at ``0``)." msgstr "" -#: ../../library/functions.rst:1762 +#: ../../library/functions.rst:1768 msgid "" "Return *number* rounded to *ndigits* precision after the decimal point. If " "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" -#: ../../library/functions.rst:1766 +#: ../../library/functions.rst:1772 msgid "" "For the built-in types supporting :func:`round`, values are rounded to the " "closest multiple of 10 to the power minus *ndigits*; if two multiples are " @@ -3071,13 +3083,13 @@ msgid "" "``None``. Otherwise, the return value has the same type as *number*." msgstr "" -#: ../../library/functions.rst:1775 +#: ../../library/functions.rst:1781 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -#: ../../library/functions.rst:1780 +#: ../../library/functions.rst:1786 msgid "" "The behavior of :func:`round` for floats can be surprising: for example, " "``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``. This is " @@ -3086,21 +3098,21 @@ msgid "" "information." msgstr "" -#: ../../library/functions.rst:1792 +#: ../../library/functions.rst:1798 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" "set` for documentation about this class." msgstr "" -#: ../../library/functions.rst:1796 +#: ../../library/functions.rst:1802 msgid "" "For other containers see the built-in :class:`frozenset`, :class:`list`, :" "class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " "module." msgstr "" -#: ../../library/functions.rst:1803 +#: ../../library/functions.rst:1809 msgid "" "This is the counterpart of :func:`getattr`. The arguments are an object, a " "string, and an arbitrary value. The string may name an existing attribute " @@ -3109,7 +3121,7 @@ msgid "" "is equivalent to ``x.foobar = 123``." msgstr "" -#: ../../library/functions.rst:1809 +#: ../../library/functions.rst:1815 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " "unless the object chooses to enforce that, for example in a custom :meth:" @@ -3118,21 +3130,21 @@ msgid "" "notation, but is accessible through :func:`getattr` etc.." msgstr "" -#: ../../library/functions.rst:1817 +#: ../../library/functions.rst:1823 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " "with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" -#: ../../library/functions.rst:1826 +#: ../../library/functions.rst:1832 msgid "" "Return a :term:`slice` object representing the set of indices specified by " "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" -#: ../../library/functions.rst:1830 +#: ../../library/functions.rst:1836 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " @@ -3140,48 +3152,48 @@ msgid "" "by NumPy and other third-party packages." msgstr "" -#: ../../library/functions.rst:1839 +#: ../../library/functions.rst:1845 msgid "" "Slice objects are also generated when extended indexing syntax is used. For " "example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" "`itertools.islice` for an alternate version that returns an :term:`iterator`." msgstr "" -#: ../../library/functions.rst:1844 +#: ../../library/functions.rst:1850 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" -#: ../../library/functions.rst:1850 +#: ../../library/functions.rst:1856 msgid "Return a new sorted list from the items in *iterable*." msgstr "" -#: ../../library/functions.rst:1852 +#: ../../library/functions.rst:1858 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" -#: ../../library/functions.rst:1854 +#: ../../library/functions.rst:1860 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" -#: ../../library/functions.rst:1858 +#: ../../library/functions.rst:1864 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" -#: ../../library/functions.rst:1861 +#: ../../library/functions.rst:1867 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" -#: ../../library/functions.rst:1864 +#: ../../library/functions.rst:1870 msgid "" "The built-in :func:`sorted` function is guaranteed to be stable. A sort is " "stable if it guarantees not to change the relative order of elements that " @@ -3189,7 +3201,7 @@ msgid "" "example, sort by department, then by salary grade)." msgstr "" -#: ../../library/functions.rst:1869 +#: ../../library/functions.rst:1875 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3201,22 +3213,22 @@ msgid "" "method." msgstr "" -#: ../../library/functions.rst:1878 +#: ../../library/functions.rst:1884 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../library/functions.rst:1882 +#: ../../library/functions.rst:1888 msgid "Transform a method into a static method." msgstr "" -#: ../../library/functions.rst:1884 +#: ../../library/functions.rst:1890 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" -#: ../../library/functions.rst:1887 +#: ../../library/functions.rst:1893 msgid "" "class C:\n" " @staticmethod\n" @@ -3226,7 +3238,7 @@ msgstr "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." -#: ../../library/functions.rst:1891 +#: ../../library/functions.rst:1897 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." @@ -3234,7 +3246,7 @@ msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" -#: ../../library/functions.rst:1894 +#: ../../library/functions.rst:1900 msgid "" "A static method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). Moreover, the static method :term:" @@ -3242,14 +3254,14 @@ msgid "" "(such as ``f()``)." msgstr "" -#: ../../library/functions.rst:1899 +#: ../../library/functions.rst:1905 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :func:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" -#: ../../library/functions.rst:1903 +#: ../../library/functions.rst:1909 msgid "" "Like all decorators, it is also possible to call ``staticmethod`` as a " "regular function and do something with its result. This is needed in some " @@ -3258,7 +3270,7 @@ msgid "" "cases, use this idiom::" msgstr "" -#: ../../library/functions.rst:1909 +#: ../../library/functions.rst:1915 msgid "" "def regular_function():\n" " ...\n" @@ -3272,11 +3284,11 @@ msgstr "" "class C:\n" " method = staticmethod(regular_function)" -#: ../../library/functions.rst:1915 +#: ../../library/functions.rst:1921 msgid "For more information on static methods, see :ref:`types`." msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" -#: ../../library/functions.rst:1917 +#: ../../library/functions.rst:1923 msgid "" "Static methods now inherit the method attributes (:attr:`~function." "__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" @@ -3288,25 +3300,25 @@ msgstr "" "__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " "``__wrapped__`` 屬性,且為如一般函式的可呼叫物件。" -#: ../../library/functions.rst:1933 +#: ../../library/functions.rst:1939 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "" -#: ../../library/functions.rst:1935 +#: ../../library/functions.rst:1941 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" -#: ../../library/functions.rst:1941 +#: ../../library/functions.rst:1947 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" -#: ../../library/functions.rst:1945 +#: ../../library/functions.rst:1951 msgid "" "For some use cases, there are good alternatives to :func:`sum`. The " "preferred, fast way to concatenate a sequence of strings is by calling ``''." @@ -3315,37 +3327,37 @@ msgid "" "using :func:`itertools.chain`." msgstr "" -#: ../../library/functions.rst:1951 +#: ../../library/functions.rst:1957 msgid "The *start* parameter can be specified as a keyword argument." msgstr "*start* 參數可被指定為關鍵字引數。" -#: ../../library/functions.rst:1954 +#: ../../library/functions.rst:1960 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" -#: ../../library/functions.rst:1961 +#: ../../library/functions.rst:1967 msgid "" "Return a proxy object that delegates method calls to a parent or sibling " "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" -#: ../../library/functions.rst:1965 +#: ../../library/functions.rst:1971 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" -#: ../../library/functions.rst:1969 +#: ../../library/functions.rst:1975 msgid "" "For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -" "> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" -#: ../../library/functions.rst:1973 +#: ../../library/functions.rst:1979 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" @@ -3353,7 +3365,7 @@ msgid "" "whenever the inheritance hierarchy is updated." msgstr "" -#: ../../library/functions.rst:1978 +#: ../../library/functions.rst:1984 msgid "" "If the second argument is omitted, the super object returned is unbound. If " "the second argument is an object, ``isinstance(obj, type)`` must be true. " @@ -3361,7 +3373,7 @@ msgid "" "(this is useful for classmethods)." msgstr "" -#: ../../library/functions.rst:1983 +#: ../../library/functions.rst:1989 msgid "" "When called directly within an ordinary method of a class, both arguments " "may be omitted (\"zero-argument :func:`!super`\"). In this case, *type* will " @@ -3371,7 +3383,7 @@ msgid "" "including generator expressions, which implicitly create nested functions.)" msgstr "" -#: ../../library/functions.rst:1990 +#: ../../library/functions.rst:1996 msgid "" "There are two typical use cases for *super*. In a class hierarchy with " "single inheritance, *super* can be used to refer to parent classes without " @@ -3379,7 +3391,7 @@ msgid "" "closely parallels the use of *super* in other programming languages." msgstr "" -#: ../../library/functions.rst:1995 +#: ../../library/functions.rst:2001 msgid "" "The second use case is to support cooperative multiple inheritance in a " "dynamic execution environment. This use case is unique to Python and is not " @@ -3392,11 +3404,11 @@ msgid "" "classes that are unknown prior to runtime)." msgstr "" -#: ../../library/functions.rst:2005 +#: ../../library/functions.rst:2011 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" -#: ../../library/functions.rst:2007 +#: ../../library/functions.rst:2013 msgid "" "class C(B):\n" " def method(self, arg):\n" @@ -3404,14 +3416,14 @@ msgid "" " # super(C, self).method(arg)" msgstr "" -#: ../../library/functions.rst:2012 +#: ../../library/functions.rst:2018 msgid "" "In addition to method lookups, :func:`super` also works for attribute " "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" -#: ../../library/functions.rst:2016 +#: ../../library/functions.rst:2022 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3421,7 +3433,7 @@ msgid "" "using statements or operators such as ``super()[name]``." msgstr "" -#: ../../library/functions.rst:2024 +#: ../../library/functions.rst:2030 msgid "" "Also note that, aside from the zero argument form, :func:`super` is not " "limited to use inside methods. The two argument form specifies the " @@ -3431,33 +3443,33 @@ msgid "" "accessing the current instance for ordinary methods." msgstr "" -#: ../../library/functions.rst:2031 +#: ../../library/functions.rst:2037 msgid "" "For practical suggestions on how to design cooperative classes using :func:" "`super`, see `guide to using super() `_." msgstr "" -#: ../../library/functions.rst:2041 +#: ../../library/functions.rst:2047 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:2050 +#: ../../library/functions.rst:2056 msgid "" "With one argument, return the type of an *object*. The return value is a " "type object and generally the same object as returned by :attr:`object." "__class__`." msgstr "" -#: ../../library/functions.rst:2054 +#: ../../library/functions.rst:2060 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." msgstr "" -#: ../../library/functions.rst:2057 +#: ../../library/functions.rst:2063 msgid "" "With three arguments, return a new type object. This is essentially a " "dynamic form of the :keyword:`class` statement. The *name* string is the " @@ -3470,21 +3482,21 @@ msgid "" "type` objects:" msgstr "" -#: ../../library/functions.rst:2072 +#: ../../library/functions.rst:2078 msgid "See also:" msgstr "" -#: ../../library/functions.rst:2074 +#: ../../library/functions.rst:2080 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" -#: ../../library/functions.rst:2075 +#: ../../library/functions.rst:2081 msgid ":ref:`bltin-type-objects`" msgstr ":ref:`bltin-type-objects`" -#: ../../library/functions.rst:2077 +#: ../../library/functions.rst:2083 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3492,23 +3504,23 @@ msgid "" "would." msgstr "" -#: ../../library/functions.rst:2082 +#: ../../library/functions.rst:2088 msgid "See also :ref:`class-customization`." msgstr "另請參閱 :ref:`class-customization`。" -#: ../../library/functions.rst:2084 +#: ../../library/functions.rst:2090 msgid "" "Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" -#: ../../library/functions.rst:2091 +#: ../../library/functions.rst:2097 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " "or any other object with a :attr:`!__dict__` attribute." msgstr "" -#: ../../library/functions.rst:2094 +#: ../../library/functions.rst:2100 msgid "" "Objects such as modules and instances have an updateable :attr:`~object." "__dict__` attribute; however, other objects may have write restrictions on " @@ -3516,34 +3528,34 @@ msgid "" "MappingProxyType` to prevent direct dictionary updates)." msgstr "" -#: ../../library/functions.rst:2099 +#: ../../library/functions.rst:2105 msgid "Without an argument, :func:`vars` acts like :func:`locals`." msgstr "" -#: ../../library/functions.rst:2101 +#: ../../library/functions.rst:2107 msgid "" "A :exc:`TypeError` exception is raised if an object is specified but it " "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " "defines the :attr:`~object.__slots__` attribute)." msgstr "" -#: ../../library/functions.rst:2107 +#: ../../library/functions.rst:2113 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:2113 +#: ../../library/functions.rst:2119 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" -#: ../../library/functions.rst:2116 +#: ../../library/functions.rst:2122 msgid "Example::" msgstr "例如: ::" -#: ../../library/functions.rst:2118 +#: ../../library/functions.rst:2124 msgid "" ">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" "... print(item)\n" @@ -3559,27 +3571,27 @@ msgstr "" "(2, 'spice')\n" "(3, 'everything nice')" -#: ../../library/functions.rst:2125 +#: ../../library/functions.rst:2131 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" -#: ../../library/functions.rst:2128 +#: ../../library/functions.rst:2134 msgid "" "Another way to think of :func:`zip` is that it turns rows into columns, and " "columns into rows. This is similar to `transposing a matrix `_." msgstr "" -#: ../../library/functions.rst:2132 +#: ../../library/functions.rst:2138 msgid "" ":func:`zip` is lazy: The elements won't be processed until the iterable is " "iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" "`list`." msgstr "" -#: ../../library/functions.rst:2136 +#: ../../library/functions.rst:2142 msgid "" "One thing to consider is that the iterables passed to :func:`zip` could have " "different lengths; sometimes by design, and sometimes because of a bug in " @@ -3587,14 +3599,14 @@ msgid "" "approaches to dealing with this issue:" msgstr "" -#: ../../library/functions.rst:2141 +#: ../../library/functions.rst:2147 msgid "" "By default, :func:`zip` stops when the shortest iterable is exhausted. It " "will ignore the remaining items in the longer iterables, cutting off the " "result to the length of the shortest iterable::" msgstr "" -#: ../../library/functions.rst:2145 +#: ../../library/functions.rst:2151 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" @@ -3602,14 +3614,14 @@ msgstr "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" -#: ../../library/functions.rst:2148 +#: ../../library/functions.rst:2154 msgid "" ":func:`zip` is often used in cases where the iterables are assumed to be of " "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" -#: ../../library/functions.rst:2152 +#: ../../library/functions.rst:2158 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" @@ -3617,37 +3629,37 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../library/functions.rst:2155 +#: ../../library/functions.rst:2161 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" -#: ../../library/functions.rst:2173 +#: ../../library/functions.rst:2179 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" -#: ../../library/functions.rst:2177 +#: ../../library/functions.rst:2183 msgid "" "Shorter iterables can be padded with a constant value to make all the " "iterables have the same length. This is done by :func:`itertools." "zip_longest`." msgstr "" -#: ../../library/functions.rst:2181 +#: ../../library/functions.rst:2187 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." msgstr "" -#: ../../library/functions.rst:2184 +#: ../../library/functions.rst:2190 msgid "Tips and tricks:" msgstr "" -#: ../../library/functions.rst:2186 +#: ../../library/functions.rst:2192 msgid "" "The left-to-right evaluation order of the iterables is guaranteed. This " "makes possible an idiom for clustering a data series into n-length groups " @@ -3656,13 +3668,13 @@ msgid "" "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" -#: ../../library/functions.rst:2192 +#: ../../library/functions.rst:2198 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -#: ../../library/functions.rst:2195 +#: ../../library/functions.rst:2201 msgid "" ">>> x = [1, 2, 3]\n" ">>> y = [4, 5, 6]\n" @@ -3680,17 +3692,17 @@ msgstr "" ">>> x == list(x2) and y == list(y2)\n" "True" -#: ../../library/functions.rst:2203 +#: ../../library/functions.rst:2209 msgid "Added the ``strict`` argument." msgstr "增加了 ``strict`` 引數。" -#: ../../library/functions.rst:2215 +#: ../../library/functions.rst:2221 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2218 +#: ../../library/functions.rst:2224 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -3702,7 +3714,7 @@ msgid "" "discouraged in favor of :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2227 +#: ../../library/functions.rst:2233 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -3712,7 +3724,7 @@ msgid "" "determine the package context of the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2234 +#: ../../library/functions.rst:2240 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -3721,7 +3733,7 @@ msgid "" "details)." msgstr "" -#: ../../library/functions.rst:2240 +#: ../../library/functions.rst:2246 msgid "" "When the *name* variable is of the form ``package.module``, normally, the " "top-level package (the name up till the first dot) is returned, *not* the " @@ -3729,37 +3741,37 @@ msgid "" "given, the module named by *name* is returned." msgstr "" -#: ../../library/functions.rst:2245 +#: ../../library/functions.rst:2251 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" -#: ../../library/functions.rst:2248 +#: ../../library/functions.rst:2254 msgid "spam = __import__('spam', globals(), locals(), [], 0)" msgstr "spam = __import__('spam', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2250 +#: ../../library/functions.rst:2256 msgid "The statement ``import spam.ham`` results in this call::" msgstr "" -#: ../../library/functions.rst:2252 +#: ../../library/functions.rst:2258 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2254 +#: ../../library/functions.rst:2260 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2257 +#: ../../library/functions.rst:2263 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" -#: ../../library/functions.rst:2260 +#: ../../library/functions.rst:2266 msgid "" "_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" "eggs = _temp.eggs\n" @@ -3769,36 +3781,36 @@ msgstr "" "eggs = _temp.eggs\n" "saus = _temp.sausage" -#: ../../library/functions.rst:2264 +#: ../../library/functions.rst:2270 msgid "" "Here, the ``spam.ham`` module is returned from :func:`__import__`. From " "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" -#: ../../library/functions.rst:2268 +#: ../../library/functions.rst:2274 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2271 +#: ../../library/functions.rst:2277 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "" -#: ../../library/functions.rst:2275 +#: ../../library/functions.rst:2281 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" -#: ../../library/functions.rst:2280 +#: ../../library/functions.rst:2286 msgid "Footnotes" msgstr "註解" -#: ../../library/functions.rst:2281 +#: ../../library/functions.rst:2287 msgid "" "Note that the parser only accepts the Unix-style end of line convention. If " "you are reading the code from a file, make sure to use newline conversion " @@ -3811,7 +3823,7 @@ msgstr "" msgid "Boolean" msgstr "Boolean(布林值)" -#: ../../library/functions.rst:154 ../../library/functions.rst:2048 +#: ../../library/functions.rst:154 ../../library/functions.rst:2054 msgid "type" msgstr "type(型別)" @@ -3835,7 +3847,7 @@ msgstr "Infinity(無窮)" msgid "__format__" msgstr "__format__" -#: ../../library/functions.rst:814 ../../library/functions.rst:1925 +#: ../../library/functions.rst:814 ../../library/functions.rst:1931 msgid "string" msgstr "string(字串)" @@ -3887,7 +3899,7 @@ msgstr "buffering(緩衝)" msgid "text mode" msgstr "text mode(文字模式)" -#: ../../library/functions.rst:1507 ../../library/functions.rst:2209 +#: ../../library/functions.rst:1507 ../../library/functions.rst:2215 msgid "module" msgstr "module(模組)" @@ -3895,22 +3907,22 @@ msgstr "module(模組)" msgid "sys" msgstr "sys" -#: ../../library/functions.rst:1925 +#: ../../library/functions.rst:1931 msgid "str() (built-in function)" msgstr "str() (內建函式)" -#: ../../library/functions.rst:2048 +#: ../../library/functions.rst:2054 msgid "object" msgstr "object(物件)" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2215 msgid "statement" msgstr "statement(陳述式)" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2215 msgid "import" msgstr "import(引入)" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2215 msgid "builtins" msgstr "builtins(內建)" diff --git a/library/locale.po b/library/locale.po index edd5415af8..afdb048b04 100644 --- a/library/locale.po +++ b/library/locale.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-22 00:14+0000\n" +"POT-Creation-Date: 2025-08-14 00:16+0000\n" "PO-Revision-Date: 2018-05-23 16:05+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -53,27 +53,33 @@ msgstr "" msgid "" "If *locale* is given and not ``None``, :func:`setlocale` modifies the locale " "setting for the *category*. The available categories are listed in the data " -"description below. *locale* may be a string, or an iterable of two strings " -"(language code and encoding). If it's an iterable, it's converted to a " -"locale name using the locale aliasing engine. An empty string specifies the " -"user's default settings. If the modification of the locale fails, the " -"exception :exc:`Error` is raised. If successful, the new locale setting is " -"returned." +"description below. *locale* may be a :ref:`string `, or a pair, " +"language code and encoding. An empty string specifies the user's default " +"settings. If the modification of the locale fails, the exception :exc:" +"`Error` is raised. If successful, the new locale setting is returned." +msgstr "" + +#: ../../library/locale.rst:42 +msgid "" +"If *locale* is a pair, it is converted to a locale name using the locale " +"aliasing engine. The language code has the same format as a :ref:`locale " +"name `, but without encoding and ``@``-modifier. The language " +"code and encoding can be ``None``." msgstr "" -#: ../../library/locale.rst:43 +#: ../../library/locale.rst:48 msgid "" "If *locale* is omitted or ``None``, the current setting for *category* is " "returned." msgstr "" -#: ../../library/locale.rst:46 +#: ../../library/locale.rst:51 msgid "" ":func:`setlocale` is not thread-safe on most systems. Applications typically " "start with a call of ::" msgstr "" -#: ../../library/locale.rst:49 +#: ../../library/locale.rst:54 msgid "" "import locale\n" "locale.setlocale(locale.LC_ALL, '')" @@ -81,7 +87,7 @@ msgstr "" "import locale\n" "locale.setlocale(locale.LC_ALL, '')" -#: ../../library/locale.rst:52 +#: ../../library/locale.rst:57 msgid "" "This sets the locale for all categories to the user's default setting " "(typically specified in the :envvar:`LANG` environment variable). If the " @@ -89,41 +95,41 @@ msgid "" "problems." msgstr "" -#: ../../library/locale.rst:59 +#: ../../library/locale.rst:64 msgid "" "Returns the database of the local conventions as a dictionary. This " "dictionary has the following strings as keys:" msgstr "" -#: ../../library/locale.rst:65 +#: ../../library/locale.rst:70 msgid "Category" msgstr "分類" -#: ../../library/locale.rst:65 +#: ../../library/locale.rst:70 msgid "Key" msgstr "" -#: ../../library/locale.rst:65 +#: ../../library/locale.rst:70 msgid "Meaning" msgstr "含義" -#: ../../library/locale.rst:67 +#: ../../library/locale.rst:72 msgid ":const:`LC_NUMERIC`" msgstr ":const:`LC_NUMERIC`" -#: ../../library/locale.rst:67 +#: ../../library/locale.rst:72 msgid "``'decimal_point'``" msgstr "``'decimal_point'``" -#: ../../library/locale.rst:67 +#: ../../library/locale.rst:72 msgid "Decimal point character." msgstr "" -#: ../../library/locale.rst:69 +#: ../../library/locale.rst:74 msgid "``'grouping'``" msgstr "``'grouping'``" -#: ../../library/locale.rst:69 +#: ../../library/locale.rst:74 msgid "" "Sequence of numbers specifying which relative positions the " "``'thousands_sep'`` is expected. If the sequence is terminated with :const:" @@ -131,204 +137,204 @@ msgid "" "with a ``0``, the last group size is repeatedly used." msgstr "" -#: ../../library/locale.rst:80 +#: ../../library/locale.rst:85 msgid "``'thousands_sep'``" msgstr "``'thousands_sep'``" -#: ../../library/locale.rst:80 +#: ../../library/locale.rst:85 msgid "Character used between groups." msgstr "" -#: ../../library/locale.rst:82 +#: ../../library/locale.rst:87 msgid ":const:`LC_MONETARY`" msgstr ":const:`LC_MONETARY`" -#: ../../library/locale.rst:82 +#: ../../library/locale.rst:87 msgid "``'int_curr_symbol'``" msgstr "``'int_curr_symbol'``" -#: ../../library/locale.rst:82 +#: ../../library/locale.rst:87 msgid "International currency symbol." msgstr "" -#: ../../library/locale.rst:84 +#: ../../library/locale.rst:89 msgid "``'currency_symbol'``" msgstr "``'currency_symbol'``" -#: ../../library/locale.rst:84 +#: ../../library/locale.rst:89 msgid "Local currency symbol." msgstr "" -#: ../../library/locale.rst:86 +#: ../../library/locale.rst:91 msgid "``'p_cs_precedes/n_cs_precedes'``" msgstr "``'p_cs_precedes/n_cs_precedes'``" -#: ../../library/locale.rst:86 +#: ../../library/locale.rst:91 msgid "" "Whether the currency symbol precedes the value (for positive resp. negative " "values)." msgstr "" -#: ../../library/locale.rst:91 +#: ../../library/locale.rst:96 msgid "``'p_sep_by_space/n_sep_by_space'``" msgstr "``'p_sep_by_space/n_sep_by_space'``" -#: ../../library/locale.rst:91 +#: ../../library/locale.rst:96 msgid "" "Whether the currency symbol is separated from the value by a space (for " "positive resp. negative values)." msgstr "" -#: ../../library/locale.rst:96 +#: ../../library/locale.rst:101 msgid "``'mon_decimal_point'``" msgstr "``'mon_decimal_point'``" -#: ../../library/locale.rst:96 +#: ../../library/locale.rst:101 msgid "Decimal point used for monetary values." msgstr "" -#: ../../library/locale.rst:99 +#: ../../library/locale.rst:104 msgid "``'frac_digits'``" msgstr "``'frac_digits'``" -#: ../../library/locale.rst:99 +#: ../../library/locale.rst:104 msgid "" "Number of fractional digits used in local formatting of monetary values." msgstr "" -#: ../../library/locale.rst:103 +#: ../../library/locale.rst:108 msgid "``'int_frac_digits'``" msgstr "``'int_frac_digits'``" -#: ../../library/locale.rst:103 +#: ../../library/locale.rst:108 msgid "" "Number of fractional digits used in international formatting of monetary " "values." msgstr "" -#: ../../library/locale.rst:107 +#: ../../library/locale.rst:112 msgid "``'mon_thousands_sep'``" msgstr "``'mon_thousands_sep'``" -#: ../../library/locale.rst:107 +#: ../../library/locale.rst:112 msgid "Group separator used for monetary values." msgstr "" -#: ../../library/locale.rst:110 +#: ../../library/locale.rst:115 msgid "``'mon_grouping'``" msgstr "``'mon_grouping'``" -#: ../../library/locale.rst:110 +#: ../../library/locale.rst:115 msgid "Equivalent to ``'grouping'``, used for monetary values." msgstr "" -#: ../../library/locale.rst:113 +#: ../../library/locale.rst:118 msgid "``'positive_sign'``" msgstr "``'positive_sign'``" -#: ../../library/locale.rst:113 +#: ../../library/locale.rst:118 msgid "Symbol used to annotate a positive monetary value." msgstr "" -#: ../../library/locale.rst:116 +#: ../../library/locale.rst:121 msgid "``'negative_sign'``" msgstr "``'negative_sign'``" -#: ../../library/locale.rst:116 +#: ../../library/locale.rst:121 msgid "Symbol used to annotate a negative monetary value." msgstr "" -#: ../../library/locale.rst:119 +#: ../../library/locale.rst:124 msgid "``'p_sign_posn/n_sign_posn'``" msgstr "``'p_sign_posn/n_sign_posn'``" -#: ../../library/locale.rst:119 +#: ../../library/locale.rst:124 msgid "" "The position of the sign (for positive resp. negative values), see below." msgstr "" -#: ../../library/locale.rst:124 +#: ../../library/locale.rst:129 msgid "" "All numeric values can be set to :const:`CHAR_MAX` to indicate that there is " "no value specified in this locale." msgstr "" -#: ../../library/locale.rst:127 +#: ../../library/locale.rst:132 msgid "" "The possible values for ``'p_sign_posn'`` and ``'n_sign_posn'`` are given " "below." msgstr "" -#: ../../library/locale.rst:130 +#: ../../library/locale.rst:135 msgid "Value" msgstr "" -#: ../../library/locale.rst:130 +#: ../../library/locale.rst:135 msgid "Explanation" msgstr "" -#: ../../library/locale.rst:132 +#: ../../library/locale.rst:137 msgid "``0``" msgstr "``0``" -#: ../../library/locale.rst:132 +#: ../../library/locale.rst:137 msgid "Currency and value are surrounded by parentheses." msgstr "" -#: ../../library/locale.rst:135 +#: ../../library/locale.rst:140 msgid "``1``" msgstr "``1``" -#: ../../library/locale.rst:135 +#: ../../library/locale.rst:140 msgid "The sign should precede the value and currency symbol." msgstr "" -#: ../../library/locale.rst:138 +#: ../../library/locale.rst:143 msgid "``2``" msgstr "``2``" -#: ../../library/locale.rst:138 +#: ../../library/locale.rst:143 msgid "The sign should follow the value and currency symbol." msgstr "" -#: ../../library/locale.rst:141 +#: ../../library/locale.rst:146 msgid "``3``" msgstr "``3``" -#: ../../library/locale.rst:141 +#: ../../library/locale.rst:146 msgid "The sign should immediately precede the value." msgstr "" -#: ../../library/locale.rst:144 +#: ../../library/locale.rst:149 msgid "``4``" msgstr "``4``" -#: ../../library/locale.rst:144 +#: ../../library/locale.rst:149 msgid "The sign should immediately follow the value." msgstr "" -#: ../../library/locale.rst:147 +#: ../../library/locale.rst:152 msgid "``CHAR_MAX``" msgstr "``CHAR_MAX``" -#: ../../library/locale.rst:147 +#: ../../library/locale.rst:152 msgid "Nothing is specified in this locale." msgstr "" -#: ../../library/locale.rst:150 +#: ../../library/locale.rst:155 msgid "" "The function temporarily sets the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` " "locale or the ``LC_MONETARY`` locale if locales are different and numeric or " "monetary strings are non-ASCII. This temporary change affects other threads." msgstr "" -#: ../../library/locale.rst:154 +#: ../../library/locale.rst:159 msgid "" "The function now temporarily sets the ``LC_CTYPE`` locale to the " "``LC_NUMERIC`` locale in some cases." msgstr "" -#: ../../library/locale.rst:161 +#: ../../library/locale.rst:166 msgid "" "Return some locale-specific information as a string. This function is not " "available on all systems, and the set of possible options might also vary " @@ -336,106 +342,106 @@ msgid "" "symbolic constants are available in the locale module." msgstr "" -#: ../../library/locale.rst:166 +#: ../../library/locale.rst:171 msgid "" "The :func:`nl_langinfo` function accepts one of the following keys. Most " "descriptions are taken from the corresponding description in the GNU C " "library." msgstr "" -#: ../../library/locale.rst:172 +#: ../../library/locale.rst:177 msgid "" "Get a string with the name of the character encoding used in the selected " "locale." msgstr "" -#: ../../library/locale.rst:177 +#: ../../library/locale.rst:182 msgid "" "Get a string that can be used as a format string for :func:`time.strftime` " "to represent date and time in a locale-specific way." msgstr "" -#: ../../library/locale.rst:182 +#: ../../library/locale.rst:187 msgid "" "Get a string that can be used as a format string for :func:`time.strftime` " "to represent a date in a locale-specific way." msgstr "" -#: ../../library/locale.rst:187 +#: ../../library/locale.rst:192 msgid "" "Get a string that can be used as a format string for :func:`time.strftime` " "to represent a time in a locale-specific way." msgstr "" -#: ../../library/locale.rst:192 +#: ../../library/locale.rst:197 msgid "" "Get a format string for :func:`time.strftime` to represent time in the am/pm " "format." msgstr "" -#: ../../library/locale.rst:203 +#: ../../library/locale.rst:208 msgid "Get the name of the n-th day of the week." msgstr "" -#: ../../library/locale.rst:207 +#: ../../library/locale.rst:212 msgid "" "This follows the US convention of :const:`DAY_1` being Sunday, not the " "international convention (ISO 8601) that Monday is the first day of the week." msgstr "" -#: ../../library/locale.rst:219 +#: ../../library/locale.rst:224 msgid "Get the abbreviated name of the n-th day of the week." msgstr "" -#: ../../library/locale.rst:234 +#: ../../library/locale.rst:239 msgid "Get the name of the n-th month." msgstr "" -#: ../../library/locale.rst:249 +#: ../../library/locale.rst:254 msgid "Get the abbreviated name of the n-th month." msgstr "" -#: ../../library/locale.rst:253 +#: ../../library/locale.rst:258 msgid "Get the radix character (decimal dot, decimal comma, etc.)." msgstr "" -#: ../../library/locale.rst:257 +#: ../../library/locale.rst:262 msgid "Get the separator character for thousands (groups of three digits)." msgstr "" -#: ../../library/locale.rst:261 +#: ../../library/locale.rst:266 msgid "" "Get a regular expression that can be used with the regex function to " "recognize a positive response to a yes/no question." msgstr "" -#: ../../library/locale.rst:266 +#: ../../library/locale.rst:271 msgid "" "Get a regular expression that can be used with the ``regex(3)`` function to " "recognize a negative response to a yes/no question." msgstr "" -#: ../../library/locale.rst:271 +#: ../../library/locale.rst:276 msgid "" "The regular expressions for :const:`YESEXPR` and :const:`NOEXPR` use syntax " "suitable for the ``regex`` function from the C library, which might differ " "from the syntax used in :mod:`re`." msgstr "" -#: ../../library/locale.rst:278 +#: ../../library/locale.rst:283 msgid "" "Get the currency symbol, preceded by \"-\" if the symbol should appear " "before the value, \"+\" if the symbol should appear after the value, or \"." "\" if the symbol should replace the radix character." msgstr "" -#: ../../library/locale.rst:284 +#: ../../library/locale.rst:289 msgid "" "Get a string which describes how years are counted and displayed for each " "era in a locale." msgstr "" -#: ../../library/locale.rst:287 +#: ../../library/locale.rst:292 msgid "" "Most locales do not define this value. An example of a locale which does " "define this value is the Japanese one. In Japan, the traditional " @@ -443,7 +449,7 @@ msgid "" "then-emperor's reign." msgstr "" -#: ../../library/locale.rst:292 +#: ../../library/locale.rst:297 msgid "" "Normally it should not be necessary to use this value directly. Specifying " "the ``E`` modifier in their format strings causes the :func:`time.strftime` " @@ -453,38 +459,38 @@ msgid "" "onlinepubs/9799919799/basedefs/V1_chap07.html#tag_07_03_05_02>`_." msgstr "" -#: ../../library/locale.rst:301 +#: ../../library/locale.rst:306 msgid "" "Get a format string for :func:`time.strftime` to represent date and time in " "a locale-specific era-based way." msgstr "" -#: ../../library/locale.rst:306 +#: ../../library/locale.rst:311 msgid "" "Get a format string for :func:`time.strftime` to represent a date in a " "locale-specific era-based way." msgstr "" -#: ../../library/locale.rst:311 +#: ../../library/locale.rst:316 msgid "" "Get a format string for :func:`time.strftime` to represent a time in a " "locale-specific era-based way." msgstr "" -#: ../../library/locale.rst:316 +#: ../../library/locale.rst:321 msgid "" "Get a string consisting of up to 100 semicolon-separated symbols used to " "represent the values 0 to 99 in a locale-specific way. In most locales this " "is an empty string." msgstr "" -#: ../../library/locale.rst:323 +#: ../../library/locale.rst:328 msgid "" "Tries to determine the default locale settings and returns them as a tuple " "of the form ``(language code, encoding)``." msgstr "" -#: ../../library/locale.rst:326 +#: ../../library/locale.rst:331 msgid "" "According to POSIX, a program which has not called ``setlocale(LC_ALL, '')`` " "runs using the portable ``'C'`` locale. Calling ``setlocale(LC_ALL, '')`` " @@ -493,7 +499,7 @@ msgid "" "emulate the behavior in the way described above." msgstr "" -#: ../../library/locale.rst:332 +#: ../../library/locale.rst:337 msgid "" "To maintain compatibility with other platforms, not only the :envvar:`LANG` " "variable is tested, but a list of variables given as envvars parameter. The " @@ -503,21 +509,23 @@ msgid "" "``'LC_CTYPE'``, ``'LANG'`` and ``'LANGUAGE'``, in that order." msgstr "" -#: ../../library/locale.rst:339 ../../library/locale.rst:352 +#: ../../library/locale.rst:344 ../../library/locale.rst:359 msgid "" -"Except for the code ``'C'``, the language code corresponds to :rfc:`1766`. " -"*language code* and *encoding* may be ``None`` if their values cannot be " -"determined." +"The language code has the same format as a :ref:`locale name `, " +"but without encoding and ``@``-modifier. The language code and encoding may " +"be ``None`` if their values cannot be determined. The \"C\" locale is " +"represented as ``(None, None)``." msgstr "" -#: ../../library/locale.rst:348 +#: ../../library/locale.rst:355 msgid "" -"Returns the current setting for the given locale category as sequence " -"containing *language code*, *encoding*. *category* may be one of the :const:" -"`!LC_\\*` values except :const:`LC_ALL`. It defaults to :const:`LC_CTYPE`." +"Returns the current setting for the given locale category as a tuple " +"containing the language code and encoding. *category* may be one of the :" +"const:`!LC_\\*` values except :const:`LC_ALL`. It defaults to :const:" +"`LC_CTYPE`." msgstr "" -#: ../../library/locale.rst:359 +#: ../../library/locale.rst:368 msgid "" "Return the :term:`locale encoding` used for text data, according to user " "preferences. User preferences are expressed differently on different " @@ -525,72 +533,72 @@ msgid "" "this function only returns a guess." msgstr "" -#: ../../library/locale.rst:364 +#: ../../library/locale.rst:373 msgid "" "On some systems, it is necessary to invoke :func:`setlocale` to obtain the " "user preferences, so this function is not thread-safe. If invoking setlocale " "is not necessary or desired, *do_setlocale* should be set to ``False``." msgstr "" -#: ../../library/locale.rst:368 +#: ../../library/locale.rst:377 msgid "" "On Android or if the :ref:`Python UTF-8 Mode ` is enabled, always " "return ``'utf-8'``, the :term:`locale encoding` and the *do_setlocale* " "argument are ignored." msgstr "" -#: ../../library/locale.rst:372 ../../library/locale.rst:390 +#: ../../library/locale.rst:381 ../../library/locale.rst:399 msgid "" "The :ref:`Python preinitialization ` configures the LC_CTYPE " "locale. See also the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../library/locale.rst:375 +#: ../../library/locale.rst:384 msgid "" "The function now always returns ``\"utf-8\"`` on Android or if the :ref:" "`Python UTF-8 Mode ` is enabled." msgstr "" -#: ../../library/locale.rst:382 +#: ../../library/locale.rst:391 msgid "Get the current :term:`locale encoding`:" msgstr "" -#: ../../library/locale.rst:384 +#: ../../library/locale.rst:393 msgid "On Android and VxWorks, return ``\"utf-8\"``." msgstr "" -#: ../../library/locale.rst:385 +#: ../../library/locale.rst:394 msgid "" "On Unix, return the encoding of the current :data:`LC_CTYPE` locale. Return " "``\"utf-8\"`` if ``nl_langinfo(CODESET)`` returns an empty string: for " "example, if the current LC_CTYPE locale is not supported." msgstr "" -#: ../../library/locale.rst:388 +#: ../../library/locale.rst:397 msgid "On Windows, return the ANSI code page." msgstr "" -#: ../../library/locale.rst:393 +#: ../../library/locale.rst:402 msgid "" "This function is similar to :func:`getpreferredencoding(False) " "` except this function ignores the :ref:`Python UTF-8 " "Mode `." msgstr "" -#: ../../library/locale.rst:402 +#: ../../library/locale.rst:411 msgid "" "Returns a normalized locale code for the given locale name. The returned " "locale code is formatted for use with :func:`setlocale`. If normalization " "fails, the original name is returned unchanged." msgstr "" -#: ../../library/locale.rst:406 +#: ../../library/locale.rst:415 msgid "" "If the given encoding is not known, the function defaults to the default " "encoding for the locale code just like :func:`setlocale`." msgstr "" -#: ../../library/locale.rst:412 +#: ../../library/locale.rst:421 msgid "" "Compares two strings according to the current :const:`LC_COLLATE` setting. " "As any other compare function, returns a negative, or a positive value, or " @@ -598,7 +606,7 @@ msgid "" "is equal to it." msgstr "" -#: ../../library/locale.rst:420 +#: ../../library/locale.rst:429 msgid "" "Transforms a string to one that can be used in locale-aware comparisons. " "For example, ``strxfrm(s1) < strxfrm(s2)`` is equivalent to ``strcoll(s1, " @@ -606,7 +614,7 @@ msgid "" "repeatedly, e.g. when collating a sequence of strings." msgstr "" -#: ../../library/locale.rst:429 +#: ../../library/locale.rst:438 msgid "" "Formats a number *val* according to the current :const:`LC_NUMERIC` setting. " "The format follows the conventions of the ``%`` operator. For floating-" @@ -614,29 +622,29 @@ msgid "" "is ``True``, also takes the grouping into account." msgstr "" -#: ../../library/locale.rst:434 +#: ../../library/locale.rst:443 msgid "" "If *monetary* is true, the conversion uses monetary thousands separator and " "grouping strings." msgstr "" -#: ../../library/locale.rst:437 +#: ../../library/locale.rst:446 msgid "" "Processes formatting specifiers as in ``format % val``, but takes the " "current locale settings into account." msgstr "" -#: ../../library/locale.rst:440 +#: ../../library/locale.rst:449 msgid "The *monetary* keyword parameter was added." msgstr "" -#: ../../library/locale.rst:446 +#: ../../library/locale.rst:455 msgid "" "Formats a number *val* according to the current :const:`LC_MONETARY` " "settings." msgstr "" -#: ../../library/locale.rst:448 +#: ../../library/locale.rst:457 msgid "" "The returned string includes the currency symbol if *symbol* is true, which " "is the default. If *grouping* is ``True`` (which is not the default), " @@ -644,43 +652,43 @@ msgid "" "not the default), the international currency symbol is used." msgstr "" -#: ../../library/locale.rst:455 +#: ../../library/locale.rst:464 msgid "" "This function will not work with the 'C' locale, so you have to set a locale " "via :func:`setlocale` first." msgstr "" -#: ../../library/locale.rst:461 +#: ../../library/locale.rst:470 msgid "" "Formats a floating-point number using the same format as the built-in " "function ``str(float)``, but takes the decimal point into account." msgstr "" -#: ../../library/locale.rst:467 +#: ../../library/locale.rst:476 msgid "" "Converts a string into a normalized number string, following the :const:" "`LC_NUMERIC` settings." msgstr "" -#: ../../library/locale.rst:475 +#: ../../library/locale.rst:484 msgid "" "Converts a normalized number string into a formatted string following the :" "const:`LC_NUMERIC` settings." msgstr "" -#: ../../library/locale.rst:483 +#: ../../library/locale.rst:492 msgid "" "Converts a string to a number, following the :const:`LC_NUMERIC` settings, " "by calling *func* on the result of calling :func:`delocalize` on *string*." msgstr "" -#: ../../library/locale.rst:489 +#: ../../library/locale.rst:498 msgid "" "Converts a string to an integer, following the :const:`LC_NUMERIC` " "conventions." msgstr "" -#: ../../library/locale.rst:494 +#: ../../library/locale.rst:503 msgid "" "Locale category for the character type functions. Most importantly, this " "category defines the text encoding, i.e. how bytes are interpreted as " @@ -690,32 +698,32 @@ msgid "" "SSH connections." msgstr "" -#: ../../library/locale.rst:501 +#: ../../library/locale.rst:510 msgid "" "Python doesn't internally use locale-dependent character transformation " "functions from ``ctype.h``. Instead, an internal ``pyctype.h`` provides " "locale-independent equivalents like :c:macro:`!Py_TOLOWER`." msgstr "" -#: ../../library/locale.rst:508 +#: ../../library/locale.rst:517 msgid "" "Locale category for sorting strings. The functions :func:`strcoll` and :" "func:`strxfrm` of the :mod:`locale` module are affected." msgstr "" -#: ../../library/locale.rst:514 +#: ../../library/locale.rst:523 msgid "" "Locale category for the formatting of time. The function :func:`time." "strftime` follows these conventions." msgstr "" -#: ../../library/locale.rst:520 +#: ../../library/locale.rst:529 msgid "" "Locale category for formatting of monetary values. The available options " "are available from the :func:`localeconv` function." msgstr "" -#: ../../library/locale.rst:526 +#: ../../library/locale.rst:535 msgid "" "Locale category for message display. Python currently does not support " "application specific locale-aware messages. Messages displayed by the " @@ -723,13 +731,13 @@ msgid "" "affected by this category." msgstr "" -#: ../../library/locale.rst:531 +#: ../../library/locale.rst:540 msgid "" "This value may not be available on operating systems not conforming to the " "POSIX standard, most notably Windows." msgstr "" -#: ../../library/locale.rst:537 +#: ../../library/locale.rst:546 msgid "" "Locale category for formatting numbers. The functions :func:" "`format_string`, :func:`atoi`, :func:`atof` and :func:`.str` of the :mod:" @@ -737,7 +745,7 @@ msgid "" "operations are not affected." msgstr "" -#: ../../library/locale.rst:545 +#: ../../library/locale.rst:554 msgid "" "Combination of all locale settings. If this flag is used when the locale is " "changed, setting the locale for all categories is attempted. If that fails " @@ -747,17 +755,17 @@ msgid "" "settings." msgstr "" -#: ../../library/locale.rst:554 +#: ../../library/locale.rst:563 msgid "" "This is a symbolic constant used for different values returned by :func:" "`localeconv`." msgstr "" -#: ../../library/locale.rst:558 +#: ../../library/locale.rst:567 msgid "Example::" msgstr "範例: ::" -#: ../../library/locale.rst:560 +#: ../../library/locale.rst:569 msgid "" ">>> import locale\n" ">>> loc = locale.getlocale() # get current locale\n" @@ -770,11 +778,11 @@ msgid "" ">>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale" msgstr "" -#: ../../library/locale.rst:571 +#: ../../library/locale.rst:580 msgid "Background, details, hints, tips and caveats" msgstr "" -#: ../../library/locale.rst:573 +#: ../../library/locale.rst:582 msgid "" "The C standard defines the locale as a program-wide property that may be " "relatively expensive to change. On top of that, some implementations are " @@ -782,7 +790,7 @@ msgid "" "This makes the locale somewhat painful to use correctly." msgstr "" -#: ../../library/locale.rst:578 +#: ../../library/locale.rst:587 msgid "" "Initially, when a program is started, the locale is the ``C`` locale, no " "matter what the user's preferred locale is. There is one exception: the :" @@ -792,7 +800,7 @@ msgid "" "categories by calling ``setlocale(LC_ALL, '')``." msgstr "" -#: ../../library/locale.rst:585 +#: ../../library/locale.rst:594 msgid "" "It is generally a bad idea to call :func:`setlocale` in some library " "routine, since as a side effect it affects the entire program. Saving and " @@ -800,7 +808,7 @@ msgid "" "that happen to run before the settings have been restored." msgstr "" -#: ../../library/locale.rst:590 +#: ../../library/locale.rst:599 msgid "" "If, when coding a module for general use, you need a locale independent " "version of an operation that is affected by the locale (such as certain " @@ -811,14 +819,14 @@ msgid "" "settings." msgstr "" -#: ../../library/locale.rst:597 +#: ../../library/locale.rst:606 msgid "" "The only way to perform numeric operations according to the locale is to use " "the special functions defined by this module: :func:`atof`, :func:`atoi`, :" "func:`format_string`, :func:`.str`." msgstr "" -#: ../../library/locale.rst:601 +#: ../../library/locale.rst:610 msgid "" "There is no way to perform case conversions and character classifications " "according to the locale. For (Unicode) text strings these are done " @@ -829,11 +837,85 @@ msgid "" "whitespace." msgstr "" -#: ../../library/locale.rst:612 +#: ../../library/locale.rst:621 +msgid "Locale names" +msgstr "" + +#: ../../library/locale.rst:623 +msgid "" +"The format of the locale name is platform dependent, and the set of " +"supported locales can depend on the system configuration." +msgstr "" + +#: ../../library/locale.rst:626 +msgid "On Posix platforms, it usually has the format [1]_:" +msgstr "" + +#: ../../library/locale.rst:631 +msgid "" +"where *language* is a two- or three-letter language code from `ISO 639`_, " +"*territory* is a two-letter country or region code from `ISO 3166`_, " +"*charset* is a locale encoding, and *modifier* is a script name, a language " +"subtag, a sort order identifier, or other locale modifier (for example, " +"\"latin\", \"valencia\", \"stroke\" and \"euro\")." +msgstr "" + +#: ../../library/locale.rst:637 +msgid "" +"On Windows, several formats are supported. [2]_ [3]_ A subset of `IETF BCP " +"47`_ tags:" +msgstr "" + +#: ../../library/locale.rst:644 +msgid "" +"where *language* and *territory* have the same meaning as in Posix, *script* " +"is a four-letter script code from `ISO 15924`_, and *modifier* is a language " +"subtag, a sort order identifier or custom modifier (for example, " +"\"valencia\", \"stroke\" or \"x-python\"). Both hyphen (``'-'``) and " +"underscore (``'_'``) separators are supported. Only UTF-8 encoding is " +"allowed for BCP 47 tags." +msgstr "" + +#: ../../library/locale.rst:651 +msgid "Windows also supports locale names in the format:" +msgstr "" + +#: ../../library/locale.rst:656 +msgid "" +"where *language* and *territory* are full names, such as \"English\" and " +"\"United States\", and *charset* is either a code page number (for example, " +"\"1252\") or UTF-8. Only the underscore separator is supported in this " +"format." +msgstr "" + +#: ../../library/locale.rst:661 +msgid "The \"C\" locale is supported on all platforms." +msgstr "" + +#: ../../library/locale.rst:668 +msgid "" +"`IEEE Std 1003.1-2024; 8.2 Internationalization Variables `_" +msgstr "" + +#: ../../library/locale.rst:669 +msgid "" +"`UCRT Locale names, Languages, and Country/Region strings `_" +msgstr "" + +#: ../../library/locale.rst:670 +msgid "" +"`Locale Names `_" +msgstr "" + +#: ../../library/locale.rst:676 msgid "For extension writers and programs that embed Python" msgstr "" -#: ../../library/locale.rst:614 +#: ../../library/locale.rst:678 msgid "" "Extension modules should never call :func:`setlocale`, except to find out " "what the current locale is. But since the return value can only be used " @@ -841,7 +923,7 @@ msgid "" "whether or not the locale is ``C``)." msgstr "" -#: ../../library/locale.rst:619 +#: ../../library/locale.rst:683 msgid "" "When Python code uses the :mod:`locale` module to change the locale, this " "also affects the embedding application. If the embedding application " @@ -851,11 +933,11 @@ msgid "" "accessible as a shared library." msgstr "" -#: ../../library/locale.rst:630 +#: ../../library/locale.rst:694 msgid "Access to message catalogs" msgstr "" -#: ../../library/locale.rst:639 +#: ../../library/locale.rst:703 msgid "" "The locale module exposes the C library's gettext interface on systems that " "provide this interface. It consists of the functions :func:`gettext`, :func:" @@ -866,7 +948,7 @@ msgid "" "locating message catalogs." msgstr "" -#: ../../library/locale.rst:646 +#: ../../library/locale.rst:710 msgid "" "Python applications should normally find no need to invoke these functions, " "and should use :mod:`gettext` instead. A known exception to this rule are "