From f3042a1d39c8de168eb5805d7941a69cbaa09409 Mon Sep 17 00:00:00 2001 From: "pydoc-zh-tw[bot]" <90344106+pydoc-zh-tw[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 00:04:07 +0800 Subject: [PATCH] Sync with CPython 3.13 (#1008) Co-authored-by: github-actions[bot] Co-authored-by: W. H. Wang --- c-api/object.po | 181 ++-- faq/library.po | 2 +- faq/programming.po | 11 +- howto/argparse-optparse.po | 122 ++- howto/argparse.po | 315 +++---- howto/free-threading-python.po | 23 +- howto/functional.po | 42 +- howto/perf_profiling.po | 2 +- howto/sorting.po | 2 +- library/_thread.po | 2 +- library/argparse.po | 865 ++++++++++--------- library/asyncio-eventloop.po | 4 +- library/cmdlinelibs.po | 32 + library/csv.po | 2 +- library/enum.po | 423 +++++----- library/filesys.po | 17 +- library/getopt.po | 144 +++- library/io.po | 2 +- library/itertools.po | 513 ++++++----- library/json.po | 2 +- library/optparse.po | 1455 ++++++++++++++++++++------------ library/os.path.po | 4 +- library/pickle.po | 76 +- library/random.po | 2 +- library/ssl.po | 11 +- library/superseded.po | 34 +- library/timeit.po | 2 +- library/tty.po | 4 +- library/unittest.po | 81 +- reference/compound_stmts.po | 810 +++++++++--------- tutorial/index.po | 2 +- whatsnew/3.10.po | 4 +- whatsnew/3.12.po | 108 ++- whatsnew/3.13.po | 950 +++++++++++---------- whatsnew/3.4.po | 2 +- whatsnew/3.5.po | 2 +- whatsnew/3.6.po | 2 +- whatsnew/3.7.po | 2 +- whatsnew/3.9.po | 2 +- 39 files changed, 3548 insertions(+), 2711 deletions(-) create mode 100644 library/cmdlinelibs.po diff --git a/c-api/object.po b/c-api/object.po index 5898ca290c..a2be5438c2 100644 --- a/c-api/object.po +++ b/c-api/object.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-14 00:14+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2018-05-23 14:32+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,15 +36,15 @@ msgstr "" #: ../../c-api/object.rst:20 msgid "Constant Identifier" -msgstr "" +msgstr "常數識別字" #: ../../c-api/object.rst:20 msgid "Value" -msgstr "" +msgstr "數值" #: ../../c-api/object.rst:20 msgid "Returned object" -msgstr "" +msgstr "回傳物件" #: ../../c-api/object.rst:22 ../../c-api/object.rst:27 msgid "``0``" @@ -126,7 +126,7 @@ msgstr "" #: ../../c-api/object.rst:42 msgid "In CPython, all of these constants are :term:`immortal`." -msgstr "" +msgstr "在 CPython 中,所有這些常數都是\\ :term:`不滅 `\\ 的。" #: ../../c-api/object.rst:47 msgid "" @@ -196,19 +196,20 @@ msgstr "" #: ../../c-api/object.rst:113 msgid "" "Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" -"`~object.__getattribute__` methods are silently ignored. For proper error " -"handling, use :c:func:`PyObject_HasAttrWithError`, :c:func:" -"`PyObject_GetOptionalAttr` or :c:func:`PyObject_GetAttr` instead." +"`~object.__getattribute__` methods aren't propagated, but instead given to :" +"func:`sys.unraisablehook`. For proper error handling, use :c:func:" +"`PyObject_HasAttrWithError`, :c:func:`PyObject_GetOptionalAttr` or :c:func:" +"`PyObject_GetAttr` instead." msgstr "" -#: ../../c-api/object.rst:121 +#: ../../c-api/object.rst:122 msgid "" "This is the same as :c:func:`PyObject_HasAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:127 +#: ../../c-api/object.rst:128 msgid "" "Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" "`~object.__getattribute__` methods or while creating the temporary :class:" @@ -217,39 +218,39 @@ msgid "" "or :c:func:`PyObject_GetAttrString` instead." msgstr "" -#: ../../c-api/object.rst:137 +#: ../../c-api/object.rst:138 msgid "" "Retrieve an attribute named *attr_name* from object *o*. Returns the " "attribute value on success, or ``NULL`` on failure. This is the equivalent " "of the Python expression ``o.attr_name``." msgstr "" -#: ../../c-api/object.rst:141 +#: ../../c-api/object.rst:142 msgid "" "If the missing attribute should not be treated as a failure, you can use :c:" "func:`PyObject_GetOptionalAttr` instead." msgstr "" -#: ../../c-api/object.rst:147 +#: ../../c-api/object.rst:148 msgid "" "This is the same as :c:func:`PyObject_GetAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:151 +#: ../../c-api/object.rst:152 msgid "" "If the missing attribute should not be treated as a failure, you can use :c:" "func:`PyObject_GetOptionalAttrString` instead." msgstr "" -#: ../../c-api/object.rst:157 +#: ../../c-api/object.rst:158 msgid "" "Variant of :c:func:`PyObject_GetAttr` which doesn't raise :exc:" "`AttributeError` if the attribute is not found." msgstr "" -#: ../../c-api/object.rst:160 +#: ../../c-api/object.rst:161 msgid "" "If the attribute is found, return ``1`` and set *\\*result* to a new :term:" "`strong reference` to the attribute. If the attribute is not found, return " @@ -258,14 +259,14 @@ msgid "" "``-1`` and set *\\*result* to ``NULL``." msgstr "" -#: ../../c-api/object.rst:172 +#: ../../c-api/object.rst:173 msgid "" "This is the same as :c:func:`PyObject_GetOptionalAttr`, but *attr_name* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:180 +#: ../../c-api/object.rst:181 msgid "" "Generic attribute getter function that is meant to be put into a type " "object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary " @@ -275,34 +276,34 @@ msgid "" "descriptors don't. Otherwise, an :exc:`AttributeError` is raised." msgstr "" -#: ../../c-api/object.rst:190 +#: ../../c-api/object.rst:191 msgid "" "Set the value of the attribute named *attr_name*, for object *o*, to the " "value *v*. Raise an exception and return ``-1`` on failure; return ``0`` on " "success. This is the equivalent of the Python statement ``o.attr_name = v``." msgstr "" -#: ../../c-api/object.rst:195 +#: ../../c-api/object.rst:196 msgid "" "If *v* is ``NULL``, the attribute is deleted. This behaviour is deprecated " "in favour of using :c:func:`PyObject_DelAttr`, but there are currently no " "plans to remove it." msgstr "" -#: ../../c-api/object.rst:202 +#: ../../c-api/object.rst:203 msgid "" "This is the same as :c:func:`PyObject_SetAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:206 +#: ../../c-api/object.rst:207 msgid "" "If *v* is ``NULL``, the attribute is deleted, but this feature is deprecated " "in favour of using :c:func:`PyObject_DelAttrString`." msgstr "" -#: ../../c-api/object.rst:209 +#: ../../c-api/object.rst:210 msgid "" "The number of different attribute names passed to this function should be " "kept small, usually by using a statically allocated string as *attr_name*. " @@ -312,7 +313,7 @@ msgid "" "internally to create a key object." msgstr "" -#: ../../c-api/object.rst:219 +#: ../../c-api/object.rst:220 msgid "" "Generic attribute setter and deleter function that is meant to be put into a " "type object's :c:member:`~PyTypeObject.tp_setattro` slot. It looks for a " @@ -324,20 +325,20 @@ msgid "" "returned." msgstr "" -#: ../../c-api/object.rst:231 +#: ../../c-api/object.rst:232 msgid "" "Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on " "failure. This is the equivalent of the Python statement ``del o.attr_name``." msgstr "" -#: ../../c-api/object.rst:237 +#: ../../c-api/object.rst:238 msgid "" "This is the same as :c:func:`PyObject_DelAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:241 +#: ../../c-api/object.rst:242 msgid "" "The number of different attribute names passed to this function should be " "kept small, usually by using a statically allocated string as *attr_name*. " @@ -347,13 +348,13 @@ msgid "" "internally to create a key object for lookup." msgstr "" -#: ../../c-api/object.rst:252 +#: ../../c-api/object.rst:253 msgid "" "A generic implementation for the getter of a ``__dict__`` descriptor. It " "creates the dictionary if necessary." msgstr "" -#: ../../c-api/object.rst:255 +#: ../../c-api/object.rst:256 msgid "" "This function may also be called to get the :py:attr:`~object.__dict__` of " "the object *o*. Pass ``NULL`` for *context* when calling it. Since this " @@ -362,30 +363,30 @@ msgid "" "the object." msgstr "" -#: ../../c-api/object.rst:261 +#: ../../c-api/object.rst:262 msgid "On failure, returns ``NULL`` with an exception set." msgstr "在失敗時,會回傳 ``NULL`` 並設定例外。" -#: ../../c-api/object.rst:268 +#: ../../c-api/object.rst:269 msgid "" "A generic implementation for the setter of a ``__dict__`` descriptor. This " "implementation does not allow the dictionary to be deleted." msgstr "" -#: ../../c-api/object.rst:276 +#: ../../c-api/object.rst:277 msgid "" "Return a pointer to :py:attr:`~object.__dict__` of the object *obj*. If " "there is no ``__dict__``, return ``NULL`` without setting an exception." msgstr "" -#: ../../c-api/object.rst:279 +#: ../../c-api/object.rst:280 msgid "" "This function may need to allocate memory for the dictionary, so it may be " "more efficient to call :c:func:`PyObject_GetAttr` when accessing an " "attribute on the object." msgstr "" -#: ../../c-api/object.rst:286 +#: ../../c-api/object.rst:287 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "which must be one of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :" @@ -396,33 +397,33 @@ msgid "" "success, or ``NULL`` on failure." msgstr "" -#: ../../c-api/object.rst:296 +#: ../../c-api/object.rst:297 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "like :c:func:`PyObject_RichCompare`, but returns ``-1`` on error, ``0`` if " "the result is false, ``1`` otherwise." msgstr "" -#: ../../c-api/object.rst:301 +#: ../../c-api/object.rst:302 msgid "" "If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool` " "will always return ``1`` for :c:macro:`Py_EQ` and ``0`` for :c:macro:`Py_NE`." msgstr "" -#: ../../c-api/object.rst:306 +#: ../../c-api/object.rst:307 msgid "" "Format *obj* using *format_spec*. This is equivalent to the Python " "expression ``format(obj, format_spec)``." msgstr "" -#: ../../c-api/object.rst:309 +#: ../../c-api/object.rst:310 msgid "" "*format_spec* may be ``NULL``. In this case the call is equivalent to " "``format(obj)``. Returns the formatted string on success, ``NULL`` on " "failure." msgstr "" -#: ../../c-api/object.rst:317 +#: ../../c-api/object.rst:318 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -430,13 +431,13 @@ msgid "" "function." msgstr "" -#: ../../c-api/object.rst:321 ../../c-api/object.rst:345 +#: ../../c-api/object.rst:322 ../../c-api/object.rst:346 msgid "" "This function now includes a debug assertion to help ensure that it does not " "silently discard an active exception." msgstr "" -#: ../../c-api/object.rst:329 +#: ../../c-api/object.rst:330 msgid "" "As :c:func:`PyObject_Repr`, compute a string representation of object *o*, " "but escape the non-ASCII characters in the string returned by :c:func:" @@ -445,7 +446,7 @@ msgid "" "Called by the :func:`ascii` built-in function." msgstr "" -#: ../../c-api/object.rst:340 +#: ../../c-api/object.rst:341 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -453,7 +454,7 @@ msgid "" "function and, therefore, by the :func:`print` function." msgstr "" -#: ../../c-api/object.rst:354 +#: ../../c-api/object.rst:355 msgid "" "Compute a bytes representation of object *o*. ``NULL`` is returned on " "failure and a bytes object on success. This is equivalent to the Python " @@ -462,20 +463,20 @@ msgid "" "bytes object." msgstr "" -#: ../../c-api/object.rst:363 +#: ../../c-api/object.rst:364 msgid "" "Return ``1`` if the class *derived* is identical to or derived from the " "class *cls*, otherwise return ``0``. In case of an error, return ``-1``." msgstr "" -#: ../../c-api/object.rst:366 ../../c-api/object.rst:385 +#: ../../c-api/object.rst:367 ../../c-api/object.rst:386 msgid "" "If *cls* is a tuple, the check will be done against every entry in *cls*. " "The result will be ``1`` when at least one of the checks returns ``1``, " "otherwise it will be ``0``." msgstr "" -#: ../../c-api/object.rst:370 +#: ../../c-api/object.rst:371 msgid "" "If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " @@ -483,52 +484,52 @@ msgid "" "e. contained in :attr:`cls.__mro__ `." msgstr "" -#: ../../c-api/object.rst:375 +#: ../../c-api/object.rst:376 msgid "" "Normally only class objects, i.e. instances of :class:`type` or a derived " "class, are considered classes. However, objects can override this by having " "a :attr:`~type.__bases__` attribute (which must be a tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:382 +#: ../../c-api/object.rst:383 msgid "" "Return ``1`` if *inst* is an instance of the class *cls* or a subclass of " "*cls*, or ``0`` if not. On error, returns ``-1`` and sets an exception." msgstr "" -#: ../../c-api/object.rst:389 +#: ../../c-api/object.rst:390 msgid "" "If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " "*inst* is an instance of *cls* if its class is a subclass of *cls*." msgstr "" -#: ../../c-api/object.rst:393 +#: ../../c-api/object.rst:394 msgid "" "An instance *inst* can override what is considered its class by having a :" "attr:`~object.__class__` attribute." msgstr "" -#: ../../c-api/object.rst:396 +#: ../../c-api/object.rst:397 msgid "" "An object *cls* can override if it is considered a class, and what its base " "classes are, by having a :attr:`~type.__bases__` attribute (which must be a " "tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:405 +#: ../../c-api/object.rst:406 msgid "" "Compute and return the hash value of an object *o*. On failure, return " "``-1``. This is the equivalent of the Python expression ``hash(o)``." msgstr "" -#: ../../c-api/object.rst:408 +#: ../../c-api/object.rst:409 msgid "" "The return type is now Py_hash_t. This is a signed integer the same size " "as :c:type:`Py_ssize_t`." msgstr "" -#: ../../c-api/object.rst:415 +#: ../../c-api/object.rst:416 msgid "" "Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` " "and return ``-1``. This function receives special treatment when stored in a " @@ -536,21 +537,21 @@ msgid "" "that it is not hashable." msgstr "" -#: ../../c-api/object.rst:423 +#: ../../c-api/object.rst:424 msgid "" "Returns ``1`` if the object *o* is considered to be true, and ``0`` " "otherwise. This is equivalent to the Python expression ``not not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:430 +#: ../../c-api/object.rst:431 msgid "" "Returns ``0`` if the object *o* is considered to be true, and ``1`` " "otherwise. This is equivalent to the Python expression ``not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:439 +#: ../../c-api/object.rst:440 msgid "" "When *o* is non-``NULL``, returns a type object corresponding to the object " "type of object *o*. On failure, raises :exc:`SystemError` and returns " @@ -561,13 +562,13 @@ msgid "" "when a new :term:`strong reference` is needed." msgstr "" -#: ../../c-api/object.rst:451 +#: ../../c-api/object.rst:452 msgid "" "Return non-zero if the object *o* is of type *type* or a subtype of *type*, " "and ``0`` otherwise. Both parameters must be non-``NULL``." msgstr "" -#: ../../c-api/object.rst:460 +#: ../../c-api/object.rst:461 msgid "" "Return the length of object *o*. If the object *o* provides either the " "sequence and mapping protocols, the sequence length is returned. On error, " @@ -575,7 +576,7 @@ msgid "" "``len(o)``." msgstr "" -#: ../../c-api/object.rst:467 +#: ../../c-api/object.rst:468 msgid "" "Return an estimated length for the object *o*. First try to return its " "actual length, then an estimate using :meth:`~object.__length_hint__`, and " @@ -584,26 +585,26 @@ msgid "" "defaultvalue)``." msgstr "" -#: ../../c-api/object.rst:477 +#: ../../c-api/object.rst:478 msgid "" "Return element of *o* corresponding to the object *key* or ``NULL`` on " "failure. This is the equivalent of the Python expression ``o[key]``." msgstr "" -#: ../../c-api/object.rst:483 +#: ../../c-api/object.rst:484 msgid "" "Map the object *key* to the value *v*. Raise an exception and return ``-1`` " "on failure; return ``0`` on success. This is the equivalent of the Python " "statement ``o[key] = v``. This function *does not* steal a reference to *v*." msgstr "" -#: ../../c-api/object.rst:491 +#: ../../c-api/object.rst:492 msgid "" "Remove the mapping for the object *key* from the object *o*. Return ``-1`` " "on failure. This is equivalent to the Python statement ``del o[key]``." msgstr "" -#: ../../c-api/object.rst:497 +#: ../../c-api/object.rst:498 msgid "" "This is equivalent to the Python expression ``dir(o)``, returning a " "(possibly empty) list of strings appropriate for the object argument, or " @@ -613,7 +614,7 @@ msgid "" "`PyErr_Occurred` will return false." msgstr "" -#: ../../c-api/object.rst:506 +#: ../../c-api/object.rst:507 msgid "" "This is equivalent to the Python expression ``iter(o)``. It returns a new " "iterator for the object argument, or the object itself if the object is " @@ -621,14 +622,14 @@ msgid "" "object cannot be iterated." msgstr "" -#: ../../c-api/object.rst:514 +#: ../../c-api/object.rst:515 msgid "" "This is equivalent to the Python ``__iter__(self): return self`` method. It " "is intended for :term:`iterator` types, to be used in the :c:member:" "`PyTypeObject.tp_iter` slot." msgstr "" -#: ../../c-api/object.rst:520 +#: ../../c-api/object.rst:521 msgid "" "This is the equivalent to the Python expression ``aiter(o)``. Takes an :" "class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it. " @@ -637,104 +638,104 @@ msgid "" "``NULL`` if the object cannot be iterated." msgstr "" -#: ../../c-api/object.rst:530 +#: ../../c-api/object.rst:531 msgid "Get a pointer to subclass-specific data reserved for *cls*." msgstr "" -#: ../../c-api/object.rst:532 +#: ../../c-api/object.rst:533 msgid "" "The object *o* must be an instance of *cls*, and *cls* must have been " "created using negative :c:member:`PyType_Spec.basicsize`. Python does not " "check this." msgstr "" -#: ../../c-api/object.rst:536 +#: ../../c-api/object.rst:537 msgid "On error, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/object.rst:542 +#: ../../c-api/object.rst:543 msgid "" "Return the size of the instance memory space reserved for *cls*, i.e. the " "size of the memory :c:func:`PyObject_GetTypeData` returns." msgstr "" -#: ../../c-api/object.rst:545 +#: ../../c-api/object.rst:546 msgid "" "This may be larger than requested using :c:member:`-PyType_Spec.basicsize " "`; it is safe to use this larger size (e.g. with :c:" "func:`!memset`)." msgstr "" -#: ../../c-api/object.rst:548 +#: ../../c-api/object.rst:549 msgid "" "The type *cls* **must** have been created using negative :c:member:" "`PyType_Spec.basicsize`. Python does not check this." msgstr "" -#: ../../c-api/object.rst:552 +#: ../../c-api/object.rst:553 msgid "On error, set an exception and return a negative value." msgstr "" -#: ../../c-api/object.rst:558 +#: ../../c-api/object.rst:559 msgid "" "Get a pointer to per-item data for a class with :c:macro:" "`Py_TPFLAGS_ITEMS_AT_END`." msgstr "" -#: ../../c-api/object.rst:561 +#: ../../c-api/object.rst:562 msgid "" "On error, set an exception and return ``NULL``. :py:exc:`TypeError` is " "raised if *o* does not have :c:macro:`Py_TPFLAGS_ITEMS_AT_END` set." msgstr "" -#: ../../c-api/object.rst:569 +#: ../../c-api/object.rst:570 msgid "Visit the managed dictionary of *obj*." msgstr "" -#: ../../c-api/object.rst:571 ../../c-api/object.rst:580 +#: ../../c-api/object.rst:572 ../../c-api/object.rst:581 msgid "" "This function must only be called in a traverse function of the type which " "has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set." msgstr "" -#: ../../c-api/object.rst:578 +#: ../../c-api/object.rst:579 msgid "Clear the managed dictionary of *obj*." msgstr "" -#: ../../c-api/object.rst:315 ../../c-api/object.rst:327 -#: ../../c-api/object.rst:352 ../../c-api/object.rst:403 -#: ../../c-api/object.rst:437 ../../c-api/object.rst:458 +#: ../../c-api/object.rst:316 ../../c-api/object.rst:328 +#: ../../c-api/object.rst:353 ../../c-api/object.rst:404 +#: ../../c-api/object.rst:438 ../../c-api/object.rst:459 msgid "built-in function" msgstr "bulit-in function(內建函式)" -#: ../../c-api/object.rst:315 +#: ../../c-api/object.rst:316 msgid "repr" msgstr "repr" -#: ../../c-api/object.rst:327 +#: ../../c-api/object.rst:328 msgid "ascii" msgstr "ascii" -#: ../../c-api/object.rst:335 +#: ../../c-api/object.rst:336 msgid "string" msgstr "string(字串)" -#: ../../c-api/object.rst:335 +#: ../../c-api/object.rst:336 msgid "PyObject_Str (C function)" msgstr "PyObject_Str(C 函式)" -#: ../../c-api/object.rst:352 +#: ../../c-api/object.rst:353 msgid "bytes" msgstr "bytes(位元組)" -#: ../../c-api/object.rst:403 +#: ../../c-api/object.rst:404 msgid "hash" msgstr "hash(雜湊)" -#: ../../c-api/object.rst:437 +#: ../../c-api/object.rst:438 msgid "type" msgstr "type(型別)" -#: ../../c-api/object.rst:458 +#: ../../c-api/object.rst:459 msgid "len" msgstr "len" diff --git a/faq/library.po b/faq/library.po index 3a9a9e0094..648029c94e 100644 --- a/faq/library.po +++ b/faq/library.po @@ -1301,7 +1301,7 @@ msgstr "``uniform(a, b)`` 會選擇 [a, b) 範圍內的浮點數。" #: ../../faq/library.rst:805 msgid "" "``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution." -msgstr "``normalvariate(mean, sdev)`` 對常態(高斯)分佈進行採樣 (sample)。" +msgstr "``normalvariate(mean, sdev)`` 對常態(高斯)分佈進行取樣 (sample)。" #: ../../faq/library.rst:807 msgid "Some higher-level functions operate on sequences directly, such as:" diff --git a/faq/programming.po b/faq/programming.po index 3a4d4abfe8..1d9f44ebb3 100644 --- a/faq/programming.po +++ b/faq/programming.po @@ -4205,7 +4205,7 @@ msgid "" msgstr "" "模組可以透過查看預定義的全域變數 ``__name__`` 來找出自己的模組名稱。如果它的" "值為``'__main__'``,則該程式作為腳本運行。許多通常透過引入使用的模組還提供命" -"令行界面或自檢,只有在檢查 ``__name__`` 後才執行此程式碼: ::" +"令行介面或自檢,只有在檢查 ``__name__`` 後才執行此程式碼: ::" #: ../../faq/programming.rst:2134 msgid "" @@ -4216,11 +4216,16 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"def main():\n" +" print('Running test...')\n" +" ...\n" +"\n" +"if __name__ == '__main__':\n" +" main()" #: ../../faq/programming.rst:2143 -#, fuzzy msgid "How can I have modules that mutually import each other?" -msgstr "我怎樣才能擁有相互引入的模組?" +msgstr "要怎樣才能擁有相互引入的模組?" #: ../../faq/programming.rst:2145 msgid "Suppose you have the following modules:" diff --git a/howto/argparse-optparse.po b/howto/argparse-optparse.po index 39f928c87d..62fdf4ecdd 100644 --- a/howto/argparse-optparse.po +++ b/howto/argparse-optparse.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-09 00:13+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+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-" @@ -16,103 +16,151 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../../howto/argparse-optparse.rst:7 -msgid "Upgrading optparse code" -msgstr "升級 optparse 程式碼" +#: ../../howto/argparse-optparse.rst:8 +msgid "Migrating ``optparse`` code to ``argparse``" +msgstr "將 ``optparse`` 程式碼遷移到 ``argparse``" -#: ../../howto/argparse-optparse.rst:9 +#: ../../howto/argparse-optparse.rst:10 msgid "" -"Originally, the :mod:`argparse` module had attempted to maintain " -"compatibility with :mod:`optparse`. However, :mod:`optparse` was difficult " -"to extend transparently, particularly with the changes required to support " -"``nargs=`` specifiers and better usage messages. When most everything in :" -"mod:`optparse` had either been copy-pasted over or monkey-patched, it no " -"longer seemed practical to try to maintain the backwards compatibility." +"The :mod:`argparse` module offers several higher level features not natively " +"provided by the :mod:`optparse` module, including:" msgstr "" +":mod:`argparse` 模組提供了一些高階功能,這些功能在 :mod:`optparse` 模組中並未" +"原生提供,包括:" -#: ../../howto/argparse-optparse.rst:16 -msgid "" -"The :mod:`argparse` module improves on the :mod:`optparse` module in a " -"number of ways including:" -msgstr "" - -#: ../../howto/argparse-optparse.rst:19 +#: ../../howto/argparse-optparse.rst:13 msgid "Handling positional arguments." -msgstr "" +msgstr "處理位置引數。" -#: ../../howto/argparse-optparse.rst:20 +#: ../../howto/argparse-optparse.rst:14 msgid "Supporting subcommands." -msgstr "" +msgstr "支援子命令。" -#: ../../howto/argparse-optparse.rst:21 +#: ../../howto/argparse-optparse.rst:15 msgid "Allowing alternative option prefixes like ``+`` and ``/``." -msgstr "" +msgstr "允許替代選項前綴,如 ``+`` 和 ``/``。" -#: ../../howto/argparse-optparse.rst:22 +#: ../../howto/argparse-optparse.rst:16 msgid "Handling zero-or-more and one-or-more style arguments." msgstr "" +"處理零或多個 (zero-or-more) 和一個或多個 (and one-or-more) 樣式的引數。" -#: ../../howto/argparse-optparse.rst:23 +#: ../../howto/argparse-optparse.rst:17 msgid "Producing more informative usage messages." -msgstr "" +msgstr "產生更多資訊的使用訊息。" -#: ../../howto/argparse-optparse.rst:24 +#: ../../howto/argparse-optparse.rst:18 msgid "Providing a much simpler interface for custom ``type`` and ``action``." +msgstr "為自訂 ``type`` 和 ``action`` 提供了一個更簡單的介面。" + +#: ../../howto/argparse-optparse.rst:20 +msgid "" +"Originally, the :mod:`argparse` module attempted to maintain compatibility " +"with :mod:`optparse`. However, the fundamental design differences between " +"supporting declarative command line option processing (while leaving " +"positional argument processing to application code), and supporting both " +"named options and positional arguments in the declarative interface mean " +"that the API has diverged from that of ``optparse`` over time." +msgstr "" +"最初 :mod:`argparse` 模組試圖保持與 :mod:`optparse` 的相容性,但在基礎設計上" +"的存在差異 -- 支援宣告式 (declarative) 命令列選項處理 (同時將位置引數處理留給" +"應用程式的程式碼) 和在宣告式介面中支援命名選項 (named options) 和位置引數 -- " +"代表 API 隨著時間的推移已經與 ``optparse`` API 分歧。" + +#: ../../howto/argparse-optparse.rst:27 +msgid "" +"As described in :ref:`choosing-an-argument-parser`, applications that are " +"currently using :mod:`optparse` and are happy with the way it works can just " +"continue to use ``optparse``." +msgstr "" +"如 :ref:`choosing-an-argument-parser` 中所述,目前使用 :mod:`optparse` 並對其" +"運作方式滿意的應用程式可以繼續使用 ``optparse``。" + +#: ../../howto/argparse-optparse.rst:31 +msgid "" +"Application developers that are considering migrating should also review the " +"list of intrinsic behavioural differences described in that section before " +"deciding whether or not migration is desirable." msgstr "" +"在決定是否遷移之前,應用程式開發人員應該先檢閱該段落中描述的內在行為差異清" +"單,來決定是否值得遷移。" -#: ../../howto/argparse-optparse.rst:26 -msgid "A partial upgrade path from :mod:`optparse` to :mod:`argparse`:" +#: ../../howto/argparse-optparse.rst:35 +msgid "" +"For applications that do choose to migrate from :mod:`optparse` to :mod:" +"`argparse`, the following suggestions should be helpful:" msgstr "" +"對於選擇從 :mod:`optparse` 遷移到 :mod:`argparse` 的應用程式,以下建議應會有" +"所幫助:" -#: ../../howto/argparse-optparse.rst:28 +#: ../../howto/argparse-optparse.rst:38 msgid "" "Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:" "`ArgumentParser.add_argument` calls." msgstr "" +"將所有 :meth:`optparse.OptionParser.add_option` 呼叫替換為 :meth:" +"`ArgumentParser.add_argument` 呼叫。" -#: ../../howto/argparse-optparse.rst:31 +#: ../../howto/argparse-optparse.rst:41 msgid "" "Replace ``(options, args) = parser.parse_args()`` with ``args = parser." "parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls " "for the positional arguments. Keep in mind that what was previously called " "``options``, now in the :mod:`argparse` context is called ``args``." msgstr "" +"將 ``(options, args) = parser.parse_args()`` 替換為 ``args = parser." +"parse_args()``,並為位置引數新增額外的 :meth:`ArgumentParser.add_argument` 呼" +"叫。請記住,以前稱為 ``options`` 的東西,在 :mod:`argparse` 情境中現在稱為 " +"``args``。" -#: ../../howto/argparse-optparse.rst:36 +#: ../../howto/argparse-optparse.rst:46 msgid "" "Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :" "meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:" "`~ArgumentParser.parse_args`." msgstr "" +"使用 :meth:`~ArgumentParser.parse_intermixed_args` 來替換掉 :meth:`optparse." +"OptionParser.disable_interspersed_args`,而不是使用 :meth:`~ArgumentParser." +"parse_args`。" -#: ../../howto/argparse-optparse.rst:40 +#: ../../howto/argparse-optparse.rst:50 msgid "" "Replace callback actions and the ``callback_*`` keyword arguments with " "``type`` or ``action`` arguments." msgstr "" +"將回呼動作和 ``callback_*`` 關鍵字引數替換為 ``type`` 或 ``action`` 引數。" -#: ../../howto/argparse-optparse.rst:43 +#: ../../howto/argparse-optparse.rst:53 msgid "" "Replace string names for ``type`` keyword arguments with the corresponding " "type objects (e.g. int, float, complex, etc)." msgstr "" +"將 ``type`` 關鍵字引數的字串名稱替換為相應的類型物件 (例如 int、float、" +"complex 等)。" -#: ../../howto/argparse-optparse.rst:46 +#: ../../howto/argparse-optparse.rst:56 msgid "" "Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse." "OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`." msgstr "" +"將 :class:`optparse.Values` 替換為 :class:`Namespace`,並將 :exc:`optparse." +"OptionError` 和 :exc:`optparse.OptionValueError` 替換為 :exc:" +"`ArgumentError`。" -#: ../../howto/argparse-optparse.rst:50 +#: ../../howto/argparse-optparse.rst:60 msgid "" "Replace strings with implicit arguments such as ``%default`` or ``%prog`` " "with the standard Python syntax to use dictionaries to format strings, that " "is, ``%(default)s`` and ``%(prog)s``." msgstr "" +"將隱式引數的字串,如 ``%default`` 或 ``%prog`` 替換為使用字典來格式化字串的標" +"準 Python 語法,即 ``%(default)s`` 和 ``%(prog)s``。" -#: ../../howto/argparse-optparse.rst:54 +#: ../../howto/argparse-optparse.rst:64 msgid "" "Replace the OptionParser constructor ``version`` argument with a call to " "``parser.add_argument('--version', action='version', version='')``." msgstr "" +"將 OptionParser 建構函式的 ``version`` 引數替換為呼叫 ``parser." +"add_argument('--version', action='version', version='')``。" diff --git a/howto/argparse.po b/howto/argparse.po index c71d110388..323727fd39 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-18 00:14+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2023-12-11 17:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -46,27 +46,36 @@ msgstr "" #: ../../howto/argparse.rst:16 msgid "" -"There are two other modules that fulfill the same task, namely :mod:`getopt` " -"(an equivalent for ``getopt()`` from the C language) and the deprecated :mod:" -"`optparse`. Note also that :mod:`argparse` is based on :mod:`optparse`, and " -"therefore very similar in terms of usage." -msgstr "" -"另外還有兩個模組可以完成相同的任務,即 :mod:`getopt`\\ (相當於 C 語言中的 " -"``getopt()``)和已棄用的 :mod:`optparse`。另請注意,:mod:`argparse` 是基於 :" -"mod:`optparse` 的,因此在用法上非常相似。" +"The standard library includes two other libraries directly related to " +"command-line parameter processing: the lower level :mod:`optparse` module " +"(which may require more code to configure for a given application, but also " +"allows an application to request behaviors that ``argparse`` doesn't " +"support), and the very low level :mod:`getopt` (which specifically serves as " +"an equivalent to the :c:func:`!getopt` family of functions available to C " +"programmers). While neither of those modules is covered directly in this " +"guide, many of the core concepts in ``argparse`` first originated in " +"``optparse``, so some aspects of this tutorial will also be relevant to " +"``optparse`` users." +msgstr "" +"標準函式庫包含另外兩個與命令列參數處理直接相關的函式庫:較低階的 :mod:" +"`optparse` 模組(可能需要更多程式碼來為給定應用程式設定,但也允許應用程式要" +"求 ``argparse`` 不支援的行為),以及非常低階的 :mod:`getopt`\\ (專門用作 C " +"程式設計師可用的 :c:func:`!getopt` 函式系列的等價)。雖然這個指南並未直接涵蓋" +"這些模組,但 ``argparse`` 的許多核心概念最初來自於 ``optparse``,因此本教學的" +"某些部分也適用於 ``optparse`` 使用者。" -#: ../../howto/argparse.rst:24 +#: ../../howto/argparse.rst:29 msgid "Concepts" msgstr "概念" -#: ../../howto/argparse.rst:26 +#: ../../howto/argparse.rst:31 msgid "" "Let's show the sort of functionality that we are going to explore in this " "introductory tutorial by making use of the :command:`ls` command:" msgstr "" "讓我們透過使用 :command:`ls` 指令來展示我們將在本介紹教學中探索的功能類型:" -#: ../../howto/argparse.rst:29 +#: ../../howto/argparse.rst:34 msgid "" "$ ls\n" "cpython devguide prog.py pypy rm-unused-function.patch\n" @@ -102,11 +111,11 @@ msgstr "" "Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n" "..." -#: ../../howto/argparse.rst:48 +#: ../../howto/argparse.rst:53 msgid "A few concepts we can learn from the four commands:" msgstr "我們可以從這四個命令中學到一些概念:" -#: ../../howto/argparse.rst:50 +#: ../../howto/argparse.rst:55 msgid "" "The :command:`ls` command is useful when run without any options at all. It " "defaults to displaying the contents of the current directory." @@ -114,7 +123,7 @@ msgstr "" ":command:`ls` 命令即便在沒有任何選項的情況下執行仍非常有用。它預設顯示目前目" "錄的內容。" -#: ../../howto/argparse.rst:53 +#: ../../howto/argparse.rst:58 msgid "" "If we want beyond what it provides by default, we tell it a bit more. In " "this case, we want it to display a different directory, ``pypy``. What we " @@ -131,7 +140,7 @@ msgstr "" "command:`cp` 這樣的指令更相關,其最基本的用法是 ``cp SRC DEST``。第一個是\\ *" "你想要複製的位置*,第二個是\\ *你想要複製過去的位置*。" -#: ../../howto/argparse.rst:62 +#: ../../howto/argparse.rst:67 msgid "" "Now, say we want to change behaviour of the program. In our example, we " "display more info for each file instead of just showing the file names. The " @@ -140,7 +149,7 @@ msgstr "" "現在假設我們想要改變程式的行為。在我們的範例中,我們顯示每個檔案的更多資訊," "而不僅是顯示檔案名稱。在這種情況下,``-l`` 被稱為可選引數。" -#: ../../howto/argparse.rst:66 +#: ../../howto/argparse.rst:71 msgid "" "That's a snippet of the help text. It's very useful in that you can come " "across a program you have never used before, and can figure out how it works " @@ -149,15 +158,15 @@ msgstr "" "這是幫助文字的片段。它非常有用,因為當你遇到以前從未使用過的程式時,只需閱讀" "其幫助文字即可了解它的工作原理。" -#: ../../howto/argparse.rst:72 +#: ../../howto/argparse.rst:77 msgid "The basics" msgstr "基本用法" -#: ../../howto/argparse.rst:74 +#: ../../howto/argparse.rst:79 msgid "Let us start with a very simple example which does (almost) nothing::" msgstr "讓我們從一個非常簡單的例子開始,它(幾乎)什麼都不做: ::" -#: ../../howto/argparse.rst:76 +#: ../../howto/argparse.rst:81 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -167,12 +176,12 @@ msgstr "" "parser = argparse.ArgumentParser()\n" "parser.parse_args()" -#: ../../howto/argparse.rst:80 ../../howto/argparse.rst:188 -#: ../../howto/argparse.rst:209 +#: ../../howto/argparse.rst:85 ../../howto/argparse.rst:193 +#: ../../howto/argparse.rst:214 msgid "Following is a result of running the code:" msgstr "程式碼執行結果如下:" -#: ../../howto/argparse.rst:82 +#: ../../howto/argparse.rst:87 msgid "" "$ python prog.py\n" "$ python prog.py --help\n" @@ -200,18 +209,18 @@ msgstr "" "usage: prog.py [-h]\n" "prog.py: error: unrecognized arguments: foo" -#: ../../howto/argparse.rst:97 ../../howto/argparse.rst:254 -#: ../../howto/argparse.rst:298 +#: ../../howto/argparse.rst:102 ../../howto/argparse.rst:259 +#: ../../howto/argparse.rst:303 msgid "Here is what is happening:" msgstr "這是發生的事情:" -#: ../../howto/argparse.rst:99 +#: ../../howto/argparse.rst:104 msgid "" "Running the script without any options results in nothing displayed to " "stdout. Not so useful." msgstr "執行不帶任何選項的腳本不會在標準輸出中顯示任何內容。不太有用。" -#: ../../howto/argparse.rst:102 +#: ../../howto/argparse.rst:107 msgid "" "The second one starts to display the usefulness of the :mod:`argparse` " "module. We have done almost nothing, but already we get a nice help message." @@ -219,7 +228,7 @@ msgstr "" "第二個開始能夠顯現 :mod:`argparse` 模組的有用之處。我們幾乎什麼也沒做,但我們" "已經收到了一個很好的幫助訊息。" -#: ../../howto/argparse.rst:105 +#: ../../howto/argparse.rst:110 msgid "" "The ``--help`` option, which can also be shortened to ``-h``, is the only " "option we get for free (i.e. no need to specify it). Specifying anything " @@ -230,15 +239,15 @@ msgstr "" "它)。指定任何其他內容都會導致錯誤。但即便如此,我們也還是輕鬆地獲得了有用的" "使用資訊。" -#: ../../howto/argparse.rst:112 +#: ../../howto/argparse.rst:117 msgid "Introducing Positional arguments" msgstr "位置引數的介紹" -#: ../../howto/argparse.rst:114 +#: ../../howto/argparse.rst:119 msgid "An example::" msgstr "例如: ::" -#: ../../howto/argparse.rst:116 +#: ../../howto/argparse.rst:121 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -252,11 +261,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:122 +#: ../../howto/argparse.rst:127 msgid "And running the code:" msgstr "執行這段程式碼:" -#: ../../howto/argparse.rst:124 +#: ../../howto/argparse.rst:129 msgid "" "$ python prog.py\n" "usage: prog.py [-h] echo\n" @@ -286,11 +295,11 @@ msgstr "" "$ python prog.py foo\n" "foo" -#: ../../howto/argparse.rst:140 +#: ../../howto/argparse.rst:145 msgid "Here is what's happening:" msgstr "這是會發生的事情:" -#: ../../howto/argparse.rst:142 +#: ../../howto/argparse.rst:147 msgid "" "We've added the :meth:`~ArgumentParser.add_argument` method, which is what " "we use to specify which command-line options the program is willing to " @@ -300,11 +309,11 @@ msgstr "" "我們新增了 :meth:`~ArgumentParser.add_argument` 方法,我們用它來指定程式願意" "接受哪些命令列選項。在本例中,我將其命名為 ``echo``,以便與其功能一致。" -#: ../../howto/argparse.rst:146 +#: ../../howto/argparse.rst:151 msgid "Calling our program now requires us to specify an option." msgstr "現在呼叫我們的程式時需要指定一個選項。" -#: ../../howto/argparse.rst:148 +#: ../../howto/argparse.rst:153 msgid "" "The :meth:`~ArgumentParser.parse_args` method actually returns some data " "from the options specified, in this case, ``echo``." @@ -312,7 +321,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法實際上從指定的選項中回傳一些資料,在本" "例中為 ``echo``。" -#: ../../howto/argparse.rst:151 +#: ../../howto/argparse.rst:156 msgid "" "The variable is some form of 'magic' that :mod:`argparse` performs for free " "(i.e. no need to specify which variable that value is stored in). You will " @@ -322,7 +331,7 @@ msgstr "" "該變數是某種形式的「魔法」,:mod:`argparse` 可以自由執行(即無需指定該值儲存" "在哪個變數中)。你還會注意到,它的名稱與提供給方法 ``echo`` 的字串引數相符。" -#: ../../howto/argparse.rst:156 +#: ../../howto/argparse.rst:161 msgid "" "Note however that, although the help display looks nice and all, it " "currently is not as helpful as it can be. For example we see that we got " @@ -334,7 +343,7 @@ msgstr "" "看到 ``echo`` 作為位置引數,但除了猜測或閱讀原始程式碼之外,我們不知道它的作" "用。那麼,我們來讓它變得更有用一點: ::" -#: ../../howto/argparse.rst:161 +#: ../../howto/argparse.rst:166 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -348,11 +357,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:167 +#: ../../howto/argparse.rst:172 msgid "And we get:" msgstr "然後我們得到:" -#: ../../howto/argparse.rst:169 +#: ../../howto/argparse.rst:174 msgid "" "$ python prog.py -h\n" "usage: prog.py [-h] echo\n" @@ -372,11 +381,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../howto/argparse.rst:180 +#: ../../howto/argparse.rst:185 msgid "Now, how about doing something even more useful::" msgstr "現在來做一些更有用處的事情: ::" -#: ../../howto/argparse.rst:182 +#: ../../howto/argparse.rst:187 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -392,7 +401,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:190 +#: ../../howto/argparse.rst:195 msgid "" "$ python prog.py 4\n" "Traceback (most recent call last):\n" @@ -406,7 +415,7 @@ msgstr "" " print(args.square**2)\n" "TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'" -#: ../../howto/argparse.rst:198 +#: ../../howto/argparse.rst:203 msgid "" "That didn't go so well. That's because :mod:`argparse` treats the options we " "give it as strings, unless we tell it otherwise. So, let's tell :mod:" @@ -415,7 +424,7 @@ msgstr "" "進展不太順利。這是因為,除非我們另有說明,:mod:`argparse` 會將我們給它的選項" "視為字串。因此,讓我們告訴 :mod:`argparse` 將該輸入視為整數: ::" -#: ../../howto/argparse.rst:202 +#: ../../howto/argparse.rst:207 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -433,7 +442,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:211 +#: ../../howto/argparse.rst:216 msgid "" "$ python prog.py 4\n" "16\n" @@ -447,23 +456,23 @@ msgstr "" "usage: prog.py [-h] square\n" "prog.py: error: argument square: invalid int value: 'four'" -#: ../../howto/argparse.rst:219 +#: ../../howto/argparse.rst:224 msgid "" "That went well. The program now even helpfully quits on bad illegal input " "before proceeding." msgstr "順利進展。現在該程式甚至可以在繼續操作之前因錯誤的非法輸入而退出。" -#: ../../howto/argparse.rst:224 +#: ../../howto/argparse.rst:229 msgid "Introducing Optional arguments" msgstr "可選引數的介紹" -#: ../../howto/argparse.rst:226 +#: ../../howto/argparse.rst:231 msgid "" "So far we have been playing with positional arguments. Let us have a look on " "how to add optional ones::" msgstr "到目前為止,我們一直在討論位置引數。我們來看看如何新增可選引數: ::" -#: ../../howto/argparse.rst:229 +#: ../../howto/argparse.rst:234 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -479,12 +488,12 @@ msgstr "" "if args.verbosity:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:236 ../../howto/argparse.rst:282 -#: ../../howto/argparse.rst:398 ../../howto/argparse.rst:432 +#: ../../howto/argparse.rst:241 ../../howto/argparse.rst:287 +#: ../../howto/argparse.rst:403 ../../howto/argparse.rst:437 msgid "And the output:" msgstr "接者是結果:" -#: ../../howto/argparse.rst:238 +#: ../../howto/argparse.rst:243 msgid "" "$ python prog.py --verbosity 1\n" "verbosity turned on\n" @@ -514,7 +523,7 @@ msgstr "" "usage: prog.py [-h] [--verbosity VERBOSITY]\n" "prog.py: error: argument --verbosity: expected one argument" -#: ../../howto/argparse.rst:256 +#: ../../howto/argparse.rst:261 msgid "" "The program is written so as to display something when ``--verbosity`` is " "specified and display nothing when not." @@ -522,7 +531,7 @@ msgstr "" "程式被編寫為在指定 ``--verbosity`` 時顯示一些內容,並在未指定時不顯示任何內" "容。" -#: ../../howto/argparse.rst:259 +#: ../../howto/argparse.rst:264 msgid "" "To show that the option is actually optional, there is no error when running " "the program without it. Note that by default, if an optional argument isn't " @@ -534,17 +543,17 @@ msgstr "" "情況下,如果未使用可選引數,則相關變數(在本例中為 ``args.verbosity``)將被賦" "予 ``None`` 作為值,這就是它未能通過 :keyword:`if` 陳述式真值測試的原因。" -#: ../../howto/argparse.rst:265 +#: ../../howto/argparse.rst:270 msgid "The help message is a bit different." msgstr "幫助訊息有點不同。" -#: ../../howto/argparse.rst:267 +#: ../../howto/argparse.rst:272 msgid "" "When using the ``--verbosity`` option, one must also specify some value, any " "value." msgstr "當使用 ``--verbosity`` 選項時必須要指定一些值,任何值都可以。" -#: ../../howto/argparse.rst:270 +#: ../../howto/argparse.rst:275 msgid "" "The above example accepts arbitrary integer values for ``--verbosity``, but " "for our simple program, only two values are actually useful, ``True`` or " @@ -553,7 +562,7 @@ msgstr "" "在上面的例子中,``--verbosity`` 接受任意的整數,但對我們的程式來說只接受兩個" "輸入值, ``True`` 或 ``False``。所以我們來修改一下程式碼使其符合: ::" -#: ../../howto/argparse.rst:274 +#: ../../howto/argparse.rst:279 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -571,7 +580,7 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:284 +#: ../../howto/argparse.rst:289 msgid "" "$ python prog.py --verbose\n" "verbosity turned on\n" @@ -597,7 +606,7 @@ msgstr "" " -h, --help show this help message and exit\n" " --verbose increase output verbosity" -#: ../../howto/argparse.rst:300 +#: ../../howto/argparse.rst:305 msgid "" "The option is now more of a flag than something that requires a value. We " "even changed the name of the option to match that idea. Note that we now " @@ -610,21 +619,21 @@ msgstr "" "``\"store_true\"``。這意味著,如果指定了該選項,則將值 ``True`` 指派給 " "``args.verbose``。不指定它代表為 ``False``。" -#: ../../howto/argparse.rst:307 +#: ../../howto/argparse.rst:312 msgid "" "It complains when you specify a value, in true spirit of what flags actually " "are." msgstr "當你指定一個值時,它會本著旗標的實際精神來抱怨。" -#: ../../howto/argparse.rst:310 +#: ../../howto/argparse.rst:315 msgid "Notice the different help text." msgstr "請注意不同的幫助文字。" -#: ../../howto/argparse.rst:314 +#: ../../howto/argparse.rst:319 msgid "Short options" msgstr "短選項" -#: ../../howto/argparse.rst:316 +#: ../../howto/argparse.rst:321 msgid "" "If you are familiar with command line usage, you will notice that I haven't " "yet touched on the topic of short versions of the options. It's quite " @@ -632,7 +641,7 @@ msgid "" msgstr "" "如果你熟悉命令列用法,你會注意到我尚未提及選項的簡短版本。這很簡單: ::" -#: ../../howto/argparse.rst:320 +#: ../../howto/argparse.rst:325 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -652,11 +661,11 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:328 +#: ../../howto/argparse.rst:333 msgid "And here goes:" msgstr "而這為:" -#: ../../howto/argparse.rst:330 +#: ../../howto/argparse.rst:335 msgid "" "$ python prog.py -v\n" "verbosity turned on\n" @@ -676,19 +685,19 @@ msgstr "" " -h, --help show this help message and exit\n" " -v, --verbose increase output verbosity" -#: ../../howto/argparse.rst:341 +#: ../../howto/argparse.rst:346 msgid "Note that the new ability is also reflected in the help text." msgstr "請注意,新功能也反映在幫助文字中。" -#: ../../howto/argparse.rst:345 +#: ../../howto/argparse.rst:350 msgid "Combining Positional and Optional arguments" msgstr "組合位置引數和可選引數" -#: ../../howto/argparse.rst:347 +#: ../../howto/argparse.rst:352 msgid "Our program keeps growing in complexity::" msgstr "我們的程式的複雜性不斷增加: ::" -#: ../../howto/argparse.rst:349 +#: ../../howto/argparse.rst:354 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -716,11 +725,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:362 +#: ../../howto/argparse.rst:367 msgid "And now the output:" msgstr "然後現在的輸出結果:" -#: ../../howto/argparse.rst:364 +#: ../../howto/argparse.rst:369 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] square\n" @@ -742,15 +751,15 @@ msgstr "" "$ python prog.py --verbose 4\n" "the square of 4 equals 16" -#: ../../howto/argparse.rst:376 +#: ../../howto/argparse.rst:381 msgid "We've brought back a positional argument, hence the complaint." msgstr "我們帶回了位置引數,因而被抱怨。" -#: ../../howto/argparse.rst:378 +#: ../../howto/argparse.rst:383 msgid "Note that the order does not matter." msgstr "請注意,順序並不重要。" -#: ../../howto/argparse.rst:380 +#: ../../howto/argparse.rst:385 msgid "" "How about we give this program of ours back the ability to have multiple " "verbosity values, and actually get to use them::" @@ -758,7 +767,7 @@ msgstr "" "我們讓這個程式擁有多個訊息詳細級別 (verbosity) 之值的能力,並實際使用它" "們: ::" -#: ../../howto/argparse.rst:383 +#: ../../howto/argparse.rst:388 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -790,7 +799,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:400 +#: ../../howto/argparse.rst:405 msgid "" "$ python prog.py 4\n" "16\n" @@ -816,7 +825,7 @@ msgstr "" "$ python prog.py 4 -v 3\n" "16" -#: ../../howto/argparse.rst:414 +#: ../../howto/argparse.rst:419 msgid "" "These all look good except the last one, which exposes a bug in our program. " "Let's fix it by restricting the values the ``--verbosity`` option can " @@ -825,7 +834,7 @@ msgstr "" "除了最後一個外都看起來正常,它透露了我們程式中的一個錯誤。我們可透過限制 ``--" "verbosity`` 選項可以接受的值來修復它: ::" -#: ../../howto/argparse.rst:417 +#: ../../howto/argparse.rst:422 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -857,7 +866,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:434 +#: ../../howto/argparse.rst:439 msgid "" "$ python prog.py 4 -v 3\n" "usage: prog.py [-h] [-v {0,1,2}] square\n" @@ -889,13 +898,13 @@ msgstr "" " -v, --verbosity {0,1,2}\n" " increase output verbosity" -#: ../../howto/argparse.rst:450 +#: ../../howto/argparse.rst:455 msgid "" "Note that the change also reflects both in the error message as well as the " "help string." msgstr "請注意,更改也會反映在錯誤訊息和幫助字串中。" -#: ../../howto/argparse.rst:453 +#: ../../howto/argparse.rst:458 msgid "" "Now, let's use a different approach of playing with verbosity, which is " "pretty common. It also matches the way the CPython executable handles its " @@ -904,7 +913,7 @@ msgstr "" "現在,讓我們使用另一種常見方法來玩玩訊息詳細級別。它也與 CPython 執行檔處理其" "自身訊息詳細級別引數的方式相符(請見 ``python --help`` 的輸出): ::" -#: ../../howto/argparse.rst:457 +#: ../../howto/argparse.rst:462 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -936,13 +945,13 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:472 +#: ../../howto/argparse.rst:477 msgid "" "We have introduced another action, \"count\", to count the number of " "occurrences of specific options." msgstr "我們已經介紹過另一個操作 \"count\" 用來計算指定的選項出現的次數。" -#: ../../howto/argparse.rst:476 +#: ../../howto/argparse.rst:481 msgid "" "$ python prog.py 4\n" "16\n" @@ -990,7 +999,7 @@ msgstr "" "$ python prog.py 4 -vvv\n" "16" -#: ../../howto/argparse.rst:501 +#: ../../howto/argparse.rst:506 msgid "" "Yes, it's now more of a flag (similar to ``action=\"store_true\"``) in the " "previous version of our script. That should explain the complaint." @@ -998,29 +1007,29 @@ msgstr "" "是的,現在它更像是我們上一版腳本中的旗標(類似於 " "``action=\"store_true\"``),這應該可以解釋抱怨的原因。" -#: ../../howto/argparse.rst:504 +#: ../../howto/argparse.rst:509 msgid "It also behaves similar to \"store_true\" action." msgstr "它的行為也類似 \"store_true\" 操作。" -#: ../../howto/argparse.rst:506 +#: ../../howto/argparse.rst:511 msgid "" "Now here's a demonstration of what the \"count\" action gives. You've " "probably seen this sort of usage before." msgstr "現在這裡示範了 \"count\" 動作的作用。你可能以前見過這種用法。" -#: ../../howto/argparse.rst:509 +#: ../../howto/argparse.rst:514 msgid "" "And if you don't specify the ``-v`` flag, that flag is considered to have " "``None`` value." msgstr "如果你不指定 ``-v`` 旗標,則該旗標被視為具有 ``None`` 值。" -#: ../../howto/argparse.rst:512 +#: ../../howto/argparse.rst:517 msgid "" "As should be expected, specifying the long form of the flag, we should get " "the same output." msgstr "正如預期的那樣,指定長形式旗標,我們應該得到相同的輸出。" -#: ../../howto/argparse.rst:515 +#: ../../howto/argparse.rst:520 msgid "" "Sadly, our help output isn't very informative on the new ability our script " "has acquired, but that can always be fixed by improving the documentation " @@ -1029,15 +1038,15 @@ msgstr "" "遺憾的是,我們的幫助輸出對於我們腳本獲得的新功能並沒有提供太多資訊,但我們都" "可以透過改進腳本的文件來解決這個問題(例如:透過 ``help`` 關鍵字引數)。" -#: ../../howto/argparse.rst:519 +#: ../../howto/argparse.rst:524 msgid "That last output exposes a bug in our program." msgstr "最後的輸出透露了我們程式中的一個錯誤。" -#: ../../howto/argparse.rst:522 +#: ../../howto/argparse.rst:527 msgid "Let's fix::" msgstr "讓我們來解決問題: ::" -#: ../../howto/argparse.rst:524 +#: ../../howto/argparse.rst:529 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1073,11 +1082,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:541 +#: ../../howto/argparse.rst:546 msgid "And this is what it gives:" msgstr "這就是它給出的:" -#: ../../howto/argparse.rst:543 +#: ../../howto/argparse.rst:548 msgid "" "$ python prog.py 4 -vvv\n" "the square of 4 equals 16\n" @@ -1099,7 +1108,7 @@ msgstr "" " if args.verbosity >= 2:\n" "TypeError: '>=' not supported between instances of 'NoneType' and 'int'" -#: ../../howto/argparse.rst:556 +#: ../../howto/argparse.rst:561 msgid "" "First output went well, and fixes the bug we had before. That is, we want " "any value >= 2 to be as verbose as possible." @@ -1107,15 +1116,15 @@ msgstr "" "第一次輸出順利進行,並修復了我們之前遇到的錯誤。也就是說,我們希望任何 >= 2 " "的值都盡可能詳細。" -#: ../../howto/argparse.rst:559 +#: ../../howto/argparse.rst:564 msgid "Third output not so good." msgstr "第三個輸出不太好。" -#: ../../howto/argparse.rst:561 +#: ../../howto/argparse.rst:566 msgid "Let's fix that bug::" msgstr "我們來修復這個錯誤: ::" -#: ../../howto/argparse.rst:563 +#: ../../howto/argparse.rst:568 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1147,7 +1156,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:578 +#: ../../howto/argparse.rst:583 msgid "" "We've just introduced yet another keyword, ``default``. We've set it to " "``0`` in order to make it comparable to the other int values. Remember that " @@ -1159,11 +1168,11 @@ msgstr "" "int 值進行比較。請記住,預設情況下,如果未指定可選引數,它將獲得 ``None`` " "值,並且不能與 int 值進行比較(因此會出現 :exc:`TypeError` 例外)。" -#: ../../howto/argparse.rst:585 +#: ../../howto/argparse.rst:590 msgid "And:" msgstr "而且:" -#: ../../howto/argparse.rst:587 +#: ../../howto/argparse.rst:592 msgid "" "$ python prog.py 4\n" "16" @@ -1171,7 +1180,7 @@ msgstr "" "$ python prog.py 4\n" "16" -#: ../../howto/argparse.rst:592 +#: ../../howto/argparse.rst:597 msgid "" "You can go quite far just with what we've learned so far, and we have only " "scratched the surface. The :mod:`argparse` module is very powerful, and " @@ -1181,17 +1190,17 @@ msgstr "" "毛而已。:mod:`argparse` 模組非常強大,在結束本教學之前我們會對它進行更多探" "索。" -#: ../../howto/argparse.rst:599 +#: ../../howto/argparse.rst:604 msgid "Getting a little more advanced" msgstr "更進階一點" -#: ../../howto/argparse.rst:601 +#: ../../howto/argparse.rst:606 msgid "" "What if we wanted to expand our tiny program to perform other powers, not " "just squares::" msgstr "如果我們想擴充我們的小程式來執行其他次方的運算,而不僅是平方: ::" -#: ../../howto/argparse.rst:604 +#: ../../howto/argparse.rst:609 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1221,12 +1230,12 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:618 ../../howto/argparse.rst:656 -#: ../../howto/argparse.rst:872 +#: ../../howto/argparse.rst:623 ../../howto/argparse.rst:661 +#: ../../howto/argparse.rst:877 msgid "Output:" msgstr "結果:" -#: ../../howto/argparse.rst:620 +#: ../../howto/argparse.rst:625 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] x y\n" @@ -1260,7 +1269,7 @@ msgstr "" "$ python prog.py 4 2 -v\n" "4^2 == 16" -#: ../../howto/argparse.rst:639 +#: ../../howto/argparse.rst:644 msgid "" "Notice that so far we've been using verbosity level to *change* the text " "that gets displayed. The following example instead uses verbosity level to " @@ -1269,7 +1278,7 @@ msgstr "" "請注意,到目前為止,我們一直在使用詳細級別來\\ *更改*\\ 顯示的文字。以下範例" "使用詳細級別來顯示\\ *更多*\\ 文字: ::" -#: ../../howto/argparse.rst:643 +#: ../../howto/argparse.rst:648 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1297,7 +1306,7 @@ msgstr "" " print(f\"{args.x}^{args.y} == \", end=\"\")\n" "print(answer)" -#: ../../howto/argparse.rst:658 +#: ../../howto/argparse.rst:663 msgid "" "$ python prog.py 4 2\n" "16\n" @@ -1315,11 +1324,11 @@ msgstr "" "Running 'prog.py'\n" "4^2 == 16" -#: ../../howto/argparse.rst:672 +#: ../../howto/argparse.rst:677 msgid "Specifying ambiguous arguments" msgstr "指定不明確的引數" -#: ../../howto/argparse.rst:674 +#: ../../howto/argparse.rst:679 msgid "" "When there is ambiguity in deciding whether an argument is positional or for " "an argument, ``--`` can be used to tell :meth:`~ArgumentParser.parse_args` " @@ -1328,7 +1337,7 @@ msgstr "" "當決定一個引數是位置引數還是引數會有歧義,可以使用 ``--`` 來告訴 :meth:" "`~ArgumentParser.parse_args` 之後的所有內容都是位置引數: ::" -#: ../../howto/argparse.rst:678 +#: ../../howto/argparse.rst:683 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-n', nargs='+')\n" @@ -1368,11 +1377,11 @@ msgstr "" ">>> parser.parse_args(['-n', '1', '--', '2', '3'])\n" "Namespace(args=['2', '3'], n=['1'])" -#: ../../howto/argparse.rst:699 +#: ../../howto/argparse.rst:704 msgid "Conflicting options" msgstr "相互衝突的選項" -#: ../../howto/argparse.rst:701 +#: ../../howto/argparse.rst:706 msgid "" "So far, we have been working with two methods of an :class:`argparse." "ArgumentParser` instance. Let's introduce a third one, :meth:" @@ -1386,7 +1395,7 @@ msgstr "" "許我們指定彼此衝突的選項。我們還可以更改程式的其餘部分,以使得新功能更有意" "義:我們將引入 ``--quiet`` 選項,該選項與 ``--verbose`` 選項相反: ::" -#: ../../howto/argparse.rst:709 +#: ../../howto/argparse.rst:714 msgid "" "import argparse\n" "\n" @@ -1424,7 +1433,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:727 +#: ../../howto/argparse.rst:732 msgid "" "Our program is now simpler, and we've lost some functionality for the sake " "of demonstration. Anyways, here's the output:" @@ -1432,7 +1441,7 @@ msgstr "" "我們的程式現在更簡單了,我們因為功能展示失去了一些功能,但無論如何,以下這是" "輸出:" -#: ../../howto/argparse.rst:730 +#: ../../howto/argparse.rst:735 msgid "" "$ python prog.py 4 2\n" "4^2 == 16\n" @@ -1460,7 +1469,7 @@ msgstr "" "usage: prog.py [-h] [-v | -q] x y\n" "prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose" -#: ../../howto/argparse.rst:745 +#: ../../howto/argparse.rst:750 msgid "" "That should be easy to follow. I've added that last output so you can see " "the sort of flexibility you get, i.e. mixing long form options with short " @@ -1469,14 +1478,14 @@ msgstr "" "這應該很容易理解。我新增了最後一個輸出,以便看到所獲得的靈活性,即可以混合長" "形式與短形式選項。" -#: ../../howto/argparse.rst:749 +#: ../../howto/argparse.rst:754 msgid "" "Before we conclude, you probably want to tell your users the main purpose of " "your program, just in case they don't know::" msgstr "" "在我們結束之前,你可能想告訴使用者你的程式的主要目的,以防他們不知道: ::" -#: ../../howto/argparse.rst:752 +#: ../../howto/argparse.rst:757 msgid "" "import argparse\n" "\n" @@ -1516,7 +1525,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:770 +#: ../../howto/argparse.rst:775 msgid "" "Note that slight difference in the usage text. Note the ``[-v | -q]``, which " "tells us that we can either use ``-v`` or ``-q``, but not both at the same " @@ -1525,7 +1534,7 @@ msgstr "" "請注意用法文字中的細微差別。注意 ``[-v | -q]``,它告訴我們可以使用 ``-v`` 或 " "``-q``,但不能同時使用:" -#: ../../howto/argparse.rst:774 ../../howto/argparse.rst:801 +#: ../../howto/argparse.rst:779 ../../howto/argparse.rst:806 msgid "" "$ python prog.py --help\n" "usage: prog.py [-h] [-v | -q] x y\n" @@ -1555,11 +1564,11 @@ msgstr "" " -v, --verbose\n" " -q, --quiet" -#: ../../howto/argparse.rst:792 +#: ../../howto/argparse.rst:797 msgid "How to translate the argparse output" msgstr "如何翻譯 argparse 輸出" -#: ../../howto/argparse.rst:794 +#: ../../howto/argparse.rst:799 msgid "" "The output of the :mod:`argparse` module such as its help text and error " "messages are all made translatable using the :mod:`gettext` module. This " @@ -1570,11 +1579,11 @@ msgstr "" "`gettext` 模組進行翻譯。這允許應用程式能輕鬆本地化 :mod:`argparse` 生成的訊" "息。另請參閱 :ref:`i18n-howto`。" -#: ../../howto/argparse.rst:799 +#: ../../howto/argparse.rst:804 msgid "For instance, in this :mod:`argparse` output:" msgstr "例如,在此 :mod:`argparse` 輸出中:" -#: ../../howto/argparse.rst:817 +#: ../../howto/argparse.rst:822 msgid "" "The strings ``usage:``, ``positional arguments:``, ``options:`` and ``show " "this help message and exit`` are all translatable." @@ -1582,7 +1591,7 @@ msgstr "" "字串 ``usage:``、``positional arguments:``、``options:`` 和 ``show this help " "message and exit`` 都是可被翻譯的。" -#: ../../howto/argparse.rst:820 +#: ../../howto/argparse.rst:825 msgid "" "In order to translate these strings, they must first be extracted into a ``." "po`` file. For example, using `Babel `__, run this " @@ -1591,11 +1600,11 @@ msgstr "" "為了翻譯這些字串,必須先將它們提取到 ``.po`` 檔案中。例如,使用 `Babel " "`__ 並執行下列命令:" -#: ../../howto/argparse.rst:824 +#: ../../howto/argparse.rst:829 msgid "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" msgstr "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" -#: ../../howto/argparse.rst:828 +#: ../../howto/argparse.rst:833 msgid "" "This command will extract all translatable strings from the :mod:`argparse` " "module and output them into a file named ``messages.po``. This command " @@ -1604,13 +1613,13 @@ msgstr "" "此命令將從 :mod:`argparse` 模組中提取出所有可翻譯的字串,並將它們輸出到名為 " "``messages.po`` 的檔案中。這個指令假設你的 Python 是安裝在 ``/usr/lib`` 中。" -#: ../../howto/argparse.rst:832 +#: ../../howto/argparse.rst:837 msgid "" "You can find out the location of the :mod:`argparse` module on your system " "using this script::" msgstr "你可以使用以下腳本找到 :mod:`argparse` 模組在系統上的位置: ::" -#: ../../howto/argparse.rst:835 +#: ../../howto/argparse.rst:840 msgid "" "import argparse\n" "print(argparse.__file__)" @@ -1618,7 +1627,7 @@ msgstr "" "import argparse\n" "print(argparse.__file__)" -#: ../../howto/argparse.rst:838 +#: ../../howto/argparse.rst:843 msgid "" "Once the messages in the ``.po`` file are translated and the translations " "are installed using :mod:`gettext`, :mod:`argparse` will be able to display " @@ -1627,17 +1636,17 @@ msgstr "" "一旦翻譯了 ``.po`` 檔案中的訊息並使用 :mod:`gettext` 安裝了翻譯,:mod:" "`argparse` 將能夠顯示翻譯後的訊息。" -#: ../../howto/argparse.rst:842 +#: ../../howto/argparse.rst:847 msgid "" "To translate your own strings in the :mod:`argparse` output, use :mod:" "`gettext`." msgstr "若要在 :mod:`argparse` 輸出中翻譯你自己的字串,請使用 :mod:`gettext`。" -#: ../../howto/argparse.rst:845 +#: ../../howto/argparse.rst:850 msgid "Custom type converters" msgstr "" -#: ../../howto/argparse.rst:847 +#: ../../howto/argparse.rst:852 msgid "" "The :mod:`argparse` module allows you to specify custom type converters for " "your command-line arguments. This allows you to modify user input before " @@ -1645,7 +1654,7 @@ msgid "" "need to pre-process the input before it is used in your program." msgstr "" -#: ../../howto/argparse.rst:852 +#: ../../howto/argparse.rst:857 msgid "" "When using a custom type converter, you can use any callable that takes a " "single string argument (the argument value) and returns the converted value. " @@ -1653,13 +1662,13 @@ msgid "" "action class with the **action** parameter instead." msgstr "" -#: ../../howto/argparse.rst:857 +#: ../../howto/argparse.rst:862 msgid "" "For example, let's say you want to handle arguments with different prefixes " "and process them accordingly::" msgstr "" -#: ../../howto/argparse.rst:860 +#: ../../howto/argparse.rst:865 msgid "" "import argparse\n" "\n" @@ -1685,7 +1694,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args)" -#: ../../howto/argparse.rst:874 +#: ../../howto/argparse.rst:879 msgid "" "$ python prog.py -a value1 +a value2\n" "Namespace(a=[('-', 'value1'), ('+', 'value2')])" @@ -1693,24 +1702,24 @@ msgstr "" "$ python prog.py -a value1 +a value2\n" "Namespace(a=[('-', 'value1'), ('+', 'value2')])" -#: ../../howto/argparse.rst:879 +#: ../../howto/argparse.rst:884 msgid "In this example, we:" msgstr "在這個範例當中,我們:" -#: ../../howto/argparse.rst:881 +#: ../../howto/argparse.rst:886 msgid "" "Created a parser with custom prefix characters using the ``prefix_chars`` " "parameter." msgstr "" -#: ../../howto/argparse.rst:884 +#: ../../howto/argparse.rst:889 msgid "" "Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter " "to create custom type converters to store the value in a tuple with the " "prefix." msgstr "" -#: ../../howto/argparse.rst:887 +#: ../../howto/argparse.rst:892 msgid "" "Without the custom type converters, the arguments would have treated the ``-" "a`` and ``+a`` as the same argument, which would have been undesirable. By " @@ -1718,11 +1727,11 @@ msgid "" "arguments." msgstr "" -#: ../../howto/argparse.rst:892 +#: ../../howto/argparse.rst:897 msgid "Conclusion" msgstr "結論" -#: ../../howto/argparse.rst:894 +#: ../../howto/argparse.rst:899 msgid "" "The :mod:`argparse` module offers a lot more than shown here. Its docs are " "quite detailed and thorough, and full of examples. Having gone through this " diff --git a/howto/free-threading-python.po b/howto/free-threading-python.po index d2f09a2deb..fe26e49d23 100644 --- a/howto/free-threading-python.po +++ b/howto/free-threading-python.po @@ -1,4 +1,3 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. @@ -20,7 +19,7 @@ msgstr "" #: ../../howto/free-threading-python.rst:5 msgid "Python experimental support for free threading" -msgstr "" +msgstr "Python 自由執行緒的實驗性支援" #: ../../howto/free-threading-python.rst:7 msgid "" @@ -54,7 +53,7 @@ msgstr "" #: ../../howto/free-threading-python.rst:28 msgid "Installation" -msgstr "" +msgstr "安裝" #: ../../howto/free-threading-python.rst:30 msgid "" @@ -130,7 +129,7 @@ msgstr "https://hugovk.github.io/free-threaded-wheels/" #: ../../howto/free-threading-python.rst:75 msgid "Thread safety" -msgstr "" +msgstr "執行緒安全" #: ../../howto/free-threading-python.rst:77 msgid "" @@ -153,7 +152,7 @@ msgstr "" #: ../../howto/free-threading-python.rst:94 msgid "Known limitations" -msgstr "" +msgstr "已知限制" #: ../../howto/free-threading-python.rst:96 msgid "" @@ -162,7 +161,7 @@ msgstr "" #: ../../howto/free-threading-python.rst:99 msgid "Immortalization" -msgstr "" +msgstr "不滅化 (Immortalization)" #: ../../howto/free-threading-python.rst:101 msgid "" @@ -182,23 +181,23 @@ msgstr "" #: ../../howto/free-threading-python.rst:109 msgid "" ":ref:`function ` objects declared at the module level" -msgstr "" +msgstr "在模組層級宣告的\\ :ref:`函式 `\\ 物件" #: ../../howto/free-threading-python.rst:110 msgid ":ref:`method ` descriptors" -msgstr "" +msgstr ":ref:`方法 `\\ 描述器" #: ../../howto/free-threading-python.rst:111 msgid ":ref:`code ` objects" -msgstr "" +msgstr ":ref:`程式碼 `\\ 物件" #: ../../howto/free-threading-python.rst:112 msgid ":term:`module` objects and their dictionaries" -msgstr "" +msgstr ":term:`模組 `\\ 物件及其字典" #: ../../howto/free-threading-python.rst:113 msgid ":ref:`classes ` (type objects)" -msgstr "" +msgstr ":ref:`類別 `\\ (型別物件)" #: ../../howto/free-threading-python.rst:115 msgid "" @@ -241,7 +240,7 @@ msgstr "" #: ../../howto/free-threading-python.rst:143 msgid "Single-threaded performance" -msgstr "" +msgstr "單執行緒效能" #: ../../howto/free-threading-python.rst:145 msgid "" diff --git a/howto/functional.po b/howto/functional.po index a145631968..15ccb13599 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -164,23 +164,23 @@ msgstr "" #: ../../howto/functional.rst:94 msgid "Formal provability." -msgstr "" +msgstr "形式可證明性 (Formal provability)。" #: ../../howto/functional.rst:95 msgid "Modularity." -msgstr "" +msgstr "模組化 (Modularity)。" #: ../../howto/functional.rst:96 msgid "Composability." -msgstr "" +msgstr "可組合性 (Composability)。" #: ../../howto/functional.rst:97 msgid "Ease of debugging and testing." -msgstr "" +msgstr "容易除錯與測試。" #: ../../howto/functional.rst:101 msgid "Formal provability" -msgstr "" +msgstr "形式可證明性" #: ../../howto/functional.rst:103 msgid "" @@ -231,7 +231,7 @@ msgstr "" #: ../../howto/functional.rst:137 msgid "Modularity" -msgstr "" +msgstr "模組化" #: ../../howto/functional.rst:139 msgid "" @@ -244,7 +244,7 @@ msgstr "" #: ../../howto/functional.rst:147 msgid "Ease of debugging and testing" -msgstr "" +msgstr "容易除錯與測試" #: ../../howto/functional.rst:149 msgid "Testing and debugging a functional-style program is easier." @@ -269,7 +269,7 @@ msgstr "" #: ../../howto/functional.rst:163 msgid "Composability" -msgstr "" +msgstr "可組合性" #: ../../howto/functional.rst:165 msgid "" @@ -498,7 +498,7 @@ msgstr "" #: ../../howto/functional.rst:333 msgid "Generator expressions and list comprehensions" -msgstr "" +msgstr "產生器運算式與串列綜合運算式" #: ../../howto/functional.rst:335 msgid "" @@ -527,6 +527,13 @@ msgid "" ">>> # List comprehension -- returns list\n" ">>> stripped_list = [line.strip() for line in line_list]" msgstr "" +">>> line_list = [' line 1\\n', 'line 2 \\n', ' \\n', '']\n" +"\n" +">>> # 產生器運算式 -- 回傳疊代器\n" +">>> stripped_iter = (line.strip() for line in line_list)\n" +"\n" +">>> # 串列綜合運算式 -- 回傳串列\n" +">>> stripped_list = [line.strip() for line in line_list]" #: ../../howto/functional.rst:354 msgid "" @@ -692,7 +699,7 @@ msgstr "" #: ../../howto/functional.rst:454 msgid "Here's the simplest example of a generator function:" -msgstr "" +msgstr "以下是最簡單的產生器函式範例:" #: ../../howto/functional.rst:460 msgid "" @@ -715,7 +722,7 @@ msgstr "" #: ../../howto/functional.rst:473 msgid "Here's a sample usage of the ``generate_ints()`` generator:" -msgstr "" +msgstr "以下是 ``generate_ints()`` 產生器的使用範例:" #: ../../howto/functional.rst:490 msgid "" @@ -840,6 +847,15 @@ msgid "" " else:\n" " i += 1" msgstr "" +"def counter(maximum):\n" +" i = 0\n" +" while i < maximum:\n" +" val = (yield i)\n" +" # 如有提供值則改變計數器\n" +" if val is not None:\n" +" i = val\n" +" else:\n" +" i += 1" #: ../../howto/functional.rst:576 msgid "And here's an example of changing the counter:" @@ -917,12 +933,14 @@ msgstr "" #: ../../howto/functional.rst:633 msgid "" ":func:`map(f, iterA, iterB, ...) ` returns an iterator over the sequence" -msgstr "" +msgstr ":func:`map(f, iterA, iterB, ...) ` 回傳一個元素為序列的疊代器" #: ../../howto/functional.rst:634 msgid "" "``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``." msgstr "" +"``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ..." +"``。" #: ../../howto/functional.rst:644 msgid "You can of course achieve the same effect with a list comprehension." diff --git a/howto/perf_profiling.po b/howto/perf_profiling.po index d89ee4250b..0274ff095f 100644 --- a/howto/perf_profiling.po +++ b/howto/perf_profiling.po @@ -115,7 +115,7 @@ msgstr "" #: ../../howto/perf_profiling.rst:55 msgid "We can run ``perf`` to sample CPU stack traces at 9999 hertz::" -msgstr "我們可以執行 ``perf`` 以 9999 赫茲採樣 CPU 堆疊追蹤 (stack trace): ::" +msgstr "我們可以執行 ``perf`` 以 9999 赫茲取樣 CPU 堆疊追蹤 (stack trace): ::" #: ../../howto/perf_profiling.rst:57 msgid "$ perf record -F 9999 -g -o perf.data python my_script.py" diff --git a/howto/sorting.po b/howto/sorting.po index f66a0870ce..dcdc529f4e 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -697,7 +697,7 @@ msgid "" msgstr "" ":func:`heapq.nsmallest` 以及 :func:`heapq.nlargest` 會分別回傳 *n* 個最小值及" "最大值。這些函式會將資料進行一次傳遞且一次只會保留 *n* 個元素在記憶體中。對於" -"相對於輸入數量較小的 *n* 個值,這些函數進行的比較比完整排序要少得多。" +"相對於輸入數量較小的 *n* 個值,這些函式進行的比較比完整排序要少得多。" #: ../../howto/sorting.rst:342 msgid "" diff --git a/library/_thread.po b/library/_thread.po index 91130e2cc2..1dbd585c96 100644 --- a/library/_thread.po +++ b/library/_thread.po @@ -319,7 +319,7 @@ msgid "" "Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is " "equivalent to calling :func:`_thread.exit`." msgstr "" -"呼叫 :func:`sys.exit` 函數或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" +"呼叫 :func:`sys.exit` 函式或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" "`_thread.exit` 函式。" #: ../../library/_thread.rst:222 diff --git a/library/argparse.po b/library/argparse.po index 4bdf1f6631..b0188fae49 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-23 00:14+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2018-05-23 14:38+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,24 +21,37 @@ msgstr "" msgid "" ":mod:`!argparse` --- Parser for command-line options, arguments and " "subcommands" -msgstr "" +msgstr ":mod:`!argparse` --- 命令列選項、引數和子命令的剖析器" #: ../../library/argparse.rst:12 msgid "**Source code:** :source:`Lib/argparse.py`" msgstr "**原始碼:**\\ :source:`Lib/argparse.py`" +#: ../../library/argparse.rst:16 +msgid "" +"While :mod:`argparse` is the default recommended standard library module for " +"implementing basic command line applications, authors with more exacting " +"requirements for exactly how their command line applications behave may find " +"it doesn't provide the necessary level of control. Refer to :ref:`choosing-" +"an-argument-parser` for alternatives to consider when ``argparse`` doesn't " +"support behaviors that the application requires (such as entirely disabling " +"support for interspersed options and positional arguments, or accepting " +"option parameter values that start with ``-`` even when they correspond to " +"another defined option)." +msgstr "" + #: ../../library/argparse.rst:-1 msgid "Tutorial" msgstr "教學" -#: ../../library/argparse.rst:18 +#: ../../library/argparse.rst:30 msgid "" "This page contains the API reference information. For a more gentle " "introduction to Python command-line parsing, have a look at the :ref:" "`argparse tutorial `." msgstr "" -#: ../../library/argparse.rst:22 +#: ../../library/argparse.rst:34 msgid "" "The :mod:`!argparse` module makes it easy to write user-friendly command-" "line interfaces. The program defines what arguments it requires, and :mod:`!" @@ -49,7 +61,7 @@ msgid "" "invalid arguments." msgstr "" -#: ../../library/argparse.rst:28 +#: ../../library/argparse.rst:40 msgid "" "The :mod:`!argparse` module's support for command-line interfaces is built " "around an instance of :class:`argparse.ArgumentParser`. It is a container " @@ -57,177 +69,187 @@ msgid "" "whole::" msgstr "" -#: ../../library/argparse.rst:32 +#: ../../library/argparse.rst:44 msgid "" "parser = argparse.ArgumentParser(\n" " prog='ProgramName',\n" " description='What the program does',\n" " epilog='Text at the bottom of help')" msgstr "" +"parser = argparse.ArgumentParser(\n" +" prog='ProgramName',\n" +" description='What the program does',\n" +" epilog='Text at the bottom of help')" -#: ../../library/argparse.rst:37 +#: ../../library/argparse.rst:49 msgid "" "The :meth:`ArgumentParser.add_argument` method attaches individual argument " "specifications to the parser. It supports positional arguments, options " "that accept values, and on/off flags::" msgstr "" -#: ../../library/argparse.rst:41 +#: ../../library/argparse.rst:53 msgid "" "parser.add_argument('filename') # positional argument\n" "parser.add_argument('-c', '--count') # option that takes a value\n" "parser.add_argument('-v', '--verbose',\n" " action='store_true') # on/off flag" msgstr "" +"parser.add_argument('filename') # 位置引數\n" +"parser.add_argument('-c', '--count') # 接收一個值的選項\n" +"parser.add_argument('-v', '--verbose',\n" +" action='store_true') # 開關旗標" -#: ../../library/argparse.rst:46 +#: ../../library/argparse.rst:58 msgid "" "The :meth:`ArgumentParser.parse_args` method runs the parser and places the " "extracted data in a :class:`argparse.Namespace` object::" msgstr "" -#: ../../library/argparse.rst:49 +#: ../../library/argparse.rst:61 msgid "" "args = parser.parse_args()\n" "print(args.filename, args.count, args.verbose)" msgstr "" +"args = parser.parse_args()\n" +"print(args.filename, args.count, args.verbose)" -#: ../../library/argparse.rst:53 +#: ../../library/argparse.rst:65 msgid "" "If you're looking for a guide about how to upgrade :mod:`optparse` code to :" "mod:`!argparse`, see :ref:`Upgrading Optparse Code `." msgstr "" -#: ../../library/argparse.rst:57 +#: ../../library/argparse.rst:69 msgid "ArgumentParser objects" msgstr "ArgumentParser 物件" -#: ../../library/argparse.rst:66 +#: ../../library/argparse.rst:78 msgid "" "Create a new :class:`ArgumentParser` object. All parameters should be passed " "as keyword arguments. Each parameter has its own more detailed description " "below, but in short they are:" msgstr "" -#: ../../library/argparse.rst:70 +#: ../../library/argparse.rst:82 msgid "" "prog_ - The name of the program (default: ``os.path.basename(sys.argv[0])``)" -msgstr "" +msgstr "prog_ - 程式的名稱(預設值:``os.path.basename(sys.argv[0])``)" -#: ../../library/argparse.rst:73 +#: ../../library/argparse.rst:85 msgid "" "usage_ - The string describing the program usage (default: generated from " "arguments added to parser)" -msgstr "" +msgstr "usage_ - 描述程式用法的字串(預設值:從新增到剖析器的引數產生)" -#: ../../library/argparse.rst:76 +#: ../../library/argparse.rst:88 msgid "" "description_ - Text to display before the argument help (by default, no text)" -msgstr "" +msgstr "description_ - 引數說明之前要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:79 +#: ../../library/argparse.rst:91 msgid "epilog_ - Text to display after the argument help (by default, no text)" -msgstr "" +msgstr "epilog_ - 引數說明之後要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:81 +#: ../../library/argparse.rst:93 msgid "" "parents_ - A list of :class:`ArgumentParser` objects whose arguments should " "also be included" -msgstr "" +msgstr "parents_ - 一個 :class:`ArgumentParser` 物件的串列,其引數也應該被包含" -#: ../../library/argparse.rst:84 +#: ../../library/argparse.rst:96 msgid "formatter_class_ - A class for customizing the help output" -msgstr "" +msgstr "formatter_class_ - 用於自訂說明輸出的類別" -#: ../../library/argparse.rst:86 +#: ../../library/argparse.rst:98 msgid "" "prefix_chars_ - The set of characters that prefix optional arguments " "(default: '-')" -msgstr "" +msgstr "prefix_chars_ - 前綴可選引數的字元集合(預設值:'-')" -#: ../../library/argparse.rst:89 +#: ../../library/argparse.rst:101 msgid "" "fromfile_prefix_chars_ - The set of characters that prefix files from which " "additional arguments should be read (default: ``None``)" msgstr "" -#: ../../library/argparse.rst:92 +#: ../../library/argparse.rst:104 msgid "" "argument_default_ - The global default value for arguments (default: " "``None``)" msgstr "" -#: ../../library/argparse.rst:95 +#: ../../library/argparse.rst:107 msgid "" "conflict_handler_ - The strategy for resolving conflicting optionals " "(usually unnecessary)" msgstr "" -#: ../../library/argparse.rst:98 +#: ../../library/argparse.rst:110 msgid "" "add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:100 +#: ../../library/argparse.rst:112 msgid "" "allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is " "unambiguous. (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:103 +#: ../../library/argparse.rst:115 msgid "" "exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits " "with error info when an error occurs. (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:106 +#: ../../library/argparse.rst:118 msgid "*allow_abbrev* parameter was added." msgstr "新增 *allow_abbrev* 參數。" -#: ../../library/argparse.rst:109 +#: ../../library/argparse.rst:121 msgid "" "In previous versions, *allow_abbrev* also disabled grouping of short flags " "such as ``-vv`` to mean ``-v -v``." msgstr "" -#: ../../library/argparse.rst:113 +#: ../../library/argparse.rst:125 msgid "*exit_on_error* parameter was added." msgstr "新增 *exit_on_error* 參數。" -#: ../../library/argparse.rst:116 ../../library/argparse.rst:598 +#: ../../library/argparse.rst:128 ../../library/argparse.rst:610 msgid "The following sections describe how each of these are used." msgstr "" -#: ../../library/argparse.rst:122 +#: ../../library/argparse.rst:134 msgid "prog" -msgstr "" +msgstr "prog" -#: ../../library/argparse.rst:125 +#: ../../library/argparse.rst:137 msgid "" "By default, :class:`ArgumentParser` calculates the name of the program to " "display in help messages depending on the way the Python interpreter was run:" msgstr "" -#: ../../library/argparse.rst:128 +#: ../../library/argparse.rst:140 msgid "" "The :func:`base name ` of ``sys.argv[0]`` if a file was " "passed as argument." msgstr "" -#: ../../library/argparse.rst:130 +#: ../../library/argparse.rst:142 msgid "" "The Python interpreter name followed by ``sys.argv[0]`` if a directory or a " "zipfile was passed as argument." msgstr "" -#: ../../library/argparse.rst:132 +#: ../../library/argparse.rst:144 msgid "" "The Python interpreter name followed by ``-m`` followed by the module or " "package name if the :option:`-m` option was used." msgstr "" -#: ../../library/argparse.rst:135 +#: ../../library/argparse.rst:147 msgid "" "This default is almost always desirable because it will make the help " "messages match the string that was used to invoke the program on the command " @@ -235,7 +257,7 @@ msgid "" "supplied using the ``prog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:140 +#: ../../library/argparse.rst:152 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.print_help()\n" @@ -251,14 +273,14 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:147 +#: ../../library/argparse.rst:159 msgid "" "Note that the program name, whether determined from ``sys.argv[0]`` or from " "the ``prog=`` argument, is available to help messages using the ``%(prog)s`` " "format specifier." msgstr "" -#: ../../library/argparse.rst:153 +#: ../../library/argparse.rst:165 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n" @@ -278,18 +300,18 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO foo of the myprogram program" -#: ../../library/argparse.rst:164 +#: ../../library/argparse.rst:176 msgid "usage" -msgstr "" +msgstr "usage" -#: ../../library/argparse.rst:166 +#: ../../library/argparse.rst:178 msgid "" "By default, :class:`ArgumentParser` calculates the usage message from the " "arguments it contains. The default message can be overridden with the " "``usage=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:170 +#: ../../library/argparse.rst:182 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s " "[options]')\n" @@ -319,17 +341,17 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo [FOO] foo help" -#: ../../library/argparse.rst:183 +#: ../../library/argparse.rst:195 msgid "" "The ``%(prog)s`` format specifier is available to fill in the program name " "in your usage messages." msgstr "" -#: ../../library/argparse.rst:190 +#: ../../library/argparse.rst:202 msgid "description" -msgstr "描述" +msgstr "description" -#: ../../library/argparse.rst:192 +#: ../../library/argparse.rst:204 msgid "" "Most calls to the :class:`ArgumentParser` constructor will use the " "``description=`` keyword argument. This argument gives a brief description " @@ -338,24 +360,24 @@ msgid "" "messages for the various arguments." msgstr "" -#: ../../library/argparse.rst:198 +#: ../../library/argparse.rst:210 msgid "" "By default, the description will be line-wrapped so that it fits within the " "given space. To change this behavior, see the formatter_class_ argument." msgstr "" -#: ../../library/argparse.rst:203 +#: ../../library/argparse.rst:215 msgid "epilog" -msgstr "" +msgstr "epilog" -#: ../../library/argparse.rst:205 +#: ../../library/argparse.rst:217 msgid "" "Some programs like to display additional description of the program after " "the description of the arguments. Such text can be specified using the " "``epilog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:209 +#: ../../library/argparse.rst:221 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... description='A foo that bars',\n" @@ -383,18 +405,18 @@ msgstr "" "\n" "And that's how you'd foo a bar" -#: ../../library/argparse.rst:222 +#: ../../library/argparse.rst:234 msgid "" "As with the description_ argument, the ``epilog=`` text is by default line-" "wrapped, but this behavior can be adjusted with the formatter_class_ " "argument to :class:`ArgumentParser`." msgstr "" -#: ../../library/argparse.rst:228 +#: ../../library/argparse.rst:240 msgid "parents" -msgstr "" +msgstr "parents" -#: ../../library/argparse.rst:230 +#: ../../library/argparse.rst:242 msgid "" "Sometimes, several parsers share a common set of arguments. Rather than " "repeating the definitions of these arguments, a single parser with all the " @@ -405,7 +427,7 @@ msgid "" "object being constructed::" msgstr "" -#: ../../library/argparse.rst:237 +#: ../../library/argparse.rst:249 msgid "" ">>> parent_parser = argparse.ArgumentParser(add_help=False)\n" ">>> parent_parser.add_argument('--parent', type=int)\n" @@ -433,32 +455,32 @@ msgstr "" ">>> bar_parser.parse_args(['--bar', 'YYY'])\n" "Namespace(bar='YYY', parent=None)" -#: ../../library/argparse.rst:250 +#: ../../library/argparse.rst:262 msgid "" "Note that most parent parsers will specify ``add_help=False``. Otherwise, " "the :class:`ArgumentParser` will see two ``-h/--help`` options (one in the " "parent and one in the child) and raise an error." msgstr "" -#: ../../library/argparse.rst:255 +#: ../../library/argparse.rst:267 msgid "" "You must fully initialize the parsers before passing them via ``parents=``. " "If you change the parent parsers after the child parser, those changes will " "not be reflected in the child." msgstr "" -#: ../../library/argparse.rst:263 +#: ../../library/argparse.rst:275 msgid "formatter_class" msgstr "formatter_class" -#: ../../library/argparse.rst:265 +#: ../../library/argparse.rst:277 msgid "" ":class:`ArgumentParser` objects allow the help formatting to be customized " "by specifying an alternate formatting class. Currently, there are four such " "classes:" msgstr "" -#: ../../library/argparse.rst:274 +#: ../../library/argparse.rst:286 msgid "" ":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give " "more control over how textual descriptions are displayed. By default, :class:" @@ -466,7 +488,7 @@ msgid "" "command-line help messages::" msgstr "" -#: ../../library/argparse.rst:279 +#: ../../library/argparse.rst:291 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -490,14 +512,14 @@ msgid "" "will be wrapped across a couple lines" msgstr "" -#: ../../library/argparse.rst:299 +#: ../../library/argparse.rst:311 msgid "" "Passing :class:`RawDescriptionHelpFormatter` as ``formatter_class=`` " "indicates that description_ and epilog_ are already correctly formatted and " "should not be line-wrapped::" msgstr "" -#: ../../library/argparse.rst:303 +#: ../../library/argparse.rst:315 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -521,8 +543,29 @@ msgid "" "options:\n" " -h, --help show this help message and exit" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.RawDescriptionHelpFormatter,\n" +"... description=textwrap.dedent('''\\\n" +"... Please do not mess up this text!\n" +"... --------------------------------\n" +"... I have indented it\n" +"... exactly the way\n" +"... I want it\n" +"... '''))\n" +">>> parser.print_help()\n" +"usage: PROG [-h]\n" +"\n" +"Please do not mess up this text!\n" +"--------------------------------\n" +" I have indented it\n" +" exactly the way\n" +" I want it\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" -#: ../../library/argparse.rst:325 +#: ../../library/argparse.rst:337 msgid "" ":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help " "text, including argument descriptions. However, multiple newlines are " @@ -530,13 +573,13 @@ msgid "" "between the newlines." msgstr "" -#: ../../library/argparse.rst:330 +#: ../../library/argparse.rst:342 msgid "" ":class:`ArgumentDefaultsHelpFormatter` automatically adds information about " "default values to each of the argument help messages::" msgstr "" -#: ../../library/argparse.rst:333 +#: ../../library/argparse.rst:345 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -568,14 +611,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO FOO! (default: 42)" -#: ../../library/argparse.rst:348 +#: ../../library/argparse.rst:360 msgid "" ":class:`MetavarTypeHelpFormatter` uses the name of the type_ argument for " "each argument as the display name for its values (rather than using the " "dest_ as the regular formatter does)::" msgstr "" -#: ../../library/argparse.rst:352 +#: ../../library/argparse.rst:364 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -607,11 +650,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo int" -#: ../../library/argparse.rst:369 +#: ../../library/argparse.rst:381 msgid "prefix_chars" msgstr "prefix_chars" -#: ../../library/argparse.rst:371 +#: ../../library/argparse.rst:383 msgid "" "Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. " "Parsers that need to support different or additional prefix characters, e.g. " @@ -619,7 +662,7 @@ msgid "" "``prefix_chars=`` argument to the :class:`ArgumentParser` constructor::" msgstr "" -#: ../../library/argparse.rst:377 +#: ../../library/argparse.rst:389 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n" ">>> parser.add_argument('+f')\n" @@ -633,18 +676,18 @@ msgstr "" ">>> parser.parse_args('+f X ++bar Y'.split())\n" "Namespace(bar='Y', f='X')" -#: ../../library/argparse.rst:383 +#: ../../library/argparse.rst:395 msgid "" "The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of " "characters that does not include ``-`` will cause ``-f/--foo`` options to be " "disallowed." msgstr "" -#: ../../library/argparse.rst:389 +#: ../../library/argparse.rst:401 msgid "fromfile_prefix_chars" msgstr "fromfile_prefix_chars" -#: ../../library/argparse.rst:391 +#: ../../library/argparse.rst:403 msgid "" "Sometimes, when dealing with a particularly long argument list, it may make " "sense to keep the list of arguments in a file rather than typing it out at " @@ -654,7 +697,7 @@ msgid "" "by the arguments they contain. For example::" msgstr "" -#: ../../library/argparse.rst:398 +#: ../../library/argparse.rst:410 msgid "" ">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n" "... fp.write('-f\\nbar')\n" @@ -672,7 +715,7 @@ msgstr "" ">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n" "Namespace(f='bar')" -#: ../../library/argparse.rst:406 +#: ../../library/argparse.rst:418 msgid "" "Arguments read from a file must by default be one per line (but see also :" "meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they " @@ -682,19 +725,19 @@ msgid "" "f', 'bar']``." msgstr "" -#: ../../library/argparse.rst:412 +#: ../../library/argparse.rst:424 msgid "" ":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` " "to read the file containing arguments." msgstr "" -#: ../../library/argparse.rst:415 +#: ../../library/argparse.rst:427 msgid "" "The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that " "arguments will never be treated as file references." msgstr "" -#: ../../library/argparse.rst:418 +#: ../../library/argparse.rst:430 msgid "" ":class:`ArgumentParser` changed encoding and errors to read arguments files " "from default (e.g. :func:`locale.getpreferredencoding(False) >> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" ">>> parser.add_argument('--foo')\n" @@ -737,22 +780,22 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace()" -#: ../../library/argparse.rst:448 +#: ../../library/argparse.rst:460 msgid "allow_abbrev" msgstr "allow_abbrev" -#: ../../library/argparse.rst:450 +#: ../../library/argparse.rst:462 msgid "" "Normally, when you pass an argument list to the :meth:`~ArgumentParser." "parse_args` method of an :class:`ArgumentParser`, it :ref:`recognizes " "abbreviations ` of long options." msgstr "" -#: ../../library/argparse.rst:454 +#: ../../library/argparse.rst:466 msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:456 +#: ../../library/argparse.rst:468 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" ">>> parser.add_argument('--foobar', action='store_true')\n" @@ -768,11 +811,11 @@ msgstr "" "usage: PROG [-h] [--foobar] [--foonley]\n" "PROG: error: unrecognized arguments: --foon" -#: ../../library/argparse.rst:467 +#: ../../library/argparse.rst:479 msgid "conflict_handler" msgstr "conflict_handler" -#: ../../library/argparse.rst:469 +#: ../../library/argparse.rst:481 msgid "" ":class:`ArgumentParser` objects do not allow two actions with the same " "option string. By default, :class:`ArgumentParser` objects raise an " @@ -780,7 +823,7 @@ msgid "" "that is already in use::" msgstr "" -#: ../../library/argparse.rst:474 +#: ../../library/argparse.rst:486 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo', help='old foo help')\n" @@ -796,7 +839,7 @@ msgstr "" " ..\n" "ArgumentError: argument --foo: conflicting option string(s): --foo" -#: ../../library/argparse.rst:481 +#: ../../library/argparse.rst:493 msgid "" "Sometimes (e.g. when using parents_) it may be useful to simply override any " "older arguments with the same option string. To get this behavior, the " @@ -804,7 +847,7 @@ msgid "" "of :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:486 +#: ../../library/argparse.rst:498 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', " "conflict_handler='resolve')\n" @@ -830,7 +873,7 @@ msgstr "" " -f FOO old foo help\n" " --foo FOO new foo help" -#: ../../library/argparse.rst:497 +#: ../../library/argparse.rst:509 msgid "" "Note that :class:`ArgumentParser` objects only remove an action if all of " "its option strings are overridden. So, in the example above, the old ``-f/--" @@ -838,25 +881,25 @@ msgid "" "option string was overridden." msgstr "" -#: ../../library/argparse.rst:504 +#: ../../library/argparse.rst:516 msgid "add_help" msgstr "add_help" -#: ../../library/argparse.rst:506 +#: ../../library/argparse.rst:518 msgid "" "By default, :class:`ArgumentParser` objects add an option which simply " "displays the parser's help message. If ``-h`` or ``--help`` is supplied at " "the command line, the :class:`!ArgumentParser` help will be printed." msgstr "" -#: ../../library/argparse.rst:510 +#: ../../library/argparse.rst:522 msgid "" "Occasionally, it may be useful to disable the addition of this help option. " "This can be achieved by passing ``False`` as the ``add_help=`` argument to :" "class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:514 +#: ../../library/argparse.rst:526 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> parser.add_argument('--foo', help='foo help')\n" @@ -874,7 +917,7 @@ msgstr "" "options:\n" " --foo FOO foo help" -#: ../../library/argparse.rst:522 +#: ../../library/argparse.rst:534 msgid "" "The help option is typically ``-h/--help``. The exception to this is if the " "``prefix_chars=`` is specified and does not include ``-``, in which case ``-" @@ -882,7 +925,7 @@ msgid "" "in ``prefix_chars`` is used to prefix the help options::" msgstr "" -#: ../../library/argparse.rst:528 +#: ../../library/argparse.rst:540 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" ">>> parser.print_help()\n" @@ -898,24 +941,24 @@ msgstr "" "options:\n" " +h, ++help show this help message and exit" -#: ../../library/argparse.rst:537 +#: ../../library/argparse.rst:549 msgid "exit_on_error" msgstr "exit_on_error" -#: ../../library/argparse.rst:539 +#: ../../library/argparse.rst:551 msgid "" "Normally, when you pass an invalid argument list to the :meth:" "`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " "print a *message* to :data:`sys.stderr` and exit with a status code of 2." msgstr "" -#: ../../library/argparse.rst:543 +#: ../../library/argparse.rst:555 msgid "" "If the user would like to catch errors manually, the feature can be enabled " "by setting ``exit_on_error`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:546 +#: ../../library/argparse.rst:558 msgid "" ">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" ">>> parser.add_argument('--integers', type=int)\n" @@ -941,81 +984,81 @@ msgstr "" "...\n" "Catching an argumentError" -#: ../../library/argparse.rst:560 +#: ../../library/argparse.rst:572 msgid "The add_argument() method" -msgstr "" +msgstr "add_argument() 方法" -#: ../../library/argparse.rst:566 +#: ../../library/argparse.rst:578 msgid "" "Define how a single command-line argument should be parsed. Each parameter " "has its own more detailed description below, but in short they are:" msgstr "" -#: ../../library/argparse.rst:569 +#: ../../library/argparse.rst:581 msgid "" "`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " "or ``'-f', '--foo'``." msgstr "" -#: ../../library/argparse.rst:572 +#: ../../library/argparse.rst:584 msgid "" "action_ - The basic type of action to be taken when this argument is " "encountered at the command line." msgstr "" -#: ../../library/argparse.rst:575 +#: ../../library/argparse.rst:587 msgid "nargs_ - The number of command-line arguments that should be consumed." msgstr "" -#: ../../library/argparse.rst:577 +#: ../../library/argparse.rst:589 msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "" -#: ../../library/argparse.rst:579 +#: ../../library/argparse.rst:591 msgid "" "default_ - The value produced if the argument is absent from the command " "line and if it is absent from the namespace object." msgstr "" -#: ../../library/argparse.rst:582 +#: ../../library/argparse.rst:594 msgid "" "type_ - The type to which the command-line argument should be converted." msgstr "" -#: ../../library/argparse.rst:584 +#: ../../library/argparse.rst:596 msgid "choices_ - A sequence of the allowable values for the argument." msgstr "" -#: ../../library/argparse.rst:586 +#: ../../library/argparse.rst:598 msgid "" "required_ - Whether or not the command-line option may be omitted (optionals " "only)." msgstr "" -#: ../../library/argparse.rst:589 +#: ../../library/argparse.rst:601 msgid "help_ - A brief description of what the argument does." msgstr "" -#: ../../library/argparse.rst:591 +#: ../../library/argparse.rst:603 msgid "metavar_ - A name for the argument in usage messages." msgstr "" -#: ../../library/argparse.rst:593 +#: ../../library/argparse.rst:605 msgid "" "dest_ - The name of the attribute to be added to the object returned by :" "meth:`parse_args`." msgstr "" -#: ../../library/argparse.rst:596 +#: ../../library/argparse.rst:608 msgid "deprecated_ - Whether or not use of the argument is deprecated." msgstr "" -#: ../../library/argparse.rst:604 +#: ../../library/argparse.rst:616 msgid "name or flags" -msgstr "" +msgstr "name or flags" -#: ../../library/argparse.rst:606 +#: ../../library/argparse.rst:618 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " @@ -1024,30 +1067,30 @@ msgid "" "or a simple argument name." msgstr "" -#: ../../library/argparse.rst:612 +#: ../../library/argparse.rst:624 msgid "For example, an optional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:614 +#: ../../library/argparse.rst:626 msgid ">>> parser.add_argument('-f', '--foo')" msgstr ">>> parser.add_argument('-f', '--foo')" -#: ../../library/argparse.rst:616 +#: ../../library/argparse.rst:628 msgid "while a positional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:618 +#: ../../library/argparse.rst:630 msgid ">>> parser.add_argument('bar')" msgstr ">>> parser.add_argument('bar')" -#: ../../library/argparse.rst:620 +#: ../../library/argparse.rst:632 msgid "" "When :meth:`~ArgumentParser.parse_args` is called, optional arguments will " "be identified by the ``-`` prefix, and the remaining arguments will be " "assumed to be positional::" msgstr "" -#: ../../library/argparse.rst:624 +#: ../../library/argparse.rst:636 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1071,11 +1114,11 @@ msgstr "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:639 +#: ../../library/argparse.rst:651 msgid "action" -msgstr "" +msgstr "action" -#: ../../library/argparse.rst:641 +#: ../../library/argparse.rst:653 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -1085,13 +1128,13 @@ msgid "" "be handled. The supplied actions are:" msgstr "" -#: ../../library/argparse.rst:647 +#: ../../library/argparse.rst:659 msgid "" "``'store'`` - This just stores the argument's value. This is the default " "action." msgstr "" -#: ../../library/argparse.rst:650 +#: ../../library/argparse.rst:662 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -1099,7 +1142,7 @@ msgid "" "specify some sort of flag. For example::" msgstr "" -#: ../../library/argparse.rst:655 +#: ../../library/argparse.rst:667 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" @@ -1111,7 +1154,7 @@ msgstr "" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:660 +#: ../../library/argparse.rst:672 msgid "" "``'store_true'`` and ``'store_false'`` - These are special cases of " "``'store_const'`` used for storing the values ``True`` and ``False`` " @@ -1119,7 +1162,7 @@ msgid "" "``True`` respectively::" msgstr "" -#: ../../library/argparse.rst:665 +#: ../../library/argparse.rst:677 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1135,7 +1178,7 @@ msgstr "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:672 +#: ../../library/argparse.rst:684 msgid "" "``'append'`` - This stores a list, and appends each argument value to the " "list. It is useful to allow an option to be specified multiple times. If the " @@ -1144,7 +1187,7 @@ msgid "" "after those default values. Example usage::" msgstr "" -#: ../../library/argparse.rst:678 +#: ../../library/argparse.rst:690 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='append')\n" @@ -1156,7 +1199,7 @@ msgstr "" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" "Namespace(foo=['1', '2'])" -#: ../../library/argparse.rst:683 +#: ../../library/argparse.rst:695 msgid "" "``'append_const'`` - This stores a list, and appends the value specified by " "the const_ keyword argument to the list; note that the const_ keyword " @@ -1165,7 +1208,7 @@ msgid "" "example::" msgstr "" -#: ../../library/argparse.rst:689 +#: ../../library/argparse.rst:701 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1183,7 +1226,7 @@ msgstr "" ">>> parser.parse_args('--str --int'.split())\n" "Namespace(types=[, ])" -#: ../../library/argparse.rst:695 +#: ../../library/argparse.rst:707 msgid "" "``'extend'`` - This stores a list and appends each item from the multi-value " "argument list to it. The ``'extend'`` action is typically used with the " @@ -1192,7 +1235,7 @@ msgid "" "will be appended to the list. Example usage::" msgstr "" -#: ../../library/argparse.rst:703 +#: ../../library/argparse.rst:715 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " @@ -1208,13 +1251,13 @@ msgstr "" "\"f4\"])\n" "Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -#: ../../library/argparse.rst:710 +#: ../../library/argparse.rst:722 msgid "" "``'count'`` - This counts the number of times a keyword argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" -#: ../../library/argparse.rst:713 +#: ../../library/argparse.rst:725 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" @@ -1222,11 +1265,11 @@ msgid "" "Namespace(verbose=3)" msgstr "" -#: ../../library/argparse.rst:718 +#: ../../library/argparse.rst:730 msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." msgstr "" -#: ../../library/argparse.rst:720 +#: ../../library/argparse.rst:732 msgid "" "``'help'`` - This prints a complete help message for all the options in the " "current parser and then exits. By default a help action is automatically " @@ -1234,14 +1277,14 @@ msgid "" "output is created." msgstr "" -#: ../../library/argparse.rst:725 +#: ../../library/argparse.rst:737 msgid "" "``'version'`` - This expects a ``version=`` keyword argument in the :meth:" "`~ArgumentParser.add_argument` call, and prints version information and " "exits when invoked::" msgstr "" -#: ../../library/argparse.rst:729 +#: ../../library/argparse.rst:741 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1257,13 +1300,13 @@ msgstr "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" -#: ../../library/argparse.rst:735 +#: ../../library/argparse.rst:747 msgid "" "Only actions that consume command-line arguments (e.g. ``'store'``, " "``'append'`` or ``'extend'``) can be used with positional arguments." msgstr "" -#: ../../library/argparse.rst:740 +#: ../../library/argparse.rst:752 msgid "" "You may also specify an arbitrary action by passing an :class:`Action` " "subclass or other object that implements the same interface. The :class:`!" @@ -1271,7 +1314,7 @@ msgid "" "boolean actions such as ``--foo`` and ``--no-foo``::" msgstr "" -#: ../../library/argparse.rst:745 +#: ../../library/argparse.rst:757 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -1285,7 +1328,7 @@ msgstr "" ">>> parser.parse_args(['--no-foo'])\n" "Namespace(foo=False)" -#: ../../library/argparse.rst:753 +#: ../../library/argparse.rst:765 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " "overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " @@ -1294,11 +1337,11 @@ msgid "" "their registered name." msgstr "" -#: ../../library/argparse.rst:758 +#: ../../library/argparse.rst:770 msgid "An example of a custom action::" msgstr "" -#: ../../library/argparse.rst:760 +#: ../../library/argparse.rst:772 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1319,15 +1362,15 @@ msgid "" "Namespace(bar='1', foo='2')" msgstr "" -#: ../../library/argparse.rst:778 +#: ../../library/argparse.rst:790 msgid "For more details, see :class:`Action`." msgstr "更多詳情請見 :class:`Action`。" -#: ../../library/argparse.rst:784 +#: ../../library/argparse.rst:796 msgid "nargs" msgstr "nargs" -#: ../../library/argparse.rst:786 +#: ../../library/argparse.rst:798 msgid "" ":class:`ArgumentParser` objects usually associate a single command-line " "argument with a single action to be taken. The ``nargs`` keyword argument " @@ -1336,13 +1379,13 @@ msgid "" "are:" msgstr "" -#: ../../library/argparse.rst:791 +#: ../../library/argparse.rst:803 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" -#: ../../library/argparse.rst:794 +#: ../../library/argparse.rst:806 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1356,13 +1399,13 @@ msgstr "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" -#: ../../library/argparse.rst:800 +#: ../../library/argparse.rst:812 msgid "" "Note that ``nargs=1`` produces a list of one item. This is different from " "the default, in which the item is produced by itself." msgstr "" -#: ../../library/argparse.rst:805 +#: ../../library/argparse.rst:817 msgid "" "``'?'``. One argument will be consumed from the command line if possible, " "and produced as a single item. If no command-line argument is present, the " @@ -1372,7 +1415,7 @@ msgid "" "produced. Some examples to illustrate this::" msgstr "" -#: ../../library/argparse.rst:812 +#: ../../library/argparse.rst:824 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1394,13 +1437,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" -#: ../../library/argparse.rst:822 +#: ../../library/argparse.rst:834 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "" -#: ../../library/argparse.rst:825 +#: ../../library/argparse.rst:837 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),\n" @@ -1426,7 +1469,7 @@ msgstr "" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" " outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:839 +#: ../../library/argparse.rst:851 msgid "" "``'*'``. All command-line arguments present are gathered into a list. Note " "that it generally doesn't make much sense to have more than one positional " @@ -1434,7 +1477,7 @@ msgid "" "``nargs='*'`` is possible. For example::" msgstr "" -#: ../../library/argparse.rst:844 +#: ../../library/argparse.rst:856 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1450,14 +1493,14 @@ msgstr "" ">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" "Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" -#: ../../library/argparse.rst:853 +#: ../../library/argparse.rst:865 msgid "" "``'+'``. Just like ``'*'``, all command-line args present are gathered into " "a list. Additionally, an error message will be generated if there wasn't at " "least one command-line argument present. For example::" msgstr "" -#: ../../library/argparse.rst:857 +#: ../../library/argparse.rst:869 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1475,7 +1518,7 @@ msgstr "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:865 +#: ../../library/argparse.rst:877 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " @@ -1484,11 +1527,11 @@ msgid "" "``'store_const'``) set ``nargs=0``." msgstr "" -#: ../../library/argparse.rst:875 +#: ../../library/argparse.rst:887 msgid "const" -msgstr "" +msgstr "const" -#: ../../library/argparse.rst:877 +#: ../../library/argparse.rst:889 msgid "" "The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to " "hold constant values that are not read from the command line but are " @@ -1496,7 +1539,7 @@ msgid "" "common uses of it are:" msgstr "" -#: ../../library/argparse.rst:881 +#: ../../library/argparse.rst:893 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " @@ -1506,7 +1549,7 @@ msgid "" "receive a default value of ``None``." msgstr "" -#: ../../library/argparse.rst:889 +#: ../../library/argparse.rst:901 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1516,17 +1559,17 @@ msgid "" "to be ``None`` instead. See the nargs_ description for examples." msgstr "" -#: ../../library/argparse.rst:896 +#: ../../library/argparse.rst:908 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." msgstr "" -#: ../../library/argparse.rst:903 +#: ../../library/argparse.rst:915 msgid "default" -msgstr "" +msgstr "default" -#: ../../library/argparse.rst:905 +#: ../../library/argparse.rst:917 msgid "" "All optional arguments and some positional arguments may be omitted at the " "command line. The ``default`` keyword argument of :meth:`~ArgumentParser." @@ -1536,7 +1579,7 @@ msgid "" "command line::" msgstr "" -#: ../../library/argparse.rst:912 +#: ../../library/argparse.rst:924 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1552,13 +1595,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:919 +#: ../../library/argparse.rst:931 msgid "" "If the target namespace already has an attribute set, the action *default* " "will not overwrite it::" msgstr "" -#: ../../library/argparse.rst:922 +#: ../../library/argparse.rst:934 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1570,7 +1613,7 @@ msgstr "" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" -#: ../../library/argparse.rst:927 +#: ../../library/argparse.rst:939 msgid "" "If the ``default`` value is a string, the parser parses the value as if it " "were a command-line argument. In particular, the parser applies any type_ " @@ -1578,7 +1621,7 @@ msgid "" "`Namespace` return value. Otherwise, the parser uses the value as is::" msgstr "" -#: ../../library/argparse.rst:932 +#: ../../library/argparse.rst:944 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -1592,13 +1635,13 @@ msgstr "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" -#: ../../library/argparse.rst:938 +#: ../../library/argparse.rst:950 msgid "" "For positional arguments with nargs_ equal to ``?`` or ``*``, the " "``default`` value is used when no command-line argument was present::" msgstr "" -#: ../../library/argparse.rst:941 +#: ../../library/argparse.rst:953 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -1614,20 +1657,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:948 +#: ../../library/argparse.rst:960 msgid "" "For required_ arguments, the ``default`` value is ignored. For example, this " "applies to positional arguments with nargs_ values other than ``?`` or " "``*``, or optional arguments marked as ``required=True``." msgstr "" -#: ../../library/argparse.rst:952 +#: ../../library/argparse.rst:964 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" msgstr "" -#: ../../library/argparse.rst:955 +#: ../../library/argparse.rst:967 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -1643,11 +1686,11 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:966 +#: ../../library/argparse.rst:978 msgid "type" -msgstr "" +msgstr "type" -#: ../../library/argparse.rst:968 +#: ../../library/argparse.rst:980 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -1656,13 +1699,13 @@ msgid "" "checking and type conversions to be performed." msgstr "" -#: ../../library/argparse.rst:974 +#: ../../library/argparse.rst:986 msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." msgstr "" -#: ../../library/argparse.rst:977 +#: ../../library/argparse.rst:989 msgid "" "The argument to ``type`` can be a callable that accepts a single string or " "the name of a registered type (see :meth:`~ArgumentParser.register`) If the " @@ -1671,11 +1714,11 @@ msgid "" "is displayed. Other exception types are not handled." msgstr "" -#: ../../library/argparse.rst:983 +#: ../../library/argparse.rst:995 msgid "Common built-in types and functions can be used as type converters:" msgstr "" -#: ../../library/argparse.rst:985 +#: ../../library/argparse.rst:997 msgid "" "import argparse\n" "import pathlib\n" @@ -1701,11 +1744,11 @@ msgstr "" "encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" -#: ../../library/argparse.rst:998 +#: ../../library/argparse.rst:1010 msgid "User defined functions can be used as well:" msgstr "" -#: ../../library/argparse.rst:1000 +#: ../../library/argparse.rst:1012 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -1723,14 +1766,14 @@ msgstr "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1010 +#: ../../library/argparse.rst:1022 msgid "" "The :func:`bool` function is not recommended as a type converter. All it " "does is convert empty strings to ``False`` and non-empty strings to " "``True``. This is usually not what is desired." msgstr "" -#: ../../library/argparse.rst:1014 +#: ../../library/argparse.rst:1026 msgid "" "In general, the ``type`` keyword is a convenience that should only be used " "for simple conversions that can only raise one of the three supported " @@ -1738,7 +1781,7 @@ msgid "" "management should be done downstream after the arguments are parsed." msgstr "" -#: ../../library/argparse.rst:1019 +#: ../../library/argparse.rst:1031 msgid "" "For example, JSON or YAML conversions have complex error cases that require " "better reporting than can be given by the ``type`` keyword. A :exc:`~json." @@ -1746,7 +1789,7 @@ msgid "" "exception would not be handled at all." msgstr "" -#: ../../library/argparse.rst:1024 +#: ../../library/argparse.rst:1036 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " "``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " @@ -1756,17 +1799,17 @@ msgid "" "files." msgstr "" -#: ../../library/argparse.rst:1031 +#: ../../library/argparse.rst:1043 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "" -#: ../../library/argparse.rst:1038 +#: ../../library/argparse.rst:1050 msgid "choices" -msgstr "" +msgstr "choices" -#: ../../library/argparse.rst:1040 +#: ../../library/argparse.rst:1052 msgid "" "Some command-line arguments should be selected from a restricted set of " "values. These can be handled by passing a sequence object as the *choices* " @@ -1775,7 +1818,7 @@ msgid "" "be displayed if the argument was not one of the acceptable values::" msgstr "" -#: ../../library/argparse.rst:1046 +#: ../../library/argparse.rst:1058 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -1795,26 +1838,26 @@ msgstr "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" -#: ../../library/argparse.rst:1055 +#: ../../library/argparse.rst:1067 msgid "" "Note that inclusion in the *choices* sequence is checked after any type_ " "conversions have been performed, so the type of the objects in the *choices* " "sequence should match the type_ specified." msgstr "" -#: ../../library/argparse.rst:1059 +#: ../../library/argparse.rst:1071 msgid "" "Any sequence can be passed as the *choices* value, so :class:`list` " "objects, :class:`tuple` objects, and custom sequences are all supported." msgstr "" -#: ../../library/argparse.rst:1062 +#: ../../library/argparse.rst:1074 msgid "" "Use of :class:`enum.Enum` is not recommended because it is difficult to " "control its appearance in usage, help, and error messages." msgstr "" -#: ../../library/argparse.rst:1065 +#: ../../library/argparse.rst:1077 msgid "" "Formatted choices override the default *metavar* which is normally derived " "from *dest*. This is usually what you want because the user never sees the " @@ -1822,11 +1865,11 @@ msgid "" "are many choices), just specify an explicit metavar_." msgstr "" -#: ../../library/argparse.rst:1074 +#: ../../library/argparse.rst:1086 msgid "required" -msgstr "" +msgstr "required" -#: ../../library/argparse.rst:1076 +#: ../../library/argparse.rst:1088 msgid "" "In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " @@ -1834,7 +1877,7 @@ msgid "" "the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::" msgstr "" -#: ../../library/argparse.rst:1081 +#: ../../library/argparse.rst:1093 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -1852,24 +1895,24 @@ msgstr "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" -#: ../../library/argparse.rst:1089 +#: ../../library/argparse.rst:1101 msgid "" "As the example shows, if an option is marked as ``required``, :meth:" "`~ArgumentParser.parse_args` will report an error if that option is not " "present at the command line." msgstr "" -#: ../../library/argparse.rst:1095 +#: ../../library/argparse.rst:1107 msgid "" "Required options are generally considered bad form because users expect " "*options* to be *optional*, and thus they should be avoided when possible." msgstr "" -#: ../../library/argparse.rst:1102 +#: ../../library/argparse.rst:1114 msgid "help" -msgstr "幫助" +msgstr "help" -#: ../../library/argparse.rst:1104 +#: ../../library/argparse.rst:1116 msgid "" "The ``help`` value is a string containing a brief description of the " "argument. When a user requests help (usually by using ``-h`` or ``--help`` " @@ -1877,7 +1920,7 @@ msgid "" "each argument." msgstr "" -#: ../../library/argparse.rst:1109 +#: ../../library/argparse.rst:1121 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " @@ -1886,7 +1929,7 @@ msgid "" "``%(type)s``, etc.::" msgstr "" -#: ../../library/argparse.rst:1114 +#: ../../library/argparse.rst:1126 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -1912,19 +1955,19 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1126 +#: ../../library/argparse.rst:1138 msgid "" "As the help string supports %-formatting, if you want a literal ``%`` to " "appear in the help string, you must escape it as ``%%``." msgstr "" -#: ../../library/argparse.rst:1129 +#: ../../library/argparse.rst:1141 msgid "" ":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" msgstr "" -#: ../../library/argparse.rst:1132 +#: ../../library/argparse.rst:1144 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -1942,11 +1985,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1144 +#: ../../library/argparse.rst:1156 msgid "metavar" msgstr "metavar" -#: ../../library/argparse.rst:1146 +#: ../../library/argparse.rst:1158 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " "refer to each expected argument. By default, :class:`!ArgumentParser` " @@ -1958,7 +2001,7 @@ msgid "" "command-line argument will be referred to as ``FOO``. An example::" msgstr "" -#: ../../library/argparse.rst:1155 +#: ../../library/argparse.rst:1167 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -1990,11 +2033,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO" -#: ../../library/argparse.rst:1170 +#: ../../library/argparse.rst:1182 msgid "An alternative name can be specified with ``metavar``::" msgstr "" -#: ../../library/argparse.rst:1172 +#: ../../library/argparse.rst:1184 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2026,21 +2069,21 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo YYY" -#: ../../library/argparse.rst:1187 +#: ../../library/argparse.rst:1199 msgid "" "Note that ``metavar`` only changes the *displayed* name - the name of the " "attribute on the :meth:`~ArgumentParser.parse_args` object is still " "determined by the dest_ value." msgstr "" -#: ../../library/argparse.rst:1191 +#: ../../library/argparse.rst:1203 msgid "" "Different values of ``nargs`` may cause the metavar to be used multiple " "times. Providing a tuple to ``metavar`` specifies a different display for " "each of the arguments::" msgstr "" -#: ../../library/argparse.rst:1195 +#: ../../library/argparse.rst:1207 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2064,11 +2107,11 @@ msgstr "" " -x X X\n" " --foo bar baz" -#: ../../library/argparse.rst:1210 +#: ../../library/argparse.rst:1222 msgid "dest" msgstr "dest" -#: ../../library/argparse.rst:1212 +#: ../../library/argparse.rst:1224 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " @@ -2078,7 +2121,7 @@ msgid "" "add_argument`::" msgstr "" -#: ../../library/argparse.rst:1219 +#: ../../library/argparse.rst:1231 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" @@ -2090,7 +2133,7 @@ msgstr "" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1224 +#: ../../library/argparse.rst:1236 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -2102,7 +2145,7 @@ msgid "" "below illustrate this behavior::" msgstr "" -#: ../../library/argparse.rst:1233 +#: ../../library/argparse.rst:1245 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" @@ -2120,11 +2163,11 @@ msgstr "" ">>> parser.parse_args('--foo 1 -y 2'.split())\n" "Namespace(foo_bar='1', x='2')" -#: ../../library/argparse.rst:1241 +#: ../../library/argparse.rst:1253 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "" -#: ../../library/argparse.rst:1243 +#: ../../library/argparse.rst:1255 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" @@ -2136,11 +2179,11 @@ msgstr "" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1252 +#: ../../library/argparse.rst:1264 msgid "deprecated" -msgstr "" +msgstr "deprecated" -#: ../../library/argparse.rst:1254 +#: ../../library/argparse.rst:1266 msgid "" "During a project's lifetime, some arguments may need to be removed from the " "command line. Before removing them, you should inform your users that the " @@ -2151,7 +2194,7 @@ msgid "" "will be printed to :data:`sys.stderr` when the argument is used::" msgstr "" -#: ../../library/argparse.rst:1264 +#: ../../library/argparse.rst:1276 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='snake.py')\n" @@ -2171,11 +2214,11 @@ msgstr "" "snake.py: warning: option '--legs' is deprecated\n" "Namespace(legs=4)" -#: ../../library/argparse.rst:1277 +#: ../../library/argparse.rst:1289 msgid "Action classes" -msgstr "" +msgstr "Action 類別" -#: ../../library/argparse.rst:1279 +#: ../../library/argparse.rst:1291 msgid "" ":class:`!Action` classes implement the Action API, a callable which returns " "a callable which processes arguments from the command-line. Any object which " @@ -2183,7 +2226,7 @@ msgid "" "`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1288 +#: ../../library/argparse.rst:1300 msgid "" ":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " "the information needed to parse a single argument from one or more strings " @@ -2192,7 +2235,7 @@ msgid "" "`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" -#: ../../library/argparse.rst:1294 +#: ../../library/argparse.rst:1306 msgid "" "Instances of :class:`!Action` (or return value of any callable to the " "``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" @@ -2201,46 +2244,46 @@ msgid "" "is to call :meth:`!Action.__init__`." msgstr "" -#: ../../library/argparse.rst:1302 +#: ../../library/argparse.rst:1314 msgid "" ":class:`!Action` instances should be callable, so subclasses must override " "the :meth:`!__call__` method, which should accept four parameters:" msgstr "" -#: ../../library/argparse.rst:1305 +#: ../../library/argparse.rst:1317 msgid "" "*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "" -#: ../../library/argparse.rst:1307 +#: ../../library/argparse.rst:1319 msgid "" "*namespace* - The :class:`Namespace` object that will be returned by :meth:" "`~ArgumentParser.parse_args`. Most actions add an attribute to this object " "using :func:`setattr`." msgstr "" -#: ../../library/argparse.rst:1311 +#: ../../library/argparse.rst:1323 msgid "" "*values* - The associated command-line arguments, with any type conversions " "applied. Type conversions are specified with the type_ keyword argument to :" "meth:`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1315 +#: ../../library/argparse.rst:1327 msgid "" "*option_string* - The option string that was used to invoke this action. The " "``option_string`` argument is optional, and will be absent if the action is " "associated with a positional argument." msgstr "" -#: ../../library/argparse.rst:1319 +#: ../../library/argparse.rst:1331 msgid "" "The :meth:`!__call__` method may perform arbitrary actions, but will " "typically set attributes on the ``namespace`` based on ``dest`` and " "``values``." msgstr "" -#: ../../library/argparse.rst:1324 +#: ../../library/argparse.rst:1336 msgid "" ":class:`!Action` subclasses can define a :meth:`!format_usage` method that " "takes no argument and return a string which will be used when printing the " @@ -2248,47 +2291,47 @@ msgid "" "will be used." msgstr "" -#: ../../library/argparse.rst:1330 +#: ../../library/argparse.rst:1342 msgid "The parse_args() method" msgstr "parse_args() 方法" -#: ../../library/argparse.rst:1334 +#: ../../library/argparse.rst:1346 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" -#: ../../library/argparse.rst:1337 +#: ../../library/argparse.rst:1349 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " "created and how they are assigned. See the documentation for :meth:`!" "add_argument` for details." msgstr "" -#: ../../library/argparse.rst:1341 +#: ../../library/argparse.rst:1353 msgid "" "args_ - List of strings to parse. The default is taken from :data:`sys." "argv`." msgstr "" -#: ../../library/argparse.rst:1344 +#: ../../library/argparse.rst:1356 msgid "" "namespace_ - An object to take the attributes. The default is a new empty :" "class:`Namespace` object." msgstr "" -#: ../../library/argparse.rst:1349 +#: ../../library/argparse.rst:1361 msgid "Option value syntax" msgstr "" -#: ../../library/argparse.rst:1351 +#: ../../library/argparse.rst:1363 msgid "" "The :meth:`~ArgumentParser.parse_args` method supports several ways of " "specifying the value of an option (if it takes one). In the simplest case, " "the option and its value are passed as two separate arguments::" msgstr "" -#: ../../library/argparse.rst:1355 +#: ../../library/argparse.rst:1367 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2306,14 +2349,14 @@ msgstr "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1363 +#: ../../library/argparse.rst:1375 msgid "" "For long options (options with names longer than a single character), the " "option and value can also be passed as a single command-line argument, using " "``=`` to separate them::" msgstr "" -#: ../../library/argparse.rst:1367 +#: ../../library/argparse.rst:1379 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" @@ -2321,13 +2364,13 @@ msgstr "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1370 +#: ../../library/argparse.rst:1382 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "" -#: ../../library/argparse.rst:1373 +#: ../../library/argparse.rst:1385 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" @@ -2335,13 +2378,13 @@ msgstr "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" -#: ../../library/argparse.rst:1376 +#: ../../library/argparse.rst:1388 msgid "" "Several short options can be joined together, using only a single ``-`` " "prefix, as long as only the last option (or none of them) requires a value::" msgstr "" -#: ../../library/argparse.rst:1379 +#: ../../library/argparse.rst:1391 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -2357,11 +2400,11 @@ msgstr "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" -#: ../../library/argparse.rst:1388 +#: ../../library/argparse.rst:1400 msgid "Invalid arguments" msgstr "無效引數" -#: ../../library/argparse.rst:1390 +#: ../../library/argparse.rst:1402 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -2369,7 +2412,7 @@ msgid "" "an error, it exits and prints the error along with a usage message::" msgstr "" -#: ../../library/argparse.rst:1395 +#: ../../library/argparse.rst:1407 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -2390,12 +2433,30 @@ msgid "" "usage: PROG [-h] [--foo FOO] [bar]\n" "PROG: error: extra arguments found: badger" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo', type=int)\n" +">>> parser.add_argument('bar', nargs='?')\n" +"\n" +">>> # 無效型別\n" +">>> parser.parse_args(['--foo', 'spam'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: argument --foo: invalid int value: 'spam'\n" +"\n" +">>> # 無效選項\n" +">>> parser.parse_args(['--bar'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: no such option: --bar\n" +"\n" +">>> # 錯誤引數數量\n" +">>> parser.parse_args(['spam', 'badger'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: extra arguments found: badger" -#: ../../library/argparse.rst:1416 +#: ../../library/argparse.rst:1428 msgid "Arguments containing ``-``" msgstr "包含 ``-`` 的引數" -#: ../../library/argparse.rst:1418 +#: ../../library/argparse.rst:1430 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -2407,7 +2468,7 @@ msgid "" "negative numbers::" msgstr "" -#: ../../library/argparse.rst:1426 +#: ../../library/argparse.rst:1438 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2440,7 +2501,7 @@ msgid "" "PROG: error: argument -1: expected one argument" msgstr "" -#: ../../library/argparse.rst:1456 +#: ../../library/argparse.rst:1468 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -2448,7 +2509,7 @@ msgid "" "positional argument::" msgstr "" -#: ../../library/argparse.rst:1461 +#: ../../library/argparse.rst:1473 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" @@ -2456,24 +2517,24 @@ msgstr "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1464 +#: ../../library/argparse.rst:1476 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." msgstr "" -#: ../../library/argparse.rst:1470 +#: ../../library/argparse.rst:1482 msgid "Argument abbreviations (prefix matching)" -msgstr "" +msgstr "引數縮寫 (前綴匹配)" -#: ../../library/argparse.rst:1472 +#: ../../library/argparse.rst:1484 msgid "" "The :meth:`~ArgumentParser.parse_args` method :ref:`by default " "` allows long options to be abbreviated to a prefix, if the " "abbreviation is unambiguous (the prefix matches a unique option)::" msgstr "" -#: ../../library/argparse.rst:1476 +#: ../../library/argparse.rst:1488 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -2497,17 +2558,17 @@ msgstr "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" -#: ../../library/argparse.rst:1487 +#: ../../library/argparse.rst:1499 msgid "" "An error is produced for arguments that could produce more than one options. " "This feature can be disabled by setting :ref:`allow_abbrev` to ``False``." msgstr "" -#: ../../library/argparse.rst:1493 +#: ../../library/argparse.rst:1505 msgid "Beyond ``sys.argv``" msgstr "" -#: ../../library/argparse.rst:1495 +#: ../../library/argparse.rst:1507 msgid "" "Sometimes it may be useful to have an :class:`ArgumentParser` parse " "arguments other than those of :data:`sys.argv`. This can be accomplished by " @@ -2515,7 +2576,7 @@ msgid "" "useful for testing at the interactive prompt::" msgstr "" -#: ../../library/argparse.rst:1500 +#: ../../library/argparse.rst:1512 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -2541,24 +2602,24 @@ msgstr "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" -#: ../../library/argparse.rst:1515 +#: ../../library/argparse.rst:1527 msgid "The Namespace object" msgstr "命名空間物件" -#: ../../library/argparse.rst:1519 +#: ../../library/argparse.rst:1531 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." msgstr "" -#: ../../library/argparse.rst:1522 +#: ../../library/argparse.rst:1534 msgid "" "This class is deliberately simple, just an :class:`object` subclass with a " "readable string representation. If you prefer to have dict-like view of the " "attributes, you can use the standard Python idiom, :func:`vars`::" msgstr "" -#: ../../library/argparse.rst:1526 +#: ../../library/argparse.rst:1538 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2572,14 +2633,14 @@ msgstr "" ">>> vars(args)\n" "{'foo': 'BAR'}" -#: ../../library/argparse.rst:1532 +#: ../../library/argparse.rst:1544 msgid "" "It may also be useful to have an :class:`ArgumentParser` assign attributes " "to an already existing object, rather than a new :class:`Namespace` object. " "This can be achieved by specifying the ``namespace=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:1536 +#: ../../library/argparse.rst:1548 msgid "" ">>> class C:\n" "... pass\n" @@ -2601,15 +2662,15 @@ msgstr "" ">>> c.foo\n" "'BAR'" -#: ../../library/argparse.rst:1548 +#: ../../library/argparse.rst:1560 msgid "Other utilities" msgstr "" -#: ../../library/argparse.rst:1551 +#: ../../library/argparse.rst:1563 msgid "Sub-commands" -msgstr "" +msgstr "子命令" -#: ../../library/argparse.rst:1558 +#: ../../library/argparse.rst:1570 msgid "" "Many programs split up their functionality into a number of subcommands, for " "example, the ``svn`` program can invoke subcommands like ``svn checkout``, " @@ -2624,69 +2685,69 @@ msgid "" "returns an :class:`!ArgumentParser` object that can be modified as usual." msgstr "" -#: ../../library/argparse.rst:1570 +#: ../../library/argparse.rst:1582 msgid "Description of parameters:" msgstr "參數的解釋:" -#: ../../library/argparse.rst:1572 +#: ../../library/argparse.rst:1584 msgid "" "*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " "positional arguments" msgstr "" -#: ../../library/argparse.rst:1576 +#: ../../library/argparse.rst:1588 msgid "" "*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "" -#: ../../library/argparse.rst:1579 +#: ../../library/argparse.rst:1591 msgid "" "*prog* - usage information that will be displayed with sub-command help, by " "default the name of the program and any positional arguments before the " "subparser argument" msgstr "" -#: ../../library/argparse.rst:1583 +#: ../../library/argparse.rst:1595 msgid "" "*parser_class* - class which will be used to create sub-parser instances, by " "default the class of the current parser (e.g. :class:`ArgumentParser`)" msgstr "" -#: ../../library/argparse.rst:1586 +#: ../../library/argparse.rst:1598 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "" -#: ../../library/argparse.rst:1589 +#: ../../library/argparse.rst:1601 msgid "" "dest_ - name of the attribute under which sub-command name will be stored; " "by default ``None`` and no value is stored" msgstr "" -#: ../../library/argparse.rst:1592 +#: ../../library/argparse.rst:1604 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "" -#: ../../library/argparse.rst:1595 +#: ../../library/argparse.rst:1607 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "" -#: ../../library/argparse.rst:1597 +#: ../../library/argparse.rst:1609 msgid "" "metavar_ - string presenting available subcommands in help; by default it is " "``None`` and presents subcommands in form {cmd1, cmd2, ..}" msgstr "" -#: ../../library/argparse.rst:1600 +#: ../../library/argparse.rst:1612 msgid "Some example usage::" msgstr "一些使用範例: ::" -#: ../../library/argparse.rst:1602 +#: ../../library/argparse.rst:1614 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -2709,7 +2770,7 @@ msgid "" "Namespace(baz='Z', foo=True)" msgstr "" -#: ../../library/argparse.rst:1621 +#: ../../library/argparse.rst:1633 msgid "" "Note that the object returned by :meth:`parse_args` will only contain " "attributes for the main parser and the subparser that was selected by the " @@ -2719,7 +2780,7 @@ msgid "" "``baz`` attributes are present." msgstr "" -#: ../../library/argparse.rst:1628 +#: ../../library/argparse.rst:1640 msgid "" "Similarly, when a help message is requested from a subparser, only the help " "for that particular parser will be printed. The help message will not " @@ -2728,7 +2789,7 @@ msgid "" "to :meth:`~_SubParsersAction.add_parser` as above.)" msgstr "" -#: ../../library/argparse.rst:1636 +#: ../../library/argparse.rst:1648 msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" @@ -2786,14 +2847,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1664 +#: ../../library/argparse.rst:1676 msgid "" "The :meth:`add_subparsers` method also supports ``title`` and " "``description`` keyword arguments. When either is present, the subparser's " "commands will appear in their own group in the help output. For example::" msgstr "" -#: ../../library/argparse.rst:1668 +#: ../../library/argparse.rst:1680 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -2829,7 +2890,7 @@ msgstr "" "\n" " {foo,bar} additional help" -#: ../../library/argparse.rst:1685 +#: ../../library/argparse.rst:1697 msgid "" "Furthermore, :meth:`~_SubParsersAction.add_parser` supports an additional " "*aliases* argument, which allows multiple strings to refer to the same " @@ -2837,7 +2898,7 @@ msgid "" "``checkout``::" msgstr "" -#: ../../library/argparse.rst:1690 +#: ../../library/argparse.rst:1702 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers()\n" @@ -2853,13 +2914,13 @@ msgstr "" ">>> parser.parse_args(['co', 'bar'])\n" "Namespace(foo='bar')" -#: ../../library/argparse.rst:1697 +#: ../../library/argparse.rst:1709 msgid "" ":meth:`~_SubParsersAction.add_parser` supports also an additional " "*deprecated* argument, which allows to deprecate the subparser." msgstr "" -#: ../../library/argparse.rst:1711 +#: ../../library/argparse.rst:1723 msgid "" "One particularly effective way of handling subcommands is to combine the use " "of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so " @@ -2867,7 +2928,7 @@ msgid "" "example::" msgstr "" -#: ../../library/argparse.rst:1716 +#: ../../library/argparse.rst:1728 msgid "" ">>> # subcommand functions\n" ">>> def foo(args):\n" @@ -2902,7 +2963,7 @@ msgid "" "((XYZYX))" msgstr "" -#: ../../library/argparse.rst:1748 +#: ../../library/argparse.rst:1760 msgid "" "This way, you can let :meth:`parse_args` do the job of calling the " "appropriate function after argument parsing is complete. Associating " @@ -2912,7 +2973,7 @@ msgid "" "argument to the :meth:`add_subparsers` call will work::" msgstr "" -#: ../../library/argparse.rst:1755 +#: ../../library/argparse.rst:1767 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -2932,15 +2993,15 @@ msgstr "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1764 +#: ../../library/argparse.rst:1776 msgid "New *required* keyword-only parameter." msgstr "" -#: ../../library/argparse.rst:1769 +#: ../../library/argparse.rst:1781 msgid "FileType objects" msgstr "FileType 物件" -#: ../../library/argparse.rst:1773 +#: ../../library/argparse.rst:1785 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " "argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" @@ -2949,7 +3010,7 @@ msgid "" "the :func:`open` function for more details)::" msgstr "" -#: ../../library/argparse.rst:1779 +#: ../../library/argparse.rst:1791 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -2967,14 +3028,14 @@ msgstr "" "Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " "raw=<_io.FileIO name='raw.dat' mode='wb'>)" -#: ../../library/argparse.rst:1785 +#: ../../library/argparse.rst:1797 msgid "" "FileType objects understand the pseudo-argument ``'-'`` and automatically " "convert this into :data:`sys.stdin` for readable :class:`FileType` objects " "and :data:`sys.stdout` for writable :class:`FileType` objects::" msgstr "" -#: ../../library/argparse.rst:1789 +#: ../../library/argparse.rst:1801 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" @@ -2986,15 +3047,15 @@ msgstr "" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1794 +#: ../../library/argparse.rst:1806 msgid "Added the *encodings* and *errors* parameters." msgstr "" -#: ../../library/argparse.rst:1799 +#: ../../library/argparse.rst:1811 msgid "Argument groups" msgstr "" -#: ../../library/argparse.rst:1804 +#: ../../library/argparse.rst:1816 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " @@ -3003,7 +3064,7 @@ msgid "" "method::" msgstr "" -#: ../../library/argparse.rst:1810 +#: ../../library/argparse.rst:1822 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3027,7 +3088,7 @@ msgstr "" " bar bar help\n" " --foo FOO foo help" -#: ../../library/argparse.rst:1821 +#: ../../library/argparse.rst:1833 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" @@ -3038,7 +3099,7 @@ msgid "" "this display::" msgstr "" -#: ../../library/argparse.rst:1829 +#: ../../library/argparse.rst:1841 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3076,7 +3137,7 @@ msgstr "" "\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1847 +#: ../../library/argparse.rst:1859 msgid "" "The optional, keyword-only parameters argument_default_ and " "conflict_handler_ allow for finer-grained control of the behavior of the " @@ -3085,13 +3146,13 @@ msgid "" "rather than the entire parser." msgstr "" -#: ../../library/argparse.rst:1852 +#: ../../library/argparse.rst:1864 msgid "" "Note that any arguments not in your user-defined groups will end up back in " "the usual \"positional arguments\" and \"optional arguments\" sections." msgstr "" -#: ../../library/argparse.rst:1855 +#: ../../library/argparse.rst:1867 msgid "" "Calling :meth:`add_argument_group` on an argument group is deprecated. This " "feature was never supported and does not always work correctly. The function " @@ -3099,18 +3160,18 @@ msgid "" "future." msgstr "" -#: ../../library/argparse.rst:1863 +#: ../../library/argparse.rst:1875 msgid "Mutual exclusion" msgstr "" -#: ../../library/argparse.rst:1867 +#: ../../library/argparse.rst:1879 msgid "" "Create a mutually exclusive group. :mod:`!argparse` will make sure that only " "one of the arguments in the mutually exclusive group was present on the " "command line::" msgstr "" -#: ../../library/argparse.rst:1871 +#: ../../library/argparse.rst:1883 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -3136,14 +3197,14 @@ msgstr "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" -#: ../../library/argparse.rst:1883 +#: ../../library/argparse.rst:1895 msgid "" "The :meth:`add_mutually_exclusive_group` method also accepts a *required* " "argument, to indicate that at least one of the mutually exclusive arguments " "is required::" msgstr "" -#: ../../library/argparse.rst:1887 +#: ../../library/argparse.rst:1899 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -3161,7 +3222,7 @@ msgstr "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:1895 +#: ../../library/argparse.rst:1907 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." @@ -3169,7 +3230,7 @@ msgid "" "argument group that has a title and description. For example::" msgstr "" -#: ../../library/argparse.rst:1901 +#: ../../library/argparse.rst:1913 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -3205,7 +3266,7 @@ msgstr "" " --foo FOO foo help\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1918 +#: ../../library/argparse.rst:1930 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group is deprecated. These features were never " @@ -3213,11 +3274,11 @@ msgid "" "by accident through inheritance and will be removed in the future." msgstr "" -#: ../../library/argparse.rst:1926 +#: ../../library/argparse.rst:1938 msgid "Parser defaults" msgstr "" -#: ../../library/argparse.rst:1930 +#: ../../library/argparse.rst:1942 msgid "" "Most of the time, the attributes of the object returned by :meth:" "`parse_args` will be fully determined by inspecting the command-line " @@ -3226,7 +3287,7 @@ msgid "" "command line to be added::" msgstr "" -#: ../../library/argparse.rst:1936 +#: ../../library/argparse.rst:1948 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -3240,12 +3301,12 @@ msgstr "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:1942 +#: ../../library/argparse.rst:1954 msgid "" "Note that parser-level defaults always override argument-level defaults::" msgstr "" -#: ../../library/argparse.rst:1944 +#: ../../library/argparse.rst:1956 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -3259,20 +3320,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" -#: ../../library/argparse.rst:1950 +#: ../../library/argparse.rst:1962 msgid "" "Parser-level defaults can be particularly useful when working with multiple " "parsers. See the :meth:`~ArgumentParser.add_subparsers` method for an " "example of this type." msgstr "" -#: ../../library/argparse.rst:1956 +#: ../../library/argparse.rst:1968 msgid "" "Get the default value for a namespace attribute, as set by either :meth:" "`~ArgumentParser.add_argument` or by :meth:`~ArgumentParser.set_defaults`::" msgstr "" -#: ../../library/argparse.rst:1960 +#: ../../library/argparse.rst:1972 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" @@ -3284,54 +3345,54 @@ msgstr "" ">>> parser.get_default('foo')\n" "'badger'" -#: ../../library/argparse.rst:1967 +#: ../../library/argparse.rst:1979 msgid "Printing help" msgstr "印出幫助訊息" -#: ../../library/argparse.rst:1969 +#: ../../library/argparse.rst:1981 msgid "" "In most typical applications, :meth:`~ArgumentParser.parse_args` will take " "care of formatting and printing any usage or error messages. However, " "several formatting methods are available:" msgstr "" -#: ../../library/argparse.rst:1975 +#: ../../library/argparse.rst:1987 msgid "" "Print a brief description of how the :class:`ArgumentParser` should be " "invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is " "assumed." msgstr "" -#: ../../library/argparse.rst:1981 +#: ../../library/argparse.rst:1993 msgid "" "Print a help message, including the program usage and information about the " "arguments registered with the :class:`ArgumentParser`. If *file* is " "``None``, :data:`sys.stdout` is assumed." msgstr "" -#: ../../library/argparse.rst:1985 +#: ../../library/argparse.rst:1997 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "" -#: ../../library/argparse.rst:1990 +#: ../../library/argparse.rst:2002 msgid "" "Return a string containing a brief description of how the :class:" "`ArgumentParser` should be invoked on the command line." msgstr "" -#: ../../library/argparse.rst:1995 +#: ../../library/argparse.rst:2007 msgid "" "Return a string containing a help message, including the program usage and " "information about the arguments registered with the :class:`ArgumentParser`." msgstr "" -#: ../../library/argparse.rst:2000 +#: ../../library/argparse.rst:2012 msgid "Partial parsing" msgstr "" -#: ../../library/argparse.rst:2004 +#: ../../library/argparse.rst:2016 msgid "" "Sometimes a script may only parse a few of the command-line arguments, " "passing the remaining arguments on to another script or program. In these " @@ -3342,7 +3403,7 @@ msgid "" "remaining argument strings." msgstr "" -#: ../../library/argparse.rst:2013 +#: ../../library/argparse.rst:2025 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -3356,7 +3417,7 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2020 +#: ../../library/argparse.rst:2032 msgid "" ":ref:`Prefix matching ` rules apply to :meth:" "`~ArgumentParser.parse_known_args`. The parser may consume an option even if " @@ -3364,11 +3425,11 @@ msgid "" "remaining arguments list." msgstr "" -#: ../../library/argparse.rst:2027 +#: ../../library/argparse.rst:2039 msgid "Customizing file parsing" msgstr "" -#: ../../library/argparse.rst:2031 +#: ../../library/argparse.rst:2043 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -3376,20 +3437,20 @@ msgid "" "reading." msgstr "" -#: ../../library/argparse.rst:2036 +#: ../../library/argparse.rst:2048 msgid "" "This method takes a single argument *arg_line* which is a string read from " "the argument file. It returns a list of arguments parsed from this string. " "The method is called once per line read from the argument file, in order." msgstr "" -#: ../../library/argparse.rst:2040 +#: ../../library/argparse.rst:2052 msgid "" "A useful override of this method is one that treats each space-separated " "word as an argument. The following example demonstrates how to do this::" msgstr "" -#: ../../library/argparse.rst:2043 +#: ../../library/argparse.rst:2055 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -3399,18 +3460,18 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2049 +#: ../../library/argparse.rst:2061 msgid "Exiting methods" msgstr "" -#: ../../library/argparse.rst:2053 +#: ../../library/argparse.rst:2065 msgid "" "This method terminates the program, exiting with the specified *status* and, " "if given, it prints a *message* to :data:`sys.stderr` before that. The user " "can override this method to handle these steps differently::" msgstr "" -#: ../../library/argparse.rst:2057 +#: ../../library/argparse.rst:2069 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -3424,17 +3485,17 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2065 +#: ../../library/argparse.rst:2077 msgid "" "This method prints a usage message, including the *message*, to :data:`sys." "stderr` and terminates the program with a status code of 2." msgstr "" -#: ../../library/argparse.rst:2070 +#: ../../library/argparse.rst:2082 msgid "Intermixed parsing" msgstr "" -#: ../../library/argparse.rst:2075 +#: ../../library/argparse.rst:2087 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -3442,7 +3503,7 @@ msgid "" "parsing style." msgstr "" -#: ../../library/argparse.rst:2080 +#: ../../library/argparse.rst:2092 msgid "" "These parsers do not support all the :mod:`!argparse` features, and will " "raise exceptions if unsupported features are used. In particular, " @@ -3450,7 +3511,7 @@ msgid "" "positionals are not supported." msgstr "" -#: ../../library/argparse.rst:2085 +#: ../../library/argparse.rst:2097 msgid "" "The following example shows the difference between :meth:`~ArgumentParser." "parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " @@ -3458,7 +3519,7 @@ msgid "" "collects all the positionals into ``rest``. ::" msgstr "" -#: ../../library/argparse.rst:2091 +#: ../../library/argparse.rst:2103 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3478,7 +3539,7 @@ msgstr "" ">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n" "Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])" -#: ../../library/argparse.rst:2100 +#: ../../library/argparse.rst:2112 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -3486,11 +3547,11 @@ msgid "" "there are any remaining unparsed argument strings." msgstr "" -#: ../../library/argparse.rst:2109 +#: ../../library/argparse.rst:2121 msgid "Registering custom types or actions" msgstr "" -#: ../../library/argparse.rst:2113 +#: ../../library/argparse.rst:2125 msgid "" "Sometimes it's desirable to use a custom string in error messages to provide " "more user-friendly output. In these cases, :meth:`!register` can be used to " @@ -3498,7 +3559,7 @@ msgid "" "the type by their registered name instead of their callable name." msgstr "" -#: ../../library/argparse.rst:2118 +#: ../../library/argparse.rst:2130 msgid "" "The :meth:`!register` method accepts three arguments - a *registry_name*, " "specifying the internal registry where the object will be stored (e.g., " @@ -3506,12 +3567,12 @@ msgid "" "be registered, and object, the callable to be registered." msgstr "" -#: ../../library/argparse.rst:2123 +#: ../../library/argparse.rst:2135 msgid "" "The following example shows how to register a custom type with a parser::" msgstr "" -#: ../../library/argparse.rst:2125 +#: ../../library/argparse.rst:2137 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -3527,42 +3588,42 @@ msgid "" "PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" msgstr "" -#: ../../library/argparse.rst:2137 +#: ../../library/argparse.rst:2149 msgid "Exceptions" msgstr "例外" -#: ../../library/argparse.rst:2141 +#: ../../library/argparse.rst:2153 msgid "An error from creating or using an argument (optional or positional)." msgstr "" -#: ../../library/argparse.rst:2143 +#: ../../library/argparse.rst:2155 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "" -#: ../../library/argparse.rst:2148 +#: ../../library/argparse.rst:2160 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "" -#: ../../library/argparse.rst:2152 +#: ../../library/argparse.rst:2164 msgid "Guides and Tutorials" msgstr "" -#: ../../library/argparse.rst:803 +#: ../../library/argparse.rst:815 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/argparse.rst:803 ../../library/argparse.rst:837 -#: ../../library/argparse.rst:851 +#: ../../library/argparse.rst:815 ../../library/argparse.rst:849 +#: ../../library/argparse.rst:863 msgid "in argparse module" msgstr "於 argparse 模組中" -#: ../../library/argparse.rst:837 +#: ../../library/argparse.rst:849 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/argparse.rst:851 +#: ../../library/argparse.rst:863 msgid "+ (plus)" msgstr "+ (加號)" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index dba9cad94d..d668319414 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -229,8 +229,8 @@ msgid "" "and then exit." msgstr "" "如果在呼叫 :meth:`run_forever` 之前呼叫 :meth:`stop`,則迴圈將使用超時為零的" -"方式輪詢 I/O 選擇器,運行所有回應 I/O 事件(以及已經排程的事件)的回呼函數," -"然後退出。" +"方式輪詢 I/O 選擇器,運行所有回應 I/O 事件(以及已經排程的事件)的回呼,然後" +"退出。" #: ../../library/asyncio-eventloop.rst:134 msgid "" diff --git a/library/cmdlinelibs.po b/library/cmdlinelibs.po new file mode 100644 index 0000000000..74afa150da --- /dev/null +++ b/library/cmdlinelibs.po @@ -0,0 +1,32 @@ +# Copyright (C) 2001-2024, 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: 2024-12-29 11:18+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-" +"tw)\n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../library/cmdlinelibs.rst:5 +msgid "Command Line Interface Libraries" +msgstr "命令列介面函式庫" + +#: ../../library/cmdlinelibs.rst:7 +msgid "" +"The modules described in this chapter assist with implementing command line " +"and terminal interfaces for applications." +msgstr "本章節所描述的模組協助實作應用程式的命令列與終端介面。" + +#: ../../library/cmdlinelibs.rst:10 +msgid "Here's an overview:" +msgstr "以下為概覽:" diff --git a/library/csv.po b/library/csv.po index 05f0cd536c..afc879deaf 100644 --- a/library/csv.po +++ b/library/csv.po @@ -486,7 +486,7 @@ msgid "" "Twenty rows after the first row are sampled; if more than half of columns + " "rows meet the criteria, :const:`True` is returned." msgstr "" -"對第一列之後的二十個列進行採樣;如果超過一半的行及列滿足條件,則返回 :const:" +"對第一列之後的二十個列進行取樣;如果超過一半的行及列滿足條件,則返回 :const:" "`True`。" #: ../../library/csv.rst:302 diff --git a/library/enum.po b/library/enum.po index 85b9d2908d..285fdae837 100644 --- a/library/enum.po +++ b/library/enum.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-02 00:13+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+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-" @@ -238,10 +238,18 @@ msgstr "" "對如何處理非法值做更細微的控制。" #: ../../library/enum.rst:113 +msgid ":class:`EnumDict`" +msgstr ":class:`EnumDict`" + +#: ../../library/enum.rst:115 +msgid "A subclass of :class:`dict` for use when subclassing :class:`EnumType`." +msgstr ":class:`dict` 的子類別,用於當作 :class:`EnumType` 的子類別時使用。" + +#: ../../library/enum.rst:117 msgid ":class:`auto`" msgstr ":class:`auto`" -#: ../../library/enum.rst:115 +#: ../../library/enum.rst:119 msgid "" "Instances are replaced with an appropriate value for Enum members. :class:" "`StrEnum` defaults to the lower-cased version of the member name, while " @@ -250,11 +258,11 @@ msgstr "" "列舉成員的實例會被取代成合適的值。:class:`StrEnum` 預設是小寫版本的成員名稱," "其它列舉則預設是 1 且往後遞增。" -#: ../../library/enum.rst:119 +#: ../../library/enum.rst:123 msgid ":func:`~enum.property`" msgstr ":func:`~enum.property`" -#: ../../library/enum.rst:121 +#: ../../library/enum.rst:125 msgid "" "Allows :class:`Enum` members to have attributes without conflicting with " "member names. The ``value`` and ``name`` attributes are implemented this " @@ -263,46 +271,46 @@ msgstr "" "允許 :class:`Enum` 成員擁有屬性且不會與成員名稱有衝突。``value`` 及 ``name`` " "屬性是用這個方式來實作。" -#: ../../library/enum.rst:125 +#: ../../library/enum.rst:129 msgid ":func:`unique`" msgstr ":func:`unique`" -#: ../../library/enum.rst:127 +#: ../../library/enum.rst:131 msgid "" "Enum class decorator that ensures only one name is bound to any one value." msgstr "Enum 類別的裝飾器,用來確保任何值只有綁定到一個名稱上。" -#: ../../library/enum.rst:129 +#: ../../library/enum.rst:133 msgid ":func:`verify`" msgstr ":func:`verify`" -#: ../../library/enum.rst:131 +#: ../../library/enum.rst:135 msgid "" "Enum class decorator that checks user-selectable constraints on an " "enumeration." msgstr "Enum 類別的裝飾器,用來檢查列舉上使用者所選的限制。" -#: ../../library/enum.rst:134 +#: ../../library/enum.rst:138 msgid ":func:`member`" msgstr ":func:`member`" -#: ../../library/enum.rst:136 +#: ../../library/enum.rst:140 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:138 +#: ../../library/enum.rst:142 msgid ":func:`nonmember`" msgstr ":func:`nonmember`" -#: ../../library/enum.rst:140 +#: ../../library/enum.rst:144 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "不讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:142 +#: ../../library/enum.rst:146 msgid ":func:`global_enum`" msgstr ":func:`global_enum`" -#: ../../library/enum.rst:144 +#: ../../library/enum.rst:148 msgid "" "Modify the :class:`str() ` and :func:`repr` of an enum to show its " "members as belonging to the module instead of its class, and export the enum " @@ -311,19 +319,19 @@ msgstr "" "修改列舉上的 :class:`str() ` 及 :func:`repr` ,讓成員顯示為屬於模組而不" "是類別,並將該列舉成員匯出到全域命名空間。" -#: ../../library/enum.rst:148 +#: ../../library/enum.rst:152 msgid ":func:`show_flag_values`" msgstr ":func:`show_flag_values`" -#: ../../library/enum.rst:150 +#: ../../library/enum.rst:154 msgid "Return a list of all power-of-two integers contained in a flag." msgstr "回傳旗標 (flag) 裡包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:153 +#: ../../library/enum.rst:157 msgid "``Flag``, ``IntFlag``, ``auto``" msgstr "``Flag``, ``IntFlag``, ``auto``" -#: ../../library/enum.rst:154 +#: ../../library/enum.rst:158 msgid "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" @@ -332,10 +340,14 @@ msgstr "" "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" #: ../../library/enum.rst:159 +msgid "``EnumDict``" +msgstr "``EnumDict``" + +#: ../../library/enum.rst:164 msgid "Data Types" msgstr "資料型別" -#: ../../library/enum.rst:164 +#: ../../library/enum.rst:169 msgid "" "*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible " "to subclass *EnumType* -- see :ref:`Subclassing EnumType `。" -#: ../../library/enum.rst:168 +#: ../../library/enum.rst:173 msgid "" "``EnumType`` is responsible for setting the correct :meth:`!__repr__`, :meth:" "`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the " @@ -355,11 +367,11 @@ msgstr "" "`!__str__`、:meth:`!__format__` 及 :meth:`!__reduce__` 方法,以及建立列舉成" "員、正確處理重複、提供列舉類別的疊代等等。" -#: ../../library/enum.rst:175 +#: ../../library/enum.rst:180 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" -#: ../../library/enum.rst:177 +#: ../../library/enum.rst:182 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" @@ -367,7 +379,7 @@ msgstr "查詢已存在的成員:" msgid "cls" msgstr "cls" -#: ../../library/enum.rst:179 ../../library/enum.rst:185 +#: ../../library/enum.rst:184 ../../library/enum.rst:190 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" @@ -375,17 +387,17 @@ msgstr "所呼叫的列舉類別。" msgid "value" msgstr "value" -#: ../../library/enum.rst:180 +#: ../../library/enum.rst:185 msgid "The value to lookup." msgstr "要查詢的值。" -#: ../../library/enum.rst:182 +#: ../../library/enum.rst:187 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:186 +#: ../../library/enum.rst:191 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" @@ -393,7 +405,7 @@ msgstr "要建立的新列舉的名稱。" msgid "names" msgstr "names" -#: ../../library/enum.rst:187 +#: ../../library/enum.rst:192 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" @@ -401,7 +413,7 @@ msgstr "新列舉的成員的名稱/值。" msgid "module" msgstr "module" -#: ../../library/enum.rst:188 +#: ../../library/enum.rst:193 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" @@ -409,7 +421,7 @@ msgstr "新列舉要建立在哪個模組名稱下。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:189 +#: ../../library/enum.rst:194 msgid "The actual location in the module where this Enum can be found." msgstr "這個列舉在模組裡實際上的位置。" @@ -417,7 +429,7 @@ msgstr "這個列舉在模組裡實際上的位置。" msgid "type" msgstr "type" -#: ../../library/enum.rst:190 +#: ../../library/enum.rst:195 msgid "A mix-in type for the new Enum." msgstr "新列舉的混合型別。" @@ -425,7 +437,7 @@ msgstr "新列舉的混合型別。" msgid "start" msgstr "start" -#: ../../library/enum.rst:191 +#: ../../library/enum.rst:196 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" @@ -433,16 +445,16 @@ msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" msgid "boundary" msgstr "boundary" -#: ../../library/enum.rst:192 +#: ../../library/enum.rst:197 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)" -#: ../../library/enum.rst:196 +#: ../../library/enum.rst:201 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" -#: ../../library/enum.rst:198 +#: ../../library/enum.rst:203 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -456,7 +468,7 @@ msgstr "" ">>> Color.RED.value in Color\n" "True" -#: ../../library/enum.rst:206 +#: ../../library/enum.rst:211 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." @@ -464,7 +476,7 @@ msgstr "" "在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 " "``TypeError``。" -#: ../../library/enum.rst:211 +#: ../../library/enum.rst:216 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" @@ -472,7 +484,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" -#: ../../library/enum.rst:214 +#: ../../library/enum.rst:219 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " @@ -484,13 +496,13 @@ msgstr "" "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:219 +#: ../../library/enum.rst:224 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" -#: ../../library/enum.rst:221 +#: ../../library/enum.rst:226 msgid "" ">>> Color['BLUE']\n" "" @@ -498,11 +510,11 @@ msgstr "" ">>> Color['BLUE']\n" "" -#: ../../library/enum.rst:226 +#: ../../library/enum.rst:231 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" -#: ../../library/enum.rst:228 +#: ../../library/enum.rst:233 msgid "" ">>> list(Color)\n" "[, , ]" @@ -510,11 +522,11 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../library/enum.rst:233 +#: ../../library/enum.rst:238 msgid "Returns the number of member in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" -#: ../../library/enum.rst:235 +#: ../../library/enum.rst:240 msgid "" ">>> len(Color)\n" "3" @@ -522,15 +534,15 @@ msgstr "" ">>> len(Color)\n" "3" -#: ../../library/enum.rst:240 +#: ../../library/enum.rst:245 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "回傳每個列舉名稱到其成員的對映,包括別名" -#: ../../library/enum.rst:244 +#: ../../library/enum.rst:249 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" -#: ../../library/enum.rst:246 +#: ../../library/enum.rst:251 msgid "" ">>> list(reversed(Color))\n" "[, , ]" @@ -538,7 +550,7 @@ msgstr "" ">>> list(reversed(Color))\n" "[, , ]" -#: ../../library/enum.rst:251 +#: ../../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." @@ -546,7 +558,7 @@ msgstr "" "新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :" "exc:`NameError`。" -#: ../../library/enum.rst:256 +#: ../../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." @@ -554,21 +566,21 @@ msgstr "" "新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:" "`ValueError`。" -#: ../../library/enum.rst:261 +#: ../../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:266 +#: ../../library/enum.rst:271 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" -#: ../../library/enum.rst:270 +#: ../../library/enum.rst:275 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" -#: ../../library/enum.rst:272 +#: ../../library/enum.rst:277 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" @@ -576,11 +588,11 @@ msgstr "" ">>> Color.BLUE.name\n" "'BLUE'" -#: ../../library/enum.rst:277 +#: ../../library/enum.rst:282 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" -#: ../../library/enum.rst:279 +#: ../../library/enum.rst:284 msgid "" ">>> Color.RED.value\n" "1" @@ -588,15 +600,15 @@ msgstr "" ">>> Color.RED.value\n" "1" -#: ../../library/enum.rst:282 ../../library/enum.rst:302 +#: ../../library/enum.rst:287 ../../library/enum.rst:307 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。" -#: ../../library/enum.rst:284 +#: ../../library/enum.rst:289 msgid "Enum member values" msgstr "列舉成員的值" -#: ../../library/enum.rst:286 +#: ../../library/enum.rst:291 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 " @@ -606,7 +618,7 @@ msgstr "" "重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :" "class:`auto`。" -#: ../../library/enum.rst:291 +#: ../../library/enum.rst:296 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " @@ -617,23 +629,23 @@ msgstr "" "`dict`、:class:`list` 或可變的 :class:`~dataclasses.dataclass`,它們在建立期" "間會對效能產生相對於列舉中可變的 / 不可雜湊的值總數量的二次方影響。" -#: ../../library/enum.rst:298 +#: ../../library/enum.rst:303 msgid "Name of the member." msgstr "成員名稱。" -#: ../../library/enum.rst:306 +#: ../../library/enum.rst:311 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)" -#: ../../library/enum.rst:311 +#: ../../library/enum.rst:316 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" -#: ../../library/enum.rst:314 +#: ../../library/enum.rst:319 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:" @@ -642,7 +654,7 @@ msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" -#: ../../library/enum.rst:320 +#: ../../library/enum.rst:325 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" @@ -650,7 +662,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 " "*self.__class__* 上定義的公開方法: ::" -#: ../../library/enum.rst:323 +#: ../../library/enum.rst:328 msgid "" ">>> from datetime import date\n" ">>> class Weekday(Enum):\n" @@ -690,11 +702,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:341 +#: ../../library/enum.rst:346 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:342 +#: ../../library/enum.rst:347 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -702,7 +714,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:343 +#: ../../library/enum.rst:348 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -710,17 +722,17 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:344 +#: ../../library/enum.rst:349 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:346 +#: ../../library/enum.rst:351 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" -#: ../../library/enum.rst:349 +#: ../../library/enum.rst:354 msgid "" ">>> from enum import auto\n" ">>> class PowersOfThree(Enum):\n" @@ -744,7 +756,7 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:362 +#: ../../library/enum.rst:367 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -752,19 +764,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:369 +#: ../../library/enum.rst:374 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:373 +#: ../../library/enum.rst:378 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:378 +#: ../../library/enum.rst:383 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::" @@ -772,7 +784,7 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:381 +#: ../../library/enum.rst:386 msgid "" ">>> from enum import StrEnum\n" ">>> class Build(StrEnum):\n" @@ -808,7 +820,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:400 +#: ../../library/enum.rst:405 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 " @@ -817,12 +829,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:408 +#: ../../library/enum.rst:413 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。" -#: ../../library/enum.rst:412 +#: ../../library/enum.rst:417 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -830,7 +842,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:417 +#: ../../library/enum.rst:422 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -838,7 +850,7 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:420 +#: ../../library/enum.rst:425 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -864,7 +876,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:433 +#: ../../library/enum.rst:438 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -872,7 +884,7 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:436 +#: ../../library/enum.rst:441 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -896,7 +908,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:448 +#: ../../library/enum.rst:453 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -904,7 +916,7 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:451 +#: ../../library/enum.rst:456 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -928,17 +940,17 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:463 +#: ../../library/enum.rst:468 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:466 +#: ../../library/enum.rst:471 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" -#: ../../library/enum.rst:471 +#: ../../library/enum.rst:476 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 " @@ -948,13 +960,13 @@ msgstr "" "*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數" "的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。" -#: ../../library/enum.rst:492 +#: ../../library/enum.rst:497 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:495 +#: ../../library/enum.rst:500 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -964,7 +976,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:502 +#: ../../library/enum.rst:507 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 " @@ -974,7 +986,7 @@ msgstr "" "``StrEnum`` 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使" "用字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:508 +#: ../../library/enum.rst:513 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 " @@ -985,13 +997,13 @@ msgstr "" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" "你需要使用 ``str(StrEnum.member)``。" -#: ../../library/enum.rst:515 +#: ../../library/enum.rst:520 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:520 +#: ../../library/enum.rst:525 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -1001,7 +1013,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:528 +#: ../../library/enum.rst:533 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -1011,11 +1023,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:534 +#: ../../library/enum.rst:539 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:536 +#: ../../library/enum.rst:541 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1051,11 +1063,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:555 +#: ../../library/enum.rst:560 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:557 +#: ../../library/enum.rst:562 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1067,11 +1079,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:566 +#: ../../library/enum.rst:571 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:568 +#: ../../library/enum.rst:573 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1083,11 +1095,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:577 +#: ../../library/enum.rst:582 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:579 +#: ../../library/enum.rst:584 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1105,11 +1117,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:589 +#: ../../library/enum.rst:594 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:591 +#: ../../library/enum.rst:596 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1117,11 +1129,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:596 +#: ../../library/enum.rst:601 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:598 +#: ../../library/enum.rst:603 msgid "" ">>> purple & white\n" "\n" @@ -1133,11 +1145,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:605 +#: ../../library/enum.rst:610 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:607 +#: ../../library/enum.rst:612 msgid "" ">>> purple ^ white\n" "\n" @@ -1149,11 +1161,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:614 +#: ../../library/enum.rst:619 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:616 +#: ../../library/enum.rst:621 msgid "" ">>> ~white\n" "\n" @@ -1169,7 +1181,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:625 +#: ../../library/enum.rst:630 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1177,17 +1189,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:630 +#: ../../library/enum.rst:635 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:633 +#: ../../library/enum.rst:638 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是: ::" -#: ../../library/enum.rst:641 +#: ../../library/enum.rst:646 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." @@ -1195,13 +1207,13 @@ msgstr "" "``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" "數的地方。" -#: ../../library/enum.rst:655 +#: ../../library/enum.rst:660 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:658 +#: ../../library/enum.rst:663 msgid "" ">>> Color.RED + 2\n" "3" @@ -1209,32 +1221,32 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:661 +#: ../../library/enum.rst:666 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:663 +#: ../../library/enum.rst:668 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:664 +#: ../../library/enum.rst:669 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:666 +#: ../../library/enum.rst:671 msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now:" msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是:" -#: ../../library/enum.rst:673 +#: ../../library/enum.rst:678 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:678 +#: ../../library/enum.rst:683 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1244,7 +1256,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:682 +#: ../../library/enum.rst:687 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 " @@ -1253,7 +1265,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:688 +#: ../../library/enum.rst:693 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1261,15 +1273,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:691 +#: ../../library/enum.rst:696 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:692 +#: ../../library/enum.rst:697 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:694 +#: ../../library/enum.rst:699 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1278,7 +1290,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:703 +#: ../../library/enum.rst:708 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1286,11 +1298,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:708 +#: ../../library/enum.rst:713 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:710 +#: ../../library/enum.rst:715 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1314,13 +1326,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:724 +#: ../../library/enum.rst:729 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:727 +#: ../../library/enum.rst:732 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1342,7 +1354,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:739 +#: ../../library/enum.rst:744 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1350,7 +1362,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:742 +#: ../../library/enum.rst:747 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1378,24 +1390,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:756 +#: ../../library/enum.rst:761 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:762 +#: ../../library/enum.rst:767 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:767 +#: ../../library/enum.rst:772 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:770 +#: ../../library/enum.rst:775 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1423,13 +1435,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:785 +#: ../../library/enum.rst:790 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:788 +#: ../../library/enum.rst:793 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1449,13 +1461,13 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:799 +#: ../../library/enum.rst:804 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:812 +#: ../../library/enum.rst:817 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" @@ -1463,7 +1475,7 @@ msgstr "" "範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " "的預設行為: ::" -#: ../../library/enum.rst:815 +#: ../../library/enum.rst:820 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1483,11 +1495,40 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:829 +#: ../../library/enum.rst:833 +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 " +"subclasses of :class:`EnumType` with advanced behavior like having multiple " +"values per member. It should be called with the name of the enum class being " +"created, otherwise private names and internal classes will not be handled " +"correctly." +msgstr "" +"*EnumDict* 是 :class:`dict` 的子類別,用來作為定義列舉類別的命名空間(參見 :" +"ref:`prepare`)。它被公開來使得 :class:`EnumType` 的子類別能具有進階行為,例" +"如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" +"稱和內部類別將無法被正確處理。" + +#: ../../library/enum.rst:840 +msgid "" +"Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" +"`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " +"possible to bypass the checks using other :class:`!dict` operations like :" +"meth:`|= `." +msgstr "" +"注意只有 :class:`~collections.abc.MutableMapping` 介面(:meth:`~object." +"__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" +"dict` 操作來繞過檢查,例如 :meth:`|= `。" + +#: ../../library/enum.rst:847 +msgid "A list of member names." +msgstr "一個成員名稱的串列。" + +#: ../../library/enum.rst:854 msgid "Supported ``__dunder__`` names" msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:831 +#: ../../library/enum.rst:856 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1495,7 +1536,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:834 +#: ../../library/enum.rst:859 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_` " @@ -1505,38 +1546,38 @@ msgstr "" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:840 +#: ../../library/enum.rst:865 msgid "Supported ``_sunder_`` names" msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:842 +#: ../../library/enum.rst:867 msgid "" ":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr ":meth:`~EnumType._add_alias_` -- 新增一個名稱作為現有成員的別名。" -#: ../../library/enum.rst:844 +#: ../../library/enum.rst:869 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:846 +#: ../../library/enum.rst:871 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:847 +#: ../../library/enum.rst:872 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:848 +#: ../../library/enum.rst:873 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:850 +#: ../../library/enum.rst:875 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 " @@ -1545,7 +1586,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:853 +#: ../../library/enum.rst:878 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1553,28 +1594,28 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:855 +#: ../../library/enum.rst:880 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:860 +#: ../../library/enum.rst:885 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:863 +#: ../../library/enum.rst:888 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:866 +#: ../../library/enum.rst:891 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:" @@ -1582,30 +1623,30 @@ msgstr "" "雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" "用,但有些是明確允許的:" -#: ../../library/enum.rst:869 +#: ../../library/enum.rst:894 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" -"``_repr_*``(例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 `_" +"``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " +"`_" -#: ../../library/enum.rst:871 +#: ../../library/enum.rst:896 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:872 +#: ../../library/enum.rst:897 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:873 +#: ../../library/enum.rst:898 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" -#: ../../library/enum.rst:879 +#: ../../library/enum.rst:904 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:883 +#: ../../library/enum.rst:908 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 " @@ -1621,16 +1662,16 @@ msgstr "" "`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" "說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" -#: ../../library/enum.rst:891 +#: ../../library/enum.rst:916 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "*auto* 實例只有在最上層的賦值時才會被解析:" -#: ../../library/enum.rst:893 +#: ../../library/enum.rst:918 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:894 +#: ../../library/enum.rst:919 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1638,7 +1679,7 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:896 +#: ../../library/enum.rst:921 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" @@ -1646,19 +1687,19 @@ msgstr "" "``THREE = [auto(), -3]`` *無法*\\ 運作(\\ ``, -3`` 會被用來建立列" "舉成員 ``THREE``)" -#: ../../library/enum.rst:901 +#: ../../library/enum.rst:926 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:904 +#: ../../library/enum.rst:929 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:907 +#: ../../library/enum.rst:932 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 " @@ -1667,7 +1708,7 @@ msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" "是不相容的型別就會失敗。" -#: ../../library/enum.rst:913 +#: ../../library/enum.rst:938 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1676,7 +1717,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:917 +#: ../../library/enum.rst:942 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, " @@ -1686,7 +1727,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:926 +#: ../../library/enum.rst:951 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1696,7 +1737,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:930 +#: ../../library/enum.rst:955 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1722,7 +1763,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:944 +#: ../../library/enum.rst:969 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1731,15 +1772,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:952 +#: ../../library/enum.rst:977 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:958 +#: ../../library/enum.rst:983 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:964 +#: ../../library/enum.rst:989 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 " @@ -1750,19 +1791,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:974 +#: ../../library/enum.rst:998 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:981 +#: ../../library/enum.rst:1006 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:983 +#: ../../library/enum.rst:1008 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:985 +#: ../../library/enum.rst:1010 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:" @@ -1770,17 +1811,17 @@ msgstr "" "這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:988 +#: ../../library/enum.rst:1013 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:990 +#: ../../library/enum.rst:1015 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:993 +#: ../../library/enum.rst:1018 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::" @@ -1788,7 +1829,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:996 +#: ../../library/enum.rst:1021 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1798,11 +1839,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1000 +#: ../../library/enum.rst:1025 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1002 +#: ../../library/enum.rst:1027 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" diff --git a/library/filesys.po b/library/filesys.po index 039d7bf996..9c42ea3858 100644 --- a/library/filesys.po +++ b/library/filesys.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -9,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-18 00:04+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2021-11-22 20:13+0800\n" "Last-Translator: Allen Wu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,11 +35,11 @@ msgstr "" "取檔案的屬性、以可攜 (portable) 方式操作路徑以及建立暫存檔。本章中的完整 " "module 清單是:" -#: ../../library/filesys.rst:29 +#: ../../library/filesys.rst:28 msgid "Module :mod:`os`" msgstr "Module :mod:`os`" -#: ../../library/filesys.rst:30 +#: ../../library/filesys.rst:29 msgid "" "Operating system interfaces, including functions to work with files at a " "lower level than Python :term:`file objects `." @@ -48,11 +47,11 @@ msgstr "" "作業系統介面,包括處理比 Python :term:`檔案物件 `\\ 更低階檔案的" "函式。" -#: ../../library/filesys.rst:33 +#: ../../library/filesys.rst:32 msgid "Module :mod:`io`" msgstr "Module :mod:`io`" -#: ../../library/filesys.rst:34 +#: ../../library/filesys.rst:33 msgid "" "Python's built-in I/O library, including both abstract classes and some " "concrete classes such as file I/O." @@ -60,10 +59,10 @@ msgstr "" "Python 的內建 I/O 函式庫,包含抽象類別和一些具體類別 (concrete class),如檔" "案 I/O。" -#: ../../library/filesys.rst:37 +#: ../../library/filesys.rst:36 msgid "Built-in function :func:`open`" msgstr "內建函式 :func:`open`" -#: ../../library/filesys.rst:38 +#: ../../library/filesys.rst:37 msgid "The standard way to open files for reading and writing with Python." msgstr "使用 Python 打開檔案以進行讀寫檔案的標準方法。" diff --git a/library/getopt.po b/library/getopt.po index 8ec79f09ad..f9d84aca9d 100644 --- a/library/getopt.po +++ b/library/getopt.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-05 00:13+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2016-01-31 07:19+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,22 +25,16 @@ msgstr ":mod:`!getopt` --- 用於命令列選項的 C 風格剖析器" msgid "**Source code:** :source:`Lib/getopt.py`" msgstr "**原始碼:**\\ :source:`Lib/getopt.py`" -#: ../../library/getopt.rst:10 +#: ../../library/getopt.rst:12 msgid "" -"The :mod:`getopt` module is :term:`soft deprecated` and will not be " -"developed further; development will continue with the :mod:`argparse` module." +"This module is considered feature complete. A more declarative and " +"extensible alternative to this API is provided in the :mod:`optparse` " +"module. Further functional enhancements for command line parameter " +"processing are provided either as third party modules on PyPI, or else as " +"features in the :mod:`argparse` module." msgstr "" -#: ../../library/getopt.rst:17 -msgid "" -"The :mod:`getopt` module is a parser for command line options whose API is " -"designed to be familiar to users of the C :c:func:`!getopt` function. Users " -"who are unfamiliar with the C :c:func:`!getopt` function or who would like " -"to write less code and get better help and error messages should consider " -"using the :mod:`argparse` module instead." -msgstr "" - -#: ../../library/getopt.rst:25 +#: ../../library/getopt.rst:20 msgid "" "This module helps scripts to parse the command line arguments in ``sys." "argv``. It supports the same conventions as the Unix :c:func:`!getopt` " @@ -49,11 +43,21 @@ msgid "" "be used as well via an optional third argument." msgstr "" -#: ../../library/getopt.rst:31 -msgid "This module provides two functions and an exception:" +#: ../../library/getopt.rst:26 +msgid "" +"Users who are unfamiliar with the Unix :c:func:`!getopt` function should " +"consider using the :mod:`argparse` module instead. Users who are familiar " +"with the Unix :c:func:`!getopt` function, but would like to get equivalent " +"behavior while writing less code and getting better help and error messages " +"should consider using the :mod:`optparse` module. See :ref:`choosing-an-" +"argument-parser` for additional details." msgstr "" -#: ../../library/getopt.rst:37 +#: ../../library/getopt.rst:33 +msgid "This module provides two functions and an exception:" +msgstr "這個模組提供兩個函式和一個例外:" + +#: ../../library/getopt.rst:39 msgid "" "Parses command line options and parameter list. *args* is the argument list " "to be parsed, without the leading reference to the running program. " @@ -63,14 +67,14 @@ msgid "" "func:`!getopt` uses)." msgstr "" -#: ../../library/getopt.rst:45 +#: ../../library/getopt.rst:47 msgid "" "Unlike GNU :c:func:`!getopt`, after a non-option argument, all further " "arguments are considered also non-options. This is similar to the way non-" "GNU Unix systems work." msgstr "" -#: ../../library/getopt.rst:49 +#: ../../library/getopt.rst:51 msgid "" "*longopts*, if specified, must be a list of strings with the names of the " "long options which should be supported. The leading ``'--'`` characters " @@ -84,7 +88,7 @@ msgid "" "uniquely, so :exc:`GetoptError` will be raised." msgstr "" -#: ../../library/getopt.rst:60 +#: ../../library/getopt.rst:62 msgid "" "The return value consists of two elements: the first is a list of ``(option, " "value)`` pairs; the second is the list of program arguments left after the " @@ -97,7 +101,7 @@ msgid "" "occurrences. Long and short options may be mixed." msgstr "" -#: ../../library/getopt.rst:73 +#: ../../library/getopt.rst:75 msgid "" "This function works like :func:`getopt`, except that GNU style scanning mode " "is used by default. This means that option and non-option arguments may be " @@ -105,14 +109,14 @@ msgid "" "a non-option argument is encountered." msgstr "" -#: ../../library/getopt.rst:78 +#: ../../library/getopt.rst:80 msgid "" "If the first character of the option string is ``'+'``, or if the " "environment variable :envvar:`!POSIXLY_CORRECT` is set, then option " "processing stops as soon as a non-option argument is encountered." msgstr "" -#: ../../library/getopt.rst:85 +#: ../../library/getopt.rst:87 msgid "" "This is raised when an unrecognized option is found in the argument list or " "when an option requiring an argument is given none. The argument to the " @@ -123,15 +127,15 @@ msgid "" "which the exception relates, :attr:`!opt` is an empty string." msgstr "" -#: ../../library/getopt.rst:96 +#: ../../library/getopt.rst:98 msgid "Alias for :exc:`GetoptError`; for backward compatibility." -msgstr "" +msgstr "為了向後相容性而設的 :exc:`GetoptError` 別名。" -#: ../../library/getopt.rst:98 +#: ../../library/getopt.rst:100 msgid "An example using only Unix style options:" -msgstr "" +msgstr "一個僅使用 Unix 風格選項的範例:" -#: ../../library/getopt.rst:100 +#: ../../library/getopt.rst:102 msgid "" ">>> import getopt\n" ">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" @@ -153,11 +157,11 @@ msgstr "" ">>> args\n" "['a1', 'a2']" -#: ../../library/getopt.rst:112 +#: ../../library/getopt.rst:114 msgid "Using long option names is equally easy:" -msgstr "" +msgstr "使用長選項名稱同樣容易:" -#: ../../library/getopt.rst:114 +#: ../../library/getopt.rst:116 msgid "" ">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" ">>> args = s.split()\n" @@ -185,11 +189,11 @@ msgstr "" ">>> args\n" "['a1', 'a2']" -#: ../../library/getopt.rst:127 +#: ../../library/getopt.rst:129 msgid "In a script, typical usage is something like this:" -msgstr "" +msgstr "在腳本中,典型的用法如下:" -#: ../../library/getopt.rst:129 +#: ../../library/getopt.rst:131 msgid "" "import getopt, sys\n" "\n" @@ -215,7 +219,7 @@ msgid "" " output = a\n" " else:\n" " assert False, \"unhandled option\"\n" -" # ...\n" +" process(args, output=output, verbose=verbose)\n" "\n" "if __name__ == \"__main__\":\n" " main()" @@ -243,35 +247,87 @@ msgstr "" " output = a\n" " else:\n" " assert False, \"unhandled option\"\n" -" # ...\n" +" process(args, output=output, verbose=verbose)\n" "\n" "if __name__ == \"__main__\":\n" " main()" -#: ../../library/getopt.rst:158 +#: ../../library/getopt.rst:160 msgid "" "Note that an equivalent command line interface could be produced with less " "code and more informative help and error messages by using the :mod:" -"`argparse` module:" +"`optparse` module:" msgstr "" -#: ../../library/getopt.rst:161 +#: ../../library/getopt.rst:163 msgid "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" +msgstr "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" + +#: ../../library/getopt.rst:174 +msgid "" +"A roughly equivalent command line interface for this case can also be " +"produced by using the :mod:`argparse` module:" +msgstr "" + +#: ../../library/getopt.rst:177 +msgid "" +"import argparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-o', '--output')\n" +" parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" +" args = parser.parse_args()\n" +" process(args.rest, output=args.output, verbose=args.verbose)" +msgstr "" "import argparse\n" "\n" "if __name__ == '__main__':\n" " parser = argparse.ArgumentParser()\n" " parser.add_argument('-o', '--output')\n" " parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" " args = parser.parse_args()\n" -" # ... do something with args.output ...\n" -" # ... do something with args.verbose .." +" process(args.rest, output=args.output, verbose=args.verbose)" + +#: ../../library/getopt.rst:189 +msgid "" +"See :ref:`choosing-an-argument-parser` for details on how the ``argparse`` " +"version of this code differs in behaviour from the ``optparse`` (and " +"``getopt``) version." msgstr "" +"參見 :ref:`choosing-an-argument-parser` 以瞭解這段程式碼的 ``argparse`` 版本" +"與 ``optparse``\\(以及 ``getopt``)版本在行為上的差異。" + +#: ../../library/getopt.rst:195 +msgid "Module :mod:`optparse`" +msgstr ":mod:`optparse` 模組" + +#: ../../library/getopt.rst:196 +msgid "Declarative command line option parsing." +msgstr "宣告式命令列選項剖析。" -#: ../../library/getopt.rst:175 +#: ../../library/getopt.rst:198 msgid "Module :mod:`argparse`" msgstr ":mod:`argparse` 模組" -#: ../../library/getopt.rst:176 -msgid "Alternative command line option and argument parsing library." +#: ../../library/getopt.rst:199 +msgid "More opinionated command line option and argument parsing library." msgstr "" diff --git a/library/io.po b/library/io.po index feecd18d50..22a257e59f 100644 --- a/library/io.po +++ b/library/io.po @@ -345,7 +345,7 @@ msgid "" "This is a helper function for callables that use :func:`open` or :class:" "`TextIOWrapper` and have an ``encoding=None`` parameter." msgstr "" -"這是個輔助函數,適用於使用 :func:`open` 或 :class:`TextIOWrapper` 且具有 " +"這是個輔助函式,適用於使用 :func:`open` 或 :class:`TextIOWrapper` 且具有 " "``encoding=None`` 參數的可呼叫物件。" #: ../../library/io.rst:203 diff --git a/library/itertools.po b/library/itertools.po index f7ba031e9c..48da6e992c 100644 --- a/library/itertools.po +++ b/library/itertools.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-05 00:14+0000\n" +"POT-Creation-Date: 2024-12-17 00:14+0000\n" "PO-Revision-Date: 2024-08-16 15:01+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -55,383 +55,371 @@ msgstr "" "f(1), ...``。在 Python 中,可以透過結合 :func:`map` 和 :func:`count` 組成 " "``map(f, count())`` 以達到同樣的效果。" -#: ../../library/itertools.rst:33 -msgid "" -"These tools and their built-in counterparts also work well with the high-" -"speed functions in the :mod:`operator` module. For example, the " -"multiplication operator can be mapped across two vectors to form an " -"efficient dot-product: ``sum(starmap(operator.mul, zip(vec1, vec2, " -"strict=True)))``." -msgstr "" -"這些工具及其內建的對等部分 (counterpart) 也可以很好地與 :mod:`operator` 模組" -"中的高速函式配合使用。例如,乘法運算子可以對映到兩個向量上以組成高效率的內" -"積:``sum(starmap(operator.mul, zip(vec1, vec2, strict=True)))``。" - -#: ../../library/itertools.rst:39 +#: ../../library/itertools.rst:34 msgid "**Infinite iterators:**" msgstr "**無限疊代器:**" -#: ../../library/itertools.rst:42 ../../library/itertools.rst:52 -#: ../../library/itertools.rst:73 +#: ../../library/itertools.rst:37 ../../library/itertools.rst:47 +#: ../../library/itertools.rst:68 msgid "Iterator" msgstr "疊代器" -#: ../../library/itertools.rst:42 ../../library/itertools.rst:52 -#: ../../library/itertools.rst:73 +#: ../../library/itertools.rst:37 ../../library/itertools.rst:47 +#: ../../library/itertools.rst:68 msgid "Arguments" msgstr "引數" -#: ../../library/itertools.rst:42 ../../library/itertools.rst:52 -#: ../../library/itertools.rst:73 ../../library/itertools.rst:82 +#: ../../library/itertools.rst:37 ../../library/itertools.rst:47 +#: ../../library/itertools.rst:68 ../../library/itertools.rst:77 msgid "Results" msgstr "結果" -#: ../../library/itertools.rst:42 ../../library/itertools.rst:52 +#: ../../library/itertools.rst:37 ../../library/itertools.rst:47 msgid "Example" msgstr "範例" -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:39 msgid ":func:`count`" msgstr ":func:`count`" -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:39 msgid "[start[, step]]" msgstr "[start[, step]]" -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:39 msgid "start, start+step, start+2*step, ..." msgstr "start, start+step, start+2*step, ..." -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:39 msgid "``count(10) → 10 11 12 13 14 ...``" msgstr "``count(10) → 10 11 12 13 14 ...``" -#: ../../library/itertools.rst:45 +#: ../../library/itertools.rst:40 msgid ":func:`cycle`" msgstr ":func:`cycle`" -#: ../../library/itertools.rst:45 +#: ../../library/itertools.rst:40 msgid "p" msgstr "p" -#: ../../library/itertools.rst:45 +#: ../../library/itertools.rst:40 msgid "p0, p1, ... plast, p0, p1, ..." msgstr "p0, p1, ... plast, p0, p1, ..." -#: ../../library/itertools.rst:45 +#: ../../library/itertools.rst:40 msgid "``cycle('ABCD') → A B C D A B C D ...``" msgstr "``cycle('ABCD') → A B C D A B C D ...``" -#: ../../library/itertools.rst:46 +#: ../../library/itertools.rst:41 msgid ":func:`repeat`" msgstr ":func:`repeat`" -#: ../../library/itertools.rst:46 +#: ../../library/itertools.rst:41 msgid "elem [,n]" msgstr "elem [,n]" -#: ../../library/itertools.rst:46 +#: ../../library/itertools.rst:41 msgid "elem, elem, elem, ... endlessly or up to n times" msgstr "elem, elem, elem,... 重複無限次或 n 次" -#: ../../library/itertools.rst:46 +#: ../../library/itertools.rst:41 msgid "``repeat(10, 3) → 10 10 10``" msgstr "``repeat(10, 3) → 10 10 10``" -#: ../../library/itertools.rst:49 +#: ../../library/itertools.rst:44 msgid "**Iterators terminating on the shortest input sequence:**" msgstr "**在最短輸入序列 (shortest input sequence) 處終止的疊代器:**" -#: ../../library/itertools.rst:54 +#: ../../library/itertools.rst:49 msgid ":func:`accumulate`" msgstr ":func:`accumulate`" -#: ../../library/itertools.rst:54 +#: ../../library/itertools.rst:49 msgid "p [,func]" msgstr "p [,func]" -#: ../../library/itertools.rst:54 +#: ../../library/itertools.rst:49 msgid "p0, p0+p1, p0+p1+p2, ..." msgstr "p0, p0+p1, p0+p1+p2, ..." -#: ../../library/itertools.rst:54 +#: ../../library/itertools.rst:49 msgid "``accumulate([1,2,3,4,5]) → 1 3 6 10 15``" msgstr "``accumulate([1,2,3,4,5]) → 1 3 6 10 15``" -#: ../../library/itertools.rst:55 +#: ../../library/itertools.rst:50 msgid ":func:`batched`" msgstr ":func:`batched`" -#: ../../library/itertools.rst:55 +#: ../../library/itertools.rst:50 msgid "p, n" msgstr "p, n" -#: ../../library/itertools.rst:55 +#: ../../library/itertools.rst:50 msgid "(p0, p1, ..., p_n-1), ..." msgstr "(p0, p1, ..., p_n-1), ..." -#: ../../library/itertools.rst:55 +#: ../../library/itertools.rst:50 msgid "``batched('ABCDEFG', n=3) → ABC DEF G``" msgstr "``batched('ABCDEFG', n=3) → ABC DEF G``" -#: ../../library/itertools.rst:56 +#: ../../library/itertools.rst:51 msgid ":func:`chain`" msgstr ":func:`chain`" -#: ../../library/itertools.rst:56 ../../library/itertools.rst:67 +#: ../../library/itertools.rst:51 ../../library/itertools.rst:62 msgid "p, q, ..." msgstr "p, q, ..." -#: ../../library/itertools.rst:56 ../../library/itertools.rst:57 +#: ../../library/itertools.rst:51 ../../library/itertools.rst:52 msgid "p0, p1, ... plast, q0, q1, ..." msgstr "p0, p1, ... plast, q0, q1, ..." -#: ../../library/itertools.rst:56 +#: ../../library/itertools.rst:51 msgid "``chain('ABC', 'DEF') → A B C D E F``" msgstr "``chain('ABC', 'DEF') → A B C D E F``" -#: ../../library/itertools.rst:57 +#: ../../library/itertools.rst:52 msgid ":func:`chain.from_iterable`" msgstr ":func:`chain.from_iterable`" -#: ../../library/itertools.rst:57 ../../library/itertools.rst:63 +#: ../../library/itertools.rst:52 ../../library/itertools.rst:58 msgid "iterable" msgstr "可疊代物件" -#: ../../library/itertools.rst:57 +#: ../../library/itertools.rst:52 msgid "``chain.from_iterable(['ABC', 'DEF']) → A B C D E F``" msgstr "``chain.from_iterable(['ABC', 'DEF']) → A B C D E F``" -#: ../../library/itertools.rst:58 +#: ../../library/itertools.rst:53 msgid ":func:`compress`" msgstr ":func:`compress`" -#: ../../library/itertools.rst:58 +#: ../../library/itertools.rst:53 msgid "data, selectors" msgstr "data, selectors" -#: ../../library/itertools.rst:58 +#: ../../library/itertools.rst:53 msgid "(d[0] if s[0]), (d[1] if s[1]), ..." msgstr "(d[0] if s[0]), (d[1] if s[1]), ..." -#: ../../library/itertools.rst:58 +#: ../../library/itertools.rst:53 msgid "``compress('ABCDEF', [1,0,1,0,1,1]) → A C E F``" msgstr "``compress('ABCDEF', [1,0,1,0,1,1]) → A C E F``" -#: ../../library/itertools.rst:59 +#: ../../library/itertools.rst:54 msgid ":func:`dropwhile`" msgstr ":func:`dropwhile`" -#: ../../library/itertools.rst:59 ../../library/itertools.rst:60 -#: ../../library/itertools.rst:65 +#: ../../library/itertools.rst:54 ../../library/itertools.rst:55 +#: ../../library/itertools.rst:60 msgid "predicate, seq" msgstr "predicate, seq" -#: ../../library/itertools.rst:59 +#: ../../library/itertools.rst:54 msgid "seq[n], seq[n+1], starting when predicate fails" msgstr "seq[n], seq[n+1],當 predicate 失敗時開始" -#: ../../library/itertools.rst:59 +#: ../../library/itertools.rst:54 msgid "``dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8``" msgstr "``dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8``" -#: ../../library/itertools.rst:60 +#: ../../library/itertools.rst:55 msgid ":func:`filterfalse`" msgstr ":func:`filterfalse`" -#: ../../library/itertools.rst:60 +#: ../../library/itertools.rst:55 msgid "elements of seq where predicate(elem) fails" msgstr "當 predicate(elem) 失敗時 seq 的元素" -#: ../../library/itertools.rst:60 +#: ../../library/itertools.rst:55 msgid "``filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8``" msgstr "``filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8``" -#: ../../library/itertools.rst:61 +#: ../../library/itertools.rst:56 msgid ":func:`groupby`" msgstr ":func:`groupby`" -#: ../../library/itertools.rst:61 +#: ../../library/itertools.rst:56 msgid "iterable[, key]" msgstr "iterable[, key]" -#: ../../library/itertools.rst:61 +#: ../../library/itertools.rst:56 msgid "sub-iterators grouped by value of key(v)" msgstr "根據 key(v) 的值分組的子疊代器" -#: ../../library/itertools.rst:61 +#: ../../library/itertools.rst:56 msgid "``groupby(['A','B','DEF'], len) → (1, A B) (3, DEF)``" msgstr "``groupby(['A','B','DEF'], len) → (1, A B) (3, DEF)``" -#: ../../library/itertools.rst:62 +#: ../../library/itertools.rst:57 msgid ":func:`islice`" msgstr ":func:`islice`" -#: ../../library/itertools.rst:62 +#: ../../library/itertools.rst:57 msgid "seq, [start,] stop [, step]" msgstr "seq, [start,] stop [, step]" -#: ../../library/itertools.rst:62 +#: ../../library/itertools.rst:57 msgid "elements from seq[start:stop:step]" msgstr "seq[start:stop:step] 的元素" -#: ../../library/itertools.rst:62 +#: ../../library/itertools.rst:57 msgid "``islice('ABCDEFG', 2, None) → C D E F G``" msgstr "``islice('ABCDEFG', 2, None) → C D E F G``" -#: ../../library/itertools.rst:63 +#: ../../library/itertools.rst:58 msgid ":func:`pairwise`" msgstr ":func:`pairwise`" -#: ../../library/itertools.rst:63 +#: ../../library/itertools.rst:58 msgid "(p[0], p[1]), (p[1], p[2])" msgstr "(p[0], p[1]), (p[1], p[2])" -#: ../../library/itertools.rst:63 +#: ../../library/itertools.rst:58 msgid "``pairwise('ABCDEFG') → AB BC CD DE EF FG``" msgstr "``pairwise('ABCDEFG') → AB BC CD DE EF FG``" -#: ../../library/itertools.rst:64 +#: ../../library/itertools.rst:59 msgid ":func:`starmap`" msgstr ":func:`starmap`" -#: ../../library/itertools.rst:64 +#: ../../library/itertools.rst:59 msgid "func, seq" msgstr "func, seq" -#: ../../library/itertools.rst:64 +#: ../../library/itertools.rst:59 msgid "func(\\*seq[0]), func(\\*seq[1]), ..." msgstr "func(\\*seq[0]), func(\\*seq[1]), ..." -#: ../../library/itertools.rst:64 +#: ../../library/itertools.rst:59 msgid "``starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000``" msgstr "``starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000``" -#: ../../library/itertools.rst:65 +#: ../../library/itertools.rst:60 msgid ":func:`takewhile`" msgstr ":func:`takewhile`" -#: ../../library/itertools.rst:65 +#: ../../library/itertools.rst:60 msgid "seq[0], seq[1], until predicate fails" msgstr "seq[0], seq[1],直到 predicate 失敗" -#: ../../library/itertools.rst:65 +#: ../../library/itertools.rst:60 msgid "``takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4``" msgstr "``takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4``" -#: ../../library/itertools.rst:66 +#: ../../library/itertools.rst:61 msgid ":func:`tee`" msgstr ":func:`tee`" -#: ../../library/itertools.rst:66 +#: ../../library/itertools.rst:61 msgid "it, n" msgstr "it, n" -#: ../../library/itertools.rst:66 +#: ../../library/itertools.rst:61 msgid "it1, it2, ... itn splits one iterator into n" msgstr "it1, it2, ... itn,將一個疊代器分成 n 個" -#: ../../library/itertools.rst:67 +#: ../../library/itertools.rst:62 msgid ":func:`zip_longest`" msgstr ":func:`zip_longest`" -#: ../../library/itertools.rst:67 +#: ../../library/itertools.rst:62 msgid "(p[0], q[0]), (p[1], q[1]), ..." msgstr "(p[0], q[0]), (p[1], q[1]), ..." -#: ../../library/itertools.rst:67 +#: ../../library/itertools.rst:62 msgid "``zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-``" msgstr "``zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-``" -#: ../../library/itertools.rst:70 +#: ../../library/itertools.rst:65 msgid "**Combinatoric iterators:**" msgstr "**組合疊代器:**" -#: ../../library/itertools.rst:75 +#: ../../library/itertools.rst:70 msgid ":func:`product`" msgstr ":func:`product`" -#: ../../library/itertools.rst:75 +#: ../../library/itertools.rst:70 msgid "p, q, ... [repeat=1]" msgstr "p, q, ... [repeat=1]" -#: ../../library/itertools.rst:75 +#: ../../library/itertools.rst:70 msgid "cartesian product, equivalent to a nested for-loop" msgstr "笛卡爾乘積 (cartesian product),相當於巢狀的 for 迴圈" -#: ../../library/itertools.rst:76 +#: ../../library/itertools.rst:71 msgid ":func:`permutations`" msgstr ":func:`permutations`" -#: ../../library/itertools.rst:76 +#: ../../library/itertools.rst:71 msgid "p[, r]" msgstr "p[, r]" -#: ../../library/itertools.rst:76 +#: ../../library/itertools.rst:71 msgid "r-length tuples, all possible orderings, no repeated elements" msgstr "長度為 r 的元組,所有可能的定序,無重複元素" -#: ../../library/itertools.rst:77 +#: ../../library/itertools.rst:72 msgid ":func:`combinations`" msgstr ":func:`combinations`" -#: ../../library/itertools.rst:77 ../../library/itertools.rst:78 +#: ../../library/itertools.rst:72 ../../library/itertools.rst:73 msgid "p, r" msgstr "p, r" -#: ../../library/itertools.rst:77 +#: ../../library/itertools.rst:72 msgid "r-length tuples, in sorted order, no repeated elements" msgstr "長度為 r 的元組,按照排序過後的定序,無重複元素" -#: ../../library/itertools.rst:78 +#: ../../library/itertools.rst:73 msgid ":func:`combinations_with_replacement`" msgstr ":func:`combinations_with_replacement`" -#: ../../library/itertools.rst:78 +#: ../../library/itertools.rst:73 msgid "r-length tuples, in sorted order, with repeated elements" msgstr "長度為 r 的元組,按照排序過後的定序,有重複元素" -#: ../../library/itertools.rst:82 +#: ../../library/itertools.rst:77 msgid "Examples" msgstr "範例" -#: ../../library/itertools.rst:84 +#: ../../library/itertools.rst:79 msgid "``product('ABCD', repeat=2)``" msgstr "``product('ABCD', repeat=2)``" -#: ../../library/itertools.rst:84 +#: ../../library/itertools.rst:79 msgid "``AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD``" msgstr "``AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD``" -#: ../../library/itertools.rst:85 +#: ../../library/itertools.rst:80 msgid "``permutations('ABCD', 2)``" msgstr "``permutations('ABCD', 2)``" -#: ../../library/itertools.rst:85 +#: ../../library/itertools.rst:80 msgid "``AB AC AD BA BC BD CA CB CD DA DB DC``" msgstr "``AB AC AD BA BC BD CA CB CD DA DB DC``" -#: ../../library/itertools.rst:86 +#: ../../library/itertools.rst:81 msgid "``combinations('ABCD', 2)``" msgstr "``combinations('ABCD', 2)``" -#: ../../library/itertools.rst:86 +#: ../../library/itertools.rst:81 msgid "``AB AC AD BC BD CD``" msgstr "``AB AC AD BC BD CD``" -#: ../../library/itertools.rst:87 +#: ../../library/itertools.rst:82 msgid "``combinations_with_replacement('ABCD', 2)``" msgstr "``combinations_with_replacement('ABCD', 2)``" -#: ../../library/itertools.rst:87 +#: ../../library/itertools.rst:82 msgid "``AA AB AC AD BB BC BD CC CD DD``" msgstr "``AA AB AC AD BB BC BD CC CD DD``" -#: ../../library/itertools.rst:94 +#: ../../library/itertools.rst:89 msgid "Itertool Functions" msgstr "Itertool 函式" -#: ../../library/itertools.rst:96 +#: ../../library/itertools.rst:91 msgid "" "The following functions all construct and return iterators. Some provide " "streams of infinite length, so they should only be accessed by functions or " @@ -440,13 +428,13 @@ msgstr "" "以下的函式都會建構並回傳疊代器。一些函式提供無限長度的串流 (stream),因此應僅" "由截斷串流的函式或迴圈來存取它們。" -#: ../../library/itertools.rst:103 +#: ../../library/itertools.rst:98 msgid "" "Make an iterator that returns accumulated sums or accumulated results from " "other binary functions." msgstr "建立一個回傳累積和的疊代器,或其他二進位函式的累積結果。" -#: ../../library/itertools.rst:106 +#: ../../library/itertools.rst:101 msgid "" "The *function* defaults to addition. The *function* should accept two " "arguments, an accumulated total and a value from the *iterable*." @@ -454,7 +442,7 @@ msgstr "" "*function* 預設為加法。*function* 應接受兩個引數,即累積總和和來自 " "*iterable* 的值。" -#: ../../library/itertools.rst:109 +#: ../../library/itertools.rst:104 msgid "" "If an *initial* value is provided, the accumulation will start with that " "value and the output will have one more element than the input iterable." @@ -462,15 +450,15 @@ msgstr "" "如果提供了 *initial* 值,則累積將從該值開始,並且輸出的元素數將比輸入的可疊代" "物件多一個。" -#: ../../library/itertools.rst:113 ../../library/itertools.rst:186 -#: ../../library/itertools.rst:245 ../../library/itertools.rst:288 -#: ../../library/itertools.rst:489 ../../library/itertools.rst:524 -#: ../../library/itertools.rst:561 ../../library/itertools.rst:637 -#: ../../library/itertools.rst:698 ../../library/itertools.rst:779 +#: ../../library/itertools.rst:108 ../../library/itertools.rst:181 +#: ../../library/itertools.rst:240 ../../library/itertools.rst:283 +#: ../../library/itertools.rst:484 ../../library/itertools.rst:519 +#: ../../library/itertools.rst:556 ../../library/itertools.rst:632 +#: ../../library/itertools.rst:693 ../../library/itertools.rst:774 msgid "Roughly equivalent to::" msgstr "大致等價於: ::" -#: ../../library/itertools.rst:115 +#: ../../library/itertools.rst:110 msgid "" "def accumulate(iterable, function=operator.add, *, initial=None):\n" " 'Return running totals'\n" @@ -492,7 +480,7 @@ msgid "" " yield total" msgstr "" -#: ../../library/itertools.rst:134 +#: ../../library/itertools.rst:129 msgid "" "To compute a running minimum, set *function* to :func:`min`. For a running " "maximum, set *function* to :func:`max`. Or for a running product, set " @@ -505,7 +493,7 @@ msgstr "" "也可以透過累積利息和付款來建立\\ `攤銷表 (Amortization tables) `_ :" -#: ../../library/itertools.rst:141 +#: ../../library/itertools.rst:136 msgid "" ">>> data = [3, 4, 6, 2, 1, 9, 0, 7, 5, 8]\n" ">>> list(accumulate(data, max)) # running maximum\n" @@ -519,35 +507,35 @@ msgid "" "[1000, 960, 918, 874, 828, 779, 728, 674, 618, 559, 497]" msgstr "" -#: ../../library/itertools.rst:154 +#: ../../library/itertools.rst:149 msgid "" "See :func:`functools.reduce` for a similar function that returns only the " "final accumulated value." msgstr "" "可參見 :func:`functools.reduce`,其是個類似的函式,但僅回傳最終的累積值。" -#: ../../library/itertools.rst:159 +#: ../../library/itertools.rst:154 msgid "Added the optional *function* parameter." msgstr "新增可選的 *function* 參數。" -#: ../../library/itertools.rst:162 +#: ../../library/itertools.rst:157 msgid "Added the optional *initial* parameter." msgstr "新增可選的 *initial* 參數。" -#: ../../library/itertools.rst:168 +#: ../../library/itertools.rst:163 msgid "" "Batch data from the *iterable* into tuples of length *n*. The last batch may " "be shorter than *n*." msgstr "" "將來自 *iterable* 的資料分批為長度為 *n* 的元組。最後一個批次可能比 *n* 短。" -#: ../../library/itertools.rst:171 +#: ../../library/itertools.rst:166 msgid "" "If *strict* is true, will raise a :exc:`ValueError` if the final batch is " "shorter than *n*." msgstr "" -#: ../../library/itertools.rst:174 +#: ../../library/itertools.rst:169 msgid "" "Loops over the input iterable and accumulates data into tuples up to size " "*n*. The input is consumed lazily, just enough to fill a batch. The result " @@ -558,7 +546,7 @@ msgstr "" "消耗 (consumed lazily) 的,會剛好足夠填充一批的資料。一旦批次填滿或輸入的可疊" "代物件耗盡,就會 yield 出結果:" -#: ../../library/itertools.rst:179 +#: ../../library/itertools.rst:174 msgid "" ">>> flattened_data = ['roses', 'red', 'violets', 'blue', 'sugar', 'sweet']\n" ">>> unflattened = list(batched(flattened_data, 2))\n" @@ -570,7 +558,7 @@ msgstr "" ">>> unflattened\n" "[('roses', 'red'), ('violets', 'blue'), ('sugar', 'sweet')]" -#: ../../library/itertools.rst:188 +#: ../../library/itertools.rst:183 msgid "" "def batched(iterable, n, *, strict=False):\n" " # batched('ABCDEFG', 3) → ABC DEF G\n" @@ -592,11 +580,11 @@ msgstr "" " raise ValueError('batched(): incomplete batch')\n" " yield batch" -#: ../../library/itertools.rst:200 +#: ../../library/itertools.rst:195 msgid "Added the *strict* option." msgstr "新增 *strict* 選項。" -#: ../../library/itertools.rst:206 +#: ../../library/itertools.rst:201 msgid "" "Make an iterator that returns elements from the first iterable until it is " "exhausted, then proceeds to the next iterable, until all of the iterables " @@ -607,7 +595,7 @@ msgstr "" "代物件,直到所有可疊代物件都耗盡。這將多個資料來源結合為單一個疊代器。大致等" "價於: ::" -#: ../../library/itertools.rst:211 +#: ../../library/itertools.rst:206 msgid "" "def chain(*iterables):\n" " # chain('ABC', 'DEF') → A B C D E F\n" @@ -615,7 +603,7 @@ msgid "" " yield from iterable" msgstr "" -#: ../../library/itertools.rst:219 +#: ../../library/itertools.rst:214 msgid "" "Alternate constructor for :func:`chain`. Gets chained inputs from a single " "iterable argument that is evaluated lazily. Roughly equivalent to::" @@ -623,7 +611,7 @@ msgstr "" ":func:`chain` 的另一個建構函式。從單個可疊代的引數中得到鏈接的輸入,該引數是" "惰性計算的。大致等價於:" -#: ../../library/itertools.rst:222 +#: ../../library/itertools.rst:217 msgid "" "def from_iterable(iterables):\n" " # chain.from_iterable(['ABC', 'DEF']) → A B C D E F\n" @@ -635,11 +623,11 @@ msgstr "" " for iterable in iterables:\n" " yield from iterable" -#: ../../library/itertools.rst:230 +#: ../../library/itertools.rst:225 msgid "Return *r* length subsequences of elements from the input *iterable*." msgstr "從輸入 *iterable* 中回傳長度為 *r* 的元素的子序列。" -#: ../../library/itertools.rst:232 +#: ../../library/itertools.rst:227 msgid "" "The output is a subsequence of :func:`product` keeping only entries that are " "subsequences of the *iterable*. The length of the output is given by :func:" @@ -650,7 +638,7 @@ msgstr "" "度由 :func:`math.comb` 給定,當 ``0 ≤ r ≤ n`` 時,長度為 ``n! / r! / (n - r)!" "``,當 ``r > n`` 時為零。" -#: ../../library/itertools.rst:237 +#: ../../library/itertools.rst:232 msgid "" "The combination tuples are emitted in lexicographic order according to the " "order of the input *iterable*. If the input *iterable* is sorted, the output " @@ -659,7 +647,7 @@ msgstr "" "根據輸入值 *iterable* 的順序,組合的元組會按照字典順序輸出。如果輸入的 " "*iterable* 已經排序,則輸出的元組也將按排序的順序產生。" -#: ../../library/itertools.rst:241 +#: ../../library/itertools.rst:236 msgid "" "Elements are treated as unique based on their position, not on their value. " "If the input elements are unique, there will be no repeated values within " @@ -668,7 +656,7 @@ msgstr "" "元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特的,則每" "個組合內將不會有重複的值。" -#: ../../library/itertools.rst:247 +#: ../../library/itertools.rst:242 msgid "" "def combinations(iterable, r):\n" " # combinations('ABCD', 2) → AB AC AD BC BD CD\n" @@ -693,14 +681,14 @@ msgid "" " yield tuple(pool[i] for i in indices)" msgstr "" -#: ../../library/itertools.rst:272 +#: ../../library/itertools.rst:267 msgid "" "Return *r* length subsequences of elements from the input *iterable* " "allowing individual elements to be repeated more than once." msgstr "" "回傳來自輸入 *iterable* 的長度為 *r* 的子序列,且允許個別元素重複多次。" -#: ../../library/itertools.rst:275 +#: ../../library/itertools.rst:270 msgid "" "The output is a subsequence of :func:`product` that keeps only entries that " "are subsequences (with possible repeated elements) of the *iterable*. The " @@ -711,7 +699,7 @@ msgstr "" "複元素)的條目。當 ``n > 0`` 時,回傳的子序列數量為 ``(n + r - 1)! / r! / (n " "- 1)!``。" -#: ../../library/itertools.rst:280 +#: ../../library/itertools.rst:275 msgid "" "The combination tuples are emitted in lexicographic order according to the " "order of the input *iterable*. if the input *iterable* is sorted, the output " @@ -720,7 +708,7 @@ msgstr "" "根據輸入值 *iterable* 的順序,組合的元組會按照字典順序輸出。如果輸入的 " "*iterable* 已經排序,則輸出的元組也將按排序的順序產生。" -#: ../../library/itertools.rst:284 +#: ../../library/itertools.rst:279 msgid "" "Elements are treated as unique based on their position, not on their value. " "If the input elements are unique, the generated combinations will also be " @@ -729,7 +717,7 @@ msgstr "" "元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特的,生成" "的組合也將是獨特的。" -#: ../../library/itertools.rst:290 +#: ../../library/itertools.rst:285 msgid "" "def combinations_with_replacement(iterable, r):\n" " # combinations_with_replacement('ABC', 2) → AA AB AC BB BC CC\n" @@ -751,7 +739,7 @@ msgid "" " yield tuple(pool[i] for i in indices)" msgstr "" -#: ../../library/itertools.rst:314 +#: ../../library/itertools.rst:309 msgid "" "Make an iterator that returns elements from *data* where the corresponding " "element in *selectors* is true. Stops when either the *data* or *selectors* " @@ -760,14 +748,14 @@ msgstr "" "建立一個疊代器,回傳 *data* 中對應 *selectors* 的元素為 true 的元素。當 " "*data* 或 *selectors* 可疊代物件耗盡時停止。大致等價於: ::" -#: ../../library/itertools.rst:319 +#: ../../library/itertools.rst:314 msgid "" "def compress(data, selectors):\n" " # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F\n" " return (datum for datum, selector in zip(data, selectors) if selector)" msgstr "" -#: ../../library/itertools.rst:328 +#: ../../library/itertools.rst:323 msgid "" "Make an iterator that returns evenly spaced values beginning with *start*. " "Can be used with :func:`map` to generate consecutive data points or with :" @@ -776,7 +764,7 @@ msgstr "" "建立一個疊代器,回傳從 *start* 開始的等差的值。可以與 :func:`map` 一起使用來" "產生連續的資料點,或與 :func:`zip` 一起使用來增加序列號。大致等價於: ::" -#: ../../library/itertools.rst:333 +#: ../../library/itertools.rst:328 msgid "" "def count(start=0, step=1):\n" " # count(10) → 10 11 12 13 14 ...\n" @@ -794,7 +782,7 @@ msgstr "" " yield n\n" " n += step" -#: ../../library/itertools.rst:341 +#: ../../library/itertools.rst:336 msgid "" "When counting with floating-point numbers, better accuracy can sometimes be " "achieved by substituting multiplicative code such as: ``(start + step * i " @@ -803,11 +791,11 @@ msgstr "" "當用浮點數計數時,將上述程式碼替換為乘法有時可以獲得更好的精確度,例如:" "``(start + step * i for i in count())``。" -#: ../../library/itertools.rst:345 +#: ../../library/itertools.rst:340 msgid "Added *step* argument and allowed non-integer arguments." msgstr "新增 *step* 引數並允許非整數引數。" -#: ../../library/itertools.rst:351 +#: ../../library/itertools.rst:346 msgid "" "Make an iterator returning elements from the *iterable* and saving a copy of " "each. When the iterable is exhausted, return elements from the saved copy. " @@ -816,7 +804,7 @@ msgstr "" "建立一個疊代器,回傳 *iterable* 中的元素並保存每個元素的副本。當可疊代物件耗" "盡時,從保存的副本中回傳元素。會無限次的重複。大致等價於: ::" -#: ../../library/itertools.rst:355 +#: ../../library/itertools.rst:350 msgid "" "def cycle(iterable):\n" " # cycle('ABCD') → A B C D A B C D A B C D ...\n" @@ -842,13 +830,13 @@ msgstr "" " for element in saved:\n" " yield element" -#: ../../library/itertools.rst:367 +#: ../../library/itertools.rst:362 msgid "" "This itertool may require significant auxiliary storage (depending on the " "length of the iterable)." msgstr "此 itertool 可能需要大量的輔助儲存空間(取決於可疊代物件的長度)。" -#: ../../library/itertools.rst:373 +#: ../../library/itertools.rst:368 msgid "" "Make an iterator that drops elements from the *iterable* while the " "*predicate* is true and afterwards returns every element. Roughly " @@ -857,7 +845,7 @@ msgstr "" "建立一個疊代器,在 *predicate* 為 true 時丟棄 *iterable* 中的元素,之後回傳每" "個元素。大致等價於:" -#: ../../library/itertools.rst:377 +#: ../../library/itertools.rst:372 msgid "" "def dropwhile(predicate, iterable):\n" " # dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8\n" @@ -883,7 +871,7 @@ msgstr "" " for x in iterator:\n" " yield x" -#: ../../library/itertools.rst:389 +#: ../../library/itertools.rst:384 msgid "" "Note this does not produce *any* output until the predicate first becomes " "false, so this itertool may have a lengthy start-up time." @@ -891,7 +879,7 @@ msgstr "" "注意,在 predicate 首次變為 False 之前,這不會產生\\ *任何*\\ 輸出,所以此 " "itertool 可能會有較長的啟動時間。" -#: ../../library/itertools.rst:395 +#: ../../library/itertools.rst:390 msgid "" "Make an iterator that filters elements from the *iterable* returning only " "those for which the *predicate* returns a false value. If *predicate* is " @@ -900,7 +888,7 @@ msgstr "" "建立一個疊代器,過濾 *iterable* 中的元素,僅回傳 *predicate* 為 False 值的元" "素。如果 *predicate* 是 ``None``,則回傳為 False 的項目。大致等價於: ::" -#: ../../library/itertools.rst:400 +#: ../../library/itertools.rst:395 msgid "" "def filterfalse(predicate, iterable):\n" " # filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8\n" @@ -922,7 +910,7 @@ msgstr "" " if not predicate(x):\n" " yield x" -#: ../../library/itertools.rst:413 +#: ../../library/itertools.rst:408 msgid "" "Make an iterator that returns consecutive keys and groups from the " "*iterable*. The *key* is a function computing a key value for each element. " @@ -935,7 +923,7 @@ msgstr "" "(identity function),並回傳未被更改的元素。一般來說,可疊代物件需要已經用相同" "的鍵函式進行排序。" -#: ../../library/itertools.rst:419 +#: ../../library/itertools.rst:414 msgid "" "The operation of :func:`groupby` is similar to the ``uniq`` filter in Unix. " "It generates a break or new group every time the value of the key function " @@ -948,7 +936,7 @@ msgstr "" "料進行排序)。這種行為不同於 SQL 的 GROUP BY,其無論輸入順序如何都會聚合相同" "的元素。" -#: ../../library/itertools.rst:425 +#: ../../library/itertools.rst:420 msgid "" "The returned group is itself an iterator that shares the underlying iterable " "with :func:`groupby`. Because the source is shared, when the :func:" @@ -959,7 +947,7 @@ msgstr "" "共享的,當 :func:`groupby` 物件前進時,前一個群組將不再可見。因此,如果之後需" "要該資料,應將其儲存為串列: ::" -#: ../../library/itertools.rst:430 +#: ../../library/itertools.rst:425 msgid "" "groups = []\n" "uniquekeys = []\n" @@ -969,11 +957,11 @@ msgid "" " uniquekeys.append(k)" msgstr "" -#: ../../library/itertools.rst:437 +#: ../../library/itertools.rst:432 msgid ":func:`groupby` is roughly equivalent to::" msgstr ":func:`groupby` 大致等價於: ::" -#: ../../library/itertools.rst:439 +#: ../../library/itertools.rst:434 msgid "" "def groupby(iterable, key=None):\n" " # [k for k, g in groupby('AAAABBBCCDAABBB')] → A B C D A B\n" @@ -1039,7 +1027,7 @@ msgstr "" " for _ in curr_group:\n" " pass" -#: ../../library/itertools.rst:475 +#: ../../library/itertools.rst:470 msgid "" "Make an iterator that returns selected elements from the iterable. Works " "like sequence slicing but does not support negative values for *start*, " @@ -1048,7 +1036,7 @@ msgstr "" "建立一個疊代器,回傳從 iterable 中選取的元素。其作用類似於序列切片 (sequence " "slicing),但不支援負數的 *start*、*stop* 或 *step* 的值。" -#: ../../library/itertools.rst:479 +#: ../../library/itertools.rst:474 msgid "" "If *start* is zero or ``None``, iteration starts at zero. Otherwise, " "elements from the iterable are skipped until *start* is reached." @@ -1056,7 +1044,7 @@ msgstr "" "如果 *start* 為零或 ``None``,則從零開始疊代。否則在達到 *start* 之前,會跳" "過 iterable 中的元素。" -#: ../../library/itertools.rst:482 +#: ../../library/itertools.rst:477 msgid "" "If *stop* is ``None``, iteration continues until the input is exhausted, if " "at all. Otherwise, it stops at the specified position." @@ -1064,7 +1052,7 @@ msgstr "" "如果 *stop* 為 ``None``,則疊代將繼續前進直到輸入耗盡。如果指定了 *stop*,則" "在達到指定位置時停止。" -#: ../../library/itertools.rst:485 +#: ../../library/itertools.rst:480 msgid "" "If *step* is ``None``, the step defaults to one. Elements are returned " "consecutively unless *step* is set higher than one which results in items " @@ -1073,7 +1061,7 @@ msgstr "" "如果 *step* 為 ``None``,則步長 (step) 預設為一。元素會連續回傳,除非將 " "*step* 設定為大於一,這會導致一些項目被跳過。" -#: ../../library/itertools.rst:491 +#: ../../library/itertools.rst:486 msgid "" "def islice(iterable, *args):\n" " # islice('ABCDEFG', 2) → A B\n" @@ -1115,17 +1103,17 @@ msgstr "" " yield element\n" " next_i += step" -#: ../../library/itertools.rst:511 +#: ../../library/itertools.rst:506 msgid "" "If the input is an iterator, then fully consuming the *islice* advances the " "input iterator by ``max(start, stop)`` steps regardless of the *step* value." msgstr "" -#: ../../library/itertools.rst:518 +#: ../../library/itertools.rst:513 msgid "Return successive overlapping pairs taken from the input *iterable*." msgstr "回傳從輸入的 *iterable* 中提取的連續重疊對。" -#: ../../library/itertools.rst:520 +#: ../../library/itertools.rst:515 msgid "" "The number of 2-tuples in the output iterator will be one fewer than the " "number of inputs. It will be empty if the input iterable has fewer than two " @@ -1134,7 +1122,7 @@ msgstr "" "輸出疊代器中的 2 元組數量將比輸入少一個。如果輸入的可疊代物件中的值少於兩個," "則輸出將為空值。" -#: ../../library/itertools.rst:526 +#: ../../library/itertools.rst:521 msgid "" "def pairwise(iterable):\n" " # pairwise('ABCDEFG') → AB BC CD DE EF FG\n" @@ -1156,7 +1144,7 @@ msgstr "" " yield a, b\n" " a = b" -#: ../../library/itertools.rst:541 +#: ../../library/itertools.rst:536 msgid "" "Return successive *r* length `permutations of elements `_ from the *iterable*." @@ -1164,7 +1152,7 @@ msgstr "" "回傳 *iterable* 中連續且長度為 *r* 的\\ `元素排列 `_ 。" -#: ../../library/itertools.rst:544 +#: ../../library/itertools.rst:539 msgid "" "If *r* is not specified or is ``None``, then *r* defaults to the length of " "the *iterable* and all possible full-length permutations are generated." @@ -1172,7 +1160,7 @@ msgstr "" "如果未指定 *r* 或其值為 ``None``,則 *r* 預設為 *iterable* 的長度,並產生所有" "可能的完整長度的排列。" -#: ../../library/itertools.rst:548 +#: ../../library/itertools.rst:543 msgid "" "The output is a subsequence of :func:`product` where entries with repeated " "elements have been filtered out. The length of the output is given by :func:" @@ -1183,7 +1171,7 @@ msgstr "" "func:`math.perm` 給定,當 ``0 ≤ r ≤ n`` 時,長度為 ``n! / (n - r)!``,當 ``r " "> n`` 時為零。" -#: ../../library/itertools.rst:553 +#: ../../library/itertools.rst:548 msgid "" "The permutation tuples are emitted in lexicographic order according to the " "order of the input *iterable*. If the input *iterable* is sorted, the " @@ -1192,7 +1180,7 @@ msgstr "" "根據輸入值 *iterable* 的順序,排列的元組會按照字典順序輸出。如果輸入的 " "*iterable* 已排序,則輸出的元組也將按排序的順序產生。" -#: ../../library/itertools.rst:557 +#: ../../library/itertools.rst:552 msgid "" "Elements are treated as unique based on their position, not on their value. " "If the input elements are unique, there will be no repeated values within a " @@ -1201,7 +1189,7 @@ msgstr "" "元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特的,則排" "列中將不會有重複的值。" -#: ../../library/itertools.rst:563 +#: ../../library/itertools.rst:558 msgid "" "def permutations(iterable, r=None):\n" " # permutations('ABCD', 2) → AB AC AD BA BC BD CA CB CD DA DB DC\n" @@ -1259,13 +1247,13 @@ msgstr "" " else:\n" " return" -#: ../../library/itertools.rst:594 +#: ../../library/itertools.rst:589 msgid "" "`Cartesian product `_ of " "the input iterables." msgstr "" -#: ../../library/itertools.rst:597 +#: ../../library/itertools.rst:592 msgid "" "Roughly equivalent to nested for-loops in a generator expression. For " "example, ``product(A, B)`` returns the same as ``((x,y) for x in A for y in " @@ -1274,7 +1262,7 @@ msgstr "" "大致等價於產生器運算式中的巢狀 for 迴圈。例如,``product(A, B)`` 的回傳結果" "與 ``((x,y) for x in A for y in B)`` 相同。" -#: ../../library/itertools.rst:600 +#: ../../library/itertools.rst:595 msgid "" "The nested loops cycle like an odometer with the rightmost element advancing " "on every iteration. This pattern creates a lexicographic ordering so that " @@ -1284,7 +1272,7 @@ msgstr "" "巢狀迴圈的循環類似於里程表,最右邊的元素在每次疊代時前進。這種模式會建立字典" "順序,因此如果輸入的 iterables 已排序,則輸出的乘積元組也將按排序的順序產生。" -#: ../../library/itertools.rst:605 +#: ../../library/itertools.rst:600 msgid "" "To compute the product of an iterable with itself, specify the number of " "repetitions with the optional *repeat* keyword argument. For example, " @@ -1293,7 +1281,7 @@ msgstr "" "要計算可疊代物件自身的乘積,可以使用可選的 *repeat* 關鍵字引數來指定重複次" "數。例如,``product(A, repeat=4)`` 與 ``product(A, A, A, A)`` 相同。" -#: ../../library/itertools.rst:609 +#: ../../library/itertools.rst:604 msgid "" "This function is roughly equivalent to the following code, except that the " "actual implementation does not build up intermediate results in memory::" @@ -1301,7 +1289,7 @@ msgstr "" "此函式大致等價於以下的程式碼,不同之處在於真正的實作不會在記憶體中建立中間結" "果: ::" -#: ../../library/itertools.rst:612 +#: ../../library/itertools.rst:607 msgid "" "def product(*iterables, repeat=1):\n" " # product('ABCD', 'xy') → Ax Ay Bx By Cx Cy Dx Dy\n" @@ -1333,7 +1321,7 @@ msgstr "" " for prod in result:\n" " yield tuple(prod)" -#: ../../library/itertools.rst:627 +#: ../../library/itertools.rst:622 msgid "" "Before :func:`product` runs, it completely consumes the input iterables, " "keeping pools of values in memory to generate the products. Accordingly, it " @@ -1342,7 +1330,7 @@ msgstr "" "在 :func:`product` 執行之前,它會完全消耗輸入的 iterables,並將值的池 (pools " "of values) 保存在記憶體中以產生乘積。因此,它僅對有限的輸入有用。" -#: ../../library/itertools.rst:634 +#: ../../library/itertools.rst:629 msgid "" "Make an iterator that returns *object* over and over again. Runs " "indefinitely unless the *times* argument is specified." @@ -1350,7 +1338,7 @@ msgstr "" "建立一個疊代器,反覆回傳 *object*。除非指定了 *times* 引數,否則會執行無限" "次。" -#: ../../library/itertools.rst:639 +#: ../../library/itertools.rst:634 msgid "" "def repeat(object, times=None):\n" " # repeat(10, 3) → 10 10 10\n" @@ -1370,13 +1358,13 @@ msgstr "" " for i in range(times):\n" " yield object" -#: ../../library/itertools.rst:648 +#: ../../library/itertools.rst:643 msgid "" "A common use for *repeat* is to supply a stream of constant values to *map* " "or *zip*:" msgstr "*repeat* 的常見用途是為 *map* 或 *zip* 提供定值的串流:" -#: ../../library/itertools.rst:651 +#: ../../library/itertools.rst:646 msgid "" ">>> list(map(pow, range(10), repeat(2)))\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" @@ -1384,7 +1372,7 @@ msgstr "" ">>> list(map(pow, range(10), repeat(2)))\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" -#: ../../library/itertools.rst:659 +#: ../../library/itertools.rst:654 msgid "" "Make an iterator that computes the *function* using arguments obtained from " "the *iterable*. Used instead of :func:`map` when argument parameters have " @@ -1393,7 +1381,7 @@ msgstr "" "建立一個疊代器,使用從 *iterable* 獲取的引數計算 *function* 。當引數參數已經" "被「預先壓縮 (pre-zipped)」成元組時,使用此方法代替 :func:`map`。" -#: ../../library/itertools.rst:663 +#: ../../library/itertools.rst:658 msgid "" "The difference between :func:`map` and :func:`starmap` parallels the " "distinction between ``function(a,b)`` and ``function(*c)``. Roughly " @@ -1402,7 +1390,7 @@ msgstr "" ":func:`map` 和 :func:`starmap` 之間的區別類似於 ``function(a,b)`` 和 " "``function(*c)`` 之間的區別。大致等價於:" -#: ../../library/itertools.rst:667 +#: ../../library/itertools.rst:662 msgid "" "def starmap(function, iterable):\n" " # starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000\n" @@ -1414,7 +1402,7 @@ msgstr "" " for args in iterable:\n" " yield function(*args)" -#: ../../library/itertools.rst:675 +#: ../../library/itertools.rst:670 msgid "" "Make an iterator that returns elements from the *iterable* as long as the " "*predicate* is true. Roughly equivalent to::" @@ -1422,7 +1410,7 @@ msgstr "" "建立一個疊代器,只在 *predicate* 為 true 時回傳 *iterable* 中的元素。大致等價" "於:" -#: ../../library/itertools.rst:678 +#: ../../library/itertools.rst:673 msgid "" "def takewhile(predicate, iterable):\n" " # takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4\n" @@ -1438,13 +1426,13 @@ msgstr "" " break\n" " yield x" -#: ../../library/itertools.rst:685 +#: ../../library/itertools.rst:680 msgid "" "Note, the element that first fails the predicate condition is consumed from " "the input iterator and there is no way to access it. This could be an issue " "if an application wants to further consume the input iterator after " "*takewhile* has been run to exhaustion. To work around this problem, " -"consider using `more-iterools before_and_after() `_ instead." msgstr "" "注意,第一個不符合條件判斷的元素將從輸入疊代器中被消耗,且無法再存取它。如果" @@ -1453,11 +1441,11 @@ msgstr "" "more-itertools.readthedocs.io/en/stable/api.html#more_itertools." "before_and_after>`_ 作為替代。" -#: ../../library/itertools.rst:696 +#: ../../library/itertools.rst:691 msgid "Return *n* independent iterators from a single iterable." msgstr "從一個 iterable 中回傳 *n* 個獨立的疊代器。" -#: ../../library/itertools.rst:700 +#: ../../library/itertools.rst:695 msgid "" "def tee(iterable, n=2):\n" " if n < 0:\n" @@ -1493,7 +1481,7 @@ msgid "" " return value" msgstr "" -#: ../../library/itertools.rst:733 +#: ../../library/itertools.rst:728 msgid "" "When the input *iterable* is already a tee iterator object, all members of " "the return tuple are constructed as if they had been produced by the " @@ -1502,11 +1490,11 @@ msgid "" "update step rather than a chain of calls." msgstr "" -#: ../../library/itertools.rst:739 +#: ../../library/itertools.rst:734 msgid "The flattening property makes tee iterators efficiently peekable:" msgstr "" -#: ../../library/itertools.rst:741 +#: ../../library/itertools.rst:736 msgid "" "def lookahead(tee_iterator):\n" " \"Return the next value without moving the input forward\"\n" @@ -1514,7 +1502,7 @@ msgid "" " return next(forked_iterator)" msgstr "" -#: ../../library/itertools.rst:748 +#: ../../library/itertools.rst:743 msgid "" ">>> iterator = iter('abcdef')\n" ">>> [iterator] = tee(iterator, 1) # Make the input peekable\n" @@ -1526,7 +1514,7 @@ msgid "" "'b'" msgstr "" -#: ../../library/itertools.rst:759 +#: ../../library/itertools.rst:754 msgid "" "``tee`` iterators are not threadsafe. A :exc:`RuntimeError` may be raised " "when simultaneously using iterators returned by the same :func:`tee` call, " @@ -1536,7 +1524,7 @@ msgstr "" "呼叫所回傳的疊代器時,即使原始的 *iterable* 是執行緒安全的,也可能引發 :exc:" "`RuntimeError`。" -#: ../../library/itertools.rst:763 +#: ../../library/itertools.rst:758 msgid "" "This itertool may require significant auxiliary storage (depending on how " "much temporary data needs to be stored). In general, if one iterator uses " @@ -1547,11 +1535,11 @@ msgstr "" "果一個疊代器在另一個疊代器開始之前使用了大部分或全部的資料,使用 :func:" "`list` 會比 :func:`tee` 更快。" -#: ../../library/itertools.rst:771 +#: ../../library/itertools.rst:766 msgid "Make an iterator that aggregates elements from each of the *iterables*." msgstr "建立一個疊代器,聚合來自每個 *iterables* 中的元素。" -#: ../../library/itertools.rst:774 +#: ../../library/itertools.rst:769 msgid "" "If the iterables are of uneven length, missing values are filled-in with " "*fillvalue*. If not specified, *fillvalue* defaults to ``None``." @@ -1559,11 +1547,11 @@ msgstr "" "如果 iterables 的長度不一,則使用 *fillvalue* 填充缺少的值。如果未指定," "*fillvalue* 會預設為 ``None``。" -#: ../../library/itertools.rst:777 +#: ../../library/itertools.rst:772 msgid "Iteration continues until the longest iterable is exhausted." msgstr "疊代將持續直到最長的可疊代物件耗盡為止。" -#: ../../library/itertools.rst:781 +#: ../../library/itertools.rst:776 msgid "" "def zip_longest(*iterables, fillvalue=None):\n" " # zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-\n" @@ -1609,7 +1597,7 @@ msgstr "" " values.append(value)\n" " yield tuple(values)" -#: ../../library/itertools.rst:803 +#: ../../library/itertools.rst:798 msgid "" "If one of the iterables is potentially infinite, then the :func:" "`zip_longest` function should be wrapped with something that limits the " @@ -1618,18 +1606,18 @@ msgstr "" "如果其中一個 iterables 可能是無限的,那麼應該用別的可以限制呼叫次數的方法來包" "裝 :func:`zip_longest` 函式(例如 :func:`islice` 或 :func:`takewhile`)。" -#: ../../library/itertools.rst:811 +#: ../../library/itertools.rst:806 msgid "Itertools Recipes" msgstr "Itertools 應用技巧" -#: ../../library/itertools.rst:813 +#: ../../library/itertools.rst:808 msgid "" "This section shows recipes for creating an extended toolset using the " "existing itertools as building blocks." msgstr "" "此段落展示了使用現有的 itertools 作為構建塊來建立擴展工具集的應用技巧。" -#: ../../library/itertools.rst:816 +#: ../../library/itertools.rst:811 msgid "" "The primary purpose of the itertools recipes is educational. The recipes " "show various ways of thinking about individual tools — for example, that " @@ -1647,7 +1635,7 @@ msgstr "" "`collections` 模組一同使用以及與內建 itertools(如 ``map()``、``filter()``、" "``reversed()`` 和 ``enumerate()``)一同使用的模式。" -#: ../../library/itertools.rst:825 +#: ../../library/itertools.rst:820 msgid "" "A secondary purpose of the recipes is to serve as an incubator. The " "``accumulate()``, ``compress()``, and ``pairwise()`` itertools started out " @@ -1659,7 +1647,7 @@ msgstr "" "``sliding_window()``、``iter_index()`` 和 ``sieve()`` 的應用技巧正在被測試," "以確定它們是否有價值被收錄到內建的 itertools 中。" -#: ../../library/itertools.rst:830 +#: ../../library/itertools.rst:825 msgid "" "Substantially all of these recipes and many, many others can be installed " "from the :pypi:`more-itertools` project found on the Python Package Index::" @@ -1667,11 +1655,11 @@ msgstr "" "幾乎所有這些應用技巧以及許多其他應用技巧都可以從 Python Package Index 上的 :" "pypi:`more-itertools` 專案中安裝: ::" -#: ../../library/itertools.rst:834 +#: ../../library/itertools.rst:829 msgid "python -m pip install more-itertools" msgstr "python -m pip install more-itertools" -#: ../../library/itertools.rst:836 +#: ../../library/itertools.rst:831 msgid "" "Many of the recipes offer the same high performance as the underlying " "toolset. Superior memory performance is kept by processing elements one at a " @@ -1689,14 +1677,13 @@ msgstr "" "用「向量化 (vectorized)」的構建塊而不是使用會造成直譯器負擔的 for 迴圈和\\ :" "term:`產生器 `,則能保持高速度。" -#: ../../library/itertools.rst:844 +#: ../../library/itertools.rst:839 msgid "" -"import collections\n" -"import contextlib\n" -"import functools\n" -"import math\n" -"import operator\n" -"import random\n" +"from collections import deque\n" +"from contextlib import suppress\n" +"from functools import reduce\n" +"from math import sumprod, isqrt\n" +"from operator import itemgetter, getitem, mul, neg\n" "\n" "def take(n, iterable):\n" " \"Return first n items of the iterable as a list.\"\n" @@ -1711,11 +1698,11 @@ msgid "" " \"Return function(0), function(1), ...\"\n" " return map(function, count(start))\n" "\n" -"def repeatfunc(func, times=None, *args):\n" -" \"Repeat calls to func with specified arguments.\"\n" +"def repeatfunc(function, times=None, *args):\n" +" \"Repeat calls to a function with specified arguments.\"\n" " if times is None:\n" -" return starmap(func, repeat(args))\n" -" return starmap(func, repeat(args, times))\n" +" return starmap(function, repeat(args))\n" +" return starmap(function, repeat(args, times))\n" "\n" "def flatten(list_of_lists):\n" " \"Flatten one level of nesting.\"\n" @@ -1733,13 +1720,13 @@ msgid "" "def tail(n, iterable):\n" " \"Return an iterator over the last n items.\"\n" " # tail(3, 'ABCDEFG') → E F G\n" -" return iter(collections.deque(iterable, maxlen=n))\n" +" return iter(deque(iterable, maxlen=n))\n" "\n" "def consume(iterator, n=None):\n" " \"Advance the iterator n-steps ahead. If n is None, consume entirely.\"\n" " # Use functions that consume iterators at C speed.\n" " if n is None:\n" -" collections.deque(iterator, maxlen=0)\n" +" deque(iterator, maxlen=0)\n" " else:\n" " next(islice(iterator, n, n), None)\n" "\n" @@ -1770,8 +1757,8 @@ msgid "" " # unique_justseen('AAAABBBCCDAABBB') → A B C D A B\n" " # unique_justseen('ABBcCAD', str.casefold) → A B c A D\n" " if key is None:\n" -" return map(operator.itemgetter(0), groupby(iterable))\n" -" return map(next, map(operator.itemgetter(1), groupby(iterable, key)))\n" +" return map(itemgetter(0), groupby(iterable))\n" +" return map(next, map(itemgetter(1), groupby(iterable, key)))\n" "\n" "def unique_everseen(iterable, key=None):\n" " \"Yield unique elements, preserving order. Remember all elements ever " @@ -1793,14 +1780,14 @@ msgid "" "def unique(iterable, key=None, reverse=False):\n" " \"Yield unique elements in sorted order. Supports unhashable inputs.\"\n" " # unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4]\n" -" return unique_justseen(sorted(iterable, key=key, reverse=reverse), " -"key=key)\n" +" sequenced = sorted(iterable, key=key, reverse=reverse)\n" +" return unique_justseen(sequenced, key=key)\n" "\n" "def sliding_window(iterable, n):\n" " \"Collect data into overlapping fixed-length chunks or blocks.\"\n" " # sliding_window('ABCDEFG', 4) → ABCD BCDE CDEF DEFG\n" " iterator = iter(iterable)\n" -" window = collections.deque(islice(iterator, n - 1), maxlen=n)\n" +" window = deque(islice(iterator, n - 1), maxlen=n)\n" " for x in iterator:\n" " window.append(x)\n" " yield tuple(window)\n" @@ -1834,7 +1821,7 @@ msgid "" " \"Return all contiguous non-empty subslices of a sequence.\"\n" " # subslices('ABCD') → A AB ABC ABCD B BC BCD C CD D\n" " slices = starmap(slice, combinations(range(len(seq) + 1), 2))\n" -" return map(operator.getitem, repeat(seq), slices)\n" +" return map(getitem, repeat(seq), slices)\n" "\n" "def iter_index(iterable, value, start=0, stop=None):\n" " \"Return indices where a value occurs in a sequence or iterable.\"\n" @@ -1848,41 +1835,42 @@ msgid "" " else:\n" " stop = len(iterable) if stop is None else stop\n" " i = start\n" -" with contextlib.suppress(ValueError):\n" +" with suppress(ValueError):\n" " while True:\n" " yield (i := seq_index(value, i, stop))\n" " i += 1\n" "\n" -"def iter_except(func, exception, first=None):\n" +"def iter_except(function, exception, first=None):\n" " \"Convert a call-until-exception interface to an iterator interface.\"\n" " # iter_except(d.popitem, KeyError) → non-blocking dictionary iterator\n" -" with contextlib.suppress(exception):\n" +" with suppress(exception):\n" " if first is not None:\n" " yield first()\n" " while True:\n" -" yield func()" +" yield function()" msgstr "" -#: ../../library/itertools.rst:1013 +#: ../../library/itertools.rst:1008 msgid "The following recipes have a more mathematical flavor:" msgstr "以下的應用技巧具有更多的數學風格:" -#: ../../library/itertools.rst:1015 +#: ../../library/itertools.rst:1010 msgid "" "def powerset(iterable):\n" -" \"powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)\"\n" +" \"Subsequences of the iterable from shortest to longest.\"\n" +" # powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)\n" " s = list(iterable)\n" " return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))\n" "\n" "def sum_of_squares(iterable):\n" " \"Add up the squares of the input values.\"\n" " # sum_of_squares([10, 20, 30]) → 1400\n" -" return math.sumprod(*tee(iterable))\n" +" return sumprod(*tee(iterable))\n" "\n" -"def reshape(matrix, cols):\n" +"def reshape(matrix, columns):\n" " \"Reshape a 2-D matrix to have a given number of columns.\"\n" " # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2), (3, 4, 5)\n" -" return batched(chain.from_iterable(matrix), cols, strict=True)\n" +" return batched(chain.from_iterable(matrix), columns, strict=True)\n" "\n" "def transpose(matrix):\n" " \"Swap the rows and columns of a 2-D matrix.\"\n" @@ -1893,7 +1881,7 @@ msgid "" " \"Multiply two matrices.\"\n" " # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80), (41, 60)\n" " n = len(m2[0])\n" -" return batched(starmap(math.sumprod, product(m1, transpose(m2))), n)\n" +" return batched(starmap(sumprod, product(m1, transpose(m2))), n)\n" "\n" "def convolve(signal, kernel):\n" " \"\"\"Discrete linear convolution of two iterables.\n" @@ -1914,7 +1902,7 @@ msgid "" " n = len(kernel)\n" " padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))\n" " windowed_signal = sliding_window(padded_signal, n)\n" -" return map(math.sumprod, repeat(kernel), windowed_signal)\n" +" return map(sumprod, repeat(kernel), windowed_signal)\n" "\n" "def polynomial_from_roots(roots):\n" " \"\"\"Compute a polynomial's coefficients from its roots.\n" @@ -1922,8 +1910,8 @@ msgid "" " (x - 5) (x + 4) (x - 3) expands to: x³ -4x² -17x + 60\n" " \"\"\"\n" " # polynomial_from_roots([5, -4, 3]) → [1, -4, -17, 60]\n" -" factors = zip(repeat(1), map(operator.neg, roots))\n" -" return list(functools.reduce(convolve, factors, [1]))\n" +" factors = zip(repeat(1), map(neg, roots))\n" +" return list(reduce(convolve, factors, [1]))\n" "\n" "def polynomial_eval(coefficients, x):\n" " \"\"\"Evaluate a polynomial at a specific value.\n" @@ -1936,7 +1924,7 @@ msgid "" " if not n:\n" " return type(x)(0)\n" " powers = map(pow, repeat(x), reversed(range(n)))\n" -" return math.sumprod(coefficients, powers)\n" +" return sumprod(coefficients, powers)\n" "\n" "def polynomial_derivative(coefficients):\n" " \"\"\"Compute the first derivative of a polynomial.\n" @@ -1947,7 +1935,7 @@ msgid "" " # polynomial_derivative([1, -4, -17, 60]) → [3, -8, -17]\n" " n = len(coefficients)\n" " powers = reversed(range(1, n))\n" -" return list(map(operator.mul, coefficients, powers))\n" +" return list(map(mul, coefficients, powers))\n" "\n" "def sieve(n):\n" " \"Primes less than n.\"\n" @@ -1955,21 +1943,16 @@ msgid "" " if n > 2:\n" " yield 2\n" " data = bytearray((0, 1)) * (n // 2)\n" -" for p in iter_index(data, 1, start=3, stop=math.isqrt(n) + 1):\n" +" for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1):\n" " data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))\n" " yield from iter_index(data, 1, start=3)\n" "\n" -"def is_prime(n):\n" -" \"Return True if n is prime.\"\n" -" # is_prime(1_000_000_000_000_403) → True\n" -" return n > 1 and all(n % p for p in sieve(math.isqrt(n) + 1))\n" -"\n" "def factor(n):\n" " \"Prime factors of n.\"\n" " # factor(99) → 3 3 11\n" " # factor(1_000_000_000_000_007) → 47 59 360620266859\n" " # factor(1_000_000_000_000_403) → 1000000000000403\n" -" for prime in sieve(math.isqrt(n) + 1):\n" +" for prime in sieve(isqrt(n) + 1):\n" " while not n % prime:\n" " yield prime\n" " n //= prime\n" @@ -1978,6 +1961,11 @@ msgid "" " if n > 1:\n" " yield n\n" "\n" +"def is_prime(n):\n" +" \"Return True if n is prime.\"\n" +" # is_prime(1_000_000_000_000_403) → True\n" +" return n > 1 and next(factor(n)) == n\n" +"\n" "def totient(n):\n" " \"Count of natural numbers up to n that are coprime to n.\"\n" " # https://mathworld.wolfram.com/TotientFunction.html\n" @@ -1986,3 +1974,14 @@ msgid "" " n -= n // prime\n" " return n" msgstr "" + +#~ msgid "" +#~ "These tools and their built-in counterparts also work well with the high-" +#~ "speed functions in the :mod:`operator` module. For example, the " +#~ "multiplication operator can be mapped across two vectors to form an " +#~ "efficient dot-product: ``sum(starmap(operator.mul, zip(vec1, vec2, " +#~ "strict=True)))``." +#~ msgstr "" +#~ "這些工具及其內建的對等部分 (counterpart) 也可以很好地與 :mod:`operator` 模" +#~ "組中的高速函式配合使用。例如,乘法運算子可以對映到兩個向量上以組成高效率的" +#~ "內積:``sum(starmap(operator.mul, zip(vec1, vec2, strict=True)))``。" diff --git a/library/json.po b/library/json.po index a910b316ff..76e792b8cb 100644 --- a/library/json.po +++ b/library/json.po @@ -1153,7 +1153,7 @@ msgid "" "The :mod:`json.tool` module provides a simple command line interface to " "validate and pretty-print JSON objects." msgstr "" -":mod:`json.tool` 模組提供了一個簡易的命令列界面以供校驗與美化呈現 JSON 物件。" +":mod:`json.tool` 模組提供了一個簡易的命令列介面以供校驗與美化呈現 JSON 物件。" #: ../../library/json.rst:694 msgid "" diff --git a/library/optparse.po b/library/optparse.po index 7f39b49f93..b23b142f75 100644 --- a/library/optparse.po +++ b/library/optparse.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,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: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2018-05-23 16:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,20 +21,222 @@ msgstr "" msgid ":mod:`!optparse` --- Parser for command line options" msgstr ":mod:`!optparse` --- 命令列選項剖析器" -#: ../../library/optparse.rst:11 +#: ../../library/optparse.rst:10 msgid "**Source code:** :source:`Lib/optparse.py`" msgstr "**原始碼:**\\ :source:`Lib/optparse.py`" -#: ../../library/optparse.rst:13 +#: ../../library/optparse.rst:17 +msgid "Choosing an argument parsing library" +msgstr "選擇一個命令列參數剖析函式庫" + +#: ../../library/optparse.rst:19 +msgid "The standard library includes three argument parsing libraries:" +msgstr "標準函式庫包含三個命令列引數剖析函式庫:" + +#: ../../library/optparse.rst:21 +msgid "" +":mod:`getopt`: a module that closely mirrors the procedural C ``getopt`` " +"API. Included in the standard library since before the initial Python 1.0 " +"release." +msgstr "" + +#: ../../library/optparse.rst:23 +msgid "" +":mod:`optparse`: a declarative replacement for ``getopt`` that provides " +"equivalent functionality without requiring each application to implement its " +"own procedural option parsing logic. Included in the standard library since " +"the Python 2.3 release." +msgstr "" + +#: ../../library/optparse.rst:27 +msgid "" +":mod:`argparse`: a more opinionated alternative to ``optparse`` that " +"provides more functionality by default, at the expense of reduced " +"application flexibility in controlling exactly how arguments are processed. " +"Included in the standard library since the Python 2.7 and Python 3.2 " +"releases." +msgstr "" + +#: ../../library/optparse.rst:32 +msgid "" +"In the absence of more specific argument parsing design constraints, :mod:" +"`argparse` is the recommended choice for implementing command line " +"applications, as it offers the highest level of baseline functionality with " +"the least application level code." +msgstr "" + +#: ../../library/optparse.rst:36 +msgid "" +":mod:`getopt` is retained almost entirely for backwards compatibility " +"reasons. However, it also serves a niche use case as a tool for prototyping " +"and testing command line argument handling in ``getopt``-based C " +"applications." +msgstr "" + +#: ../../library/optparse.rst:40 +msgid "" +":mod:`optparse` should be considered as an alternative to :mod:`argparse` in " +"the following cases:" +msgstr "" + +#: ../../library/optparse.rst:43 +msgid "" +"an application is already using :mod:`optparse` and doesn't want to risk the " +"subtle behavioural changes that may arise when migrating to :mod:`argparse`" +msgstr "" + +#: ../../library/optparse.rst:45 +msgid "" +"the application requires additional control over the way options and " +"positional parameters are interleaved on the command line (including the " +"ability to disable the interleaving feature completely)" +msgstr "" + +#: ../../library/optparse.rst:48 +msgid "" +"the application requires additional control over the incremental parsing of " +"command line elements (while ``argparse`` does support this, the exact way " +"it works in practice is undesirable for some use cases)" +msgstr "" + +#: ../../library/optparse.rst:51 +msgid "" +"the application requires additional control over the handling of options " +"which accept parameter values that may start with ``-`` (such as delegated " +"options to be passed to invoked subprocesses)" +msgstr "" + +#: ../../library/optparse.rst:54 +msgid "" +"the application requires some other command line parameter processing " +"behavior which ``argparse`` does not support, but which can be implemented " +"in terms of the lower level interface offered by ``optparse``" +msgstr "" + +#: ../../library/optparse.rst:58 +msgid "" +"These considerations also mean that :mod:`optparse` is likely to provide a " +"better foundation for library authors writing third party command line " +"argument processing libraries." +msgstr "" + +#: ../../library/optparse.rst:62 +msgid "" +"As a concrete example, consider the following two command line argument " +"parsing configurations, the first using ``optparse``, and the second using " +"``argparse``:" +msgstr "" + +#: ../../library/optparse.rst:66 +msgid "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" +msgstr "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" + +#: ../../library/optparse.rst:77 +msgid "" +"import argparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-o', '--output')\n" +" parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" +" args = parser.parse_args()\n" +" process(args.rest, output=args.output, verbose=args.verbose)" +msgstr "" +"import argparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-o', '--output')\n" +" parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" +" args = parser.parse_args()\n" +" process(args.rest, output=args.output, verbose=args.verbose)" + +#: ../../library/optparse.rst:89 +msgid "" +"The most obvious difference is that in the ``optparse`` version, the non-" +"option arguments are processed separately by the application after the " +"option processing is complete. In the ``argparse`` version, positional " +"arguments are declared and processed in the same way as the named options." +msgstr "" + +#: ../../library/optparse.rst:94 +msgid "" +"However, the ``argparse`` version will also handle some parameter " +"combination differently from the way the ``optparse`` version would handle " +"them. For example (amongst other differences):" +msgstr "" + +#: ../../library/optparse.rst:98 +msgid "" +"supplying ``-o -v`` gives ``output=\"-v\"`` and ``verbose=False`` when using " +"``optparse``, but a usage error with ``argparse`` (complaining that no value " +"has been supplied for ``-o/--output``, since ``-v`` is interpreted as " +"meaning the verbosity flag)" +msgstr "" + +#: ../../library/optparse.rst:102 +msgid "" +"similarly, supplying ``-o --`` gives ``output=\"--\"`` and ``args=()`` when " +"using ``optparse``, but a usage error with ``argparse`` (also complaining " +"that no value has been supplied for ``-o/--output``, since ``--`` is " +"interpreted as terminating the option processing and treating all remaining " +"values as positional arguments)" +msgstr "" + +#: ../../library/optparse.rst:107 msgid "" -"The :mod:`optparse` module is :term:`soft deprecated` and will not be " -"developed further; development will continue with the :mod:`argparse` module." +"supplying ``-o=foo`` gives ``output=\"=foo\"`` when using ``optparse``, but " +"gives ``output=\"foo\"`` with ``argparse`` (since ``=`` is special cased as " +"an alternative separator for option parameter values)" msgstr "" -#: ../../library/optparse.rst:20 +#: ../../library/optparse.rst:111 +msgid "" +"Whether these differing behaviors in the ``argparse`` version are considered " +"desirable or a problem will depend on the specific command line application " +"use case." +msgstr "" + +#: ../../library/optparse.rst:117 +msgid "" +":pypi:`click` is a third party argument processing library (originally based " +"on ``optparse``), which allows command line applications to be developed as " +"a set of decorated command implementation functions." +msgstr "" + +#: ../../library/optparse.rst:121 +msgid "" +"Other third party libraries, such as :pypi:`typer` or :pypi:`msgspec-click`, " +"allow command line interfaces to be specified in ways that more effectively " +"integrate with static checking of Python type annotations." +msgstr "" + +#: ../../library/optparse.rst:127 +msgid "Introduction" +msgstr "" + +#: ../../library/optparse.rst:129 msgid "" ":mod:`optparse` is a more convenient, flexible, and powerful library for " -"parsing command-line options than the old :mod:`getopt` module. :mod:" +"parsing command-line options than the minimalist :mod:`getopt` module. :mod:" "`optparse` uses a more declarative style of command-line parsing: you create " "an instance of :class:`OptionParser`, populate it with options, and parse " "the command line. :mod:`optparse` allows users to specify options in the " @@ -43,11 +244,11 @@ msgid "" "messages for you." msgstr "" -#: ../../library/optparse.rst:27 +#: ../../library/optparse.rst:137 msgid "Here's an example of using :mod:`optparse` in a simple script::" msgstr "" -#: ../../library/optparse.rst:29 +#: ../../library/optparse.rst:139 msgid "" "from optparse import OptionParser\n" "...\n" @@ -60,18 +261,28 @@ msgid "" "\n" "(options, args) = parser.parse_args()" msgstr "" +"from optparse import OptionParser\n" +"...\n" +"parser = OptionParser()\n" +"parser.add_option(\"-f\", \"--file\", dest=\"filename\",\n" +" help=\"write report to FILE\", metavar=\"FILE\")\n" +"parser.add_option(\"-q\", \"--quiet\",\n" +" action=\"store_false\", dest=\"verbose\", default=True,\n" +" help=\"don't print status messages to stdout\")\n" +"\n" +"(options, args) = parser.parse_args()" -#: ../../library/optparse.rst:40 +#: ../../library/optparse.rst:150 msgid "" "With these few lines of code, users of your script can now do the \"usual " "thing\" on the command-line, for example::" msgstr "" -#: ../../library/optparse.rst:43 +#: ../../library/optparse.rst:153 msgid " --file=outfile -q" -msgstr "" +msgstr " --file=outfile -q" -#: ../../library/optparse.rst:45 +#: ../../library/optparse.rst:155 msgid "" "As it parses the command line, :mod:`optparse` sets attributes of the " "``options`` object returned by :meth:`~OptionParser.parse_args` based on " @@ -84,7 +295,7 @@ msgid "" "the above example::" msgstr "" -#: ../../library/optparse.rst:54 +#: ../../library/optparse.rst:164 msgid "" " -f outfile --quiet\n" " --quiet --file outfile\n" @@ -92,22 +303,24 @@ msgid "" " -qfoutfile" msgstr "" -#: ../../library/optparse.rst:59 +#: ../../library/optparse.rst:169 msgid "Additionally, users can run one of the following ::" msgstr "" -#: ../../library/optparse.rst:61 +#: ../../library/optparse.rst:171 msgid "" " -h\n" " --help" msgstr "" +" -h\n" +" --help" -#: ../../library/optparse.rst:64 +#: ../../library/optparse.rst:174 msgid "" "and :mod:`optparse` will print out a brief summary of your script's options:" msgstr "" -#: ../../library/optparse.rst:66 +#: ../../library/optparse.rst:176 msgid "" "Usage: [options]\n" "\n" @@ -116,35 +329,43 @@ msgid "" " -f FILE, --file=FILE write report to FILE\n" " -q, --quiet don't print status messages to stdout" msgstr "" +"Usage: [options]\n" +"\n" +"Options:\n" +" -h, --help show this help message and exit\n" +" -f FILE, --file=FILE write report to FILE\n" +" -q, --quiet don't print status messages to stdout" -#: ../../library/optparse.rst:75 +#: ../../library/optparse.rst:185 msgid "" "where the value of *yourscript* is determined at runtime (normally from " "``sys.argv[0]``)." msgstr "" -#: ../../library/optparse.rst:82 +#: ../../library/optparse.rst:192 msgid "Background" msgstr "背景" -#: ../../library/optparse.rst:84 +#: ../../library/optparse.rst:194 msgid "" ":mod:`optparse` was explicitly designed to encourage the creation of " -"programs with straightforward, conventional command-line interfaces. To " -"that end, it supports only the most common command-line syntax and semantics " -"conventionally used under Unix. If you are unfamiliar with these " -"conventions, read this section to acquaint yourself with them." +"programs with straightforward command-line interfaces that follow the " +"conventions established by the :c:func:`!getopt` family of functions " +"available to C developers. To that end, it supports only the most common " +"command-line syntax and semantics conventionally used under Unix. If you " +"are unfamiliar with these conventions, reading this section will allow you " +"to acquaint yourself with them." msgstr "" -#: ../../library/optparse.rst:94 +#: ../../library/optparse.rst:205 msgid "Terminology" msgstr "術語" -#: ../../library/optparse.rst:96 +#: ../../library/optparse.rst:207 msgid "argument" -msgstr "" +msgstr "引數" -#: ../../library/optparse.rst:97 +#: ../../library/optparse.rst:208 msgid "" "a string entered on the command-line, and passed by the shell to ``execl()`` " "or ``execv()``. In Python, arguments are elements of ``sys.argv[1:]`` " @@ -152,7 +373,7 @@ msgid "" "also use the term \"word\"." msgstr "" -#: ../../library/optparse.rst:102 +#: ../../library/optparse.rst:213 msgid "" "It is occasionally desirable to substitute an argument list other than ``sys." "argv[1:]``, so you should read \"argument\" as \"an element of ``sys." @@ -160,11 +381,11 @@ msgid "" "argv[1:]``\"." msgstr "" -#: ../../library/optparse.rst:107 +#: ../../library/optparse.rst:218 msgid "option" -msgstr "" +msgstr "選項" -#: ../../library/optparse.rst:108 +#: ../../library/optparse.rst:219 msgid "" "an argument used to supply extra information to guide or customize the " "execution of a program. There are many different syntaxes for options; the " @@ -176,36 +397,36 @@ msgid "" "option syntaxes provided by :mod:`optparse`." msgstr "" -#: ../../library/optparse.rst:117 +#: ../../library/optparse.rst:228 msgid "Some other option syntaxes that the world has seen include:" msgstr "" -#: ../../library/optparse.rst:119 +#: ../../library/optparse.rst:230 msgid "" "a hyphen followed by a few letters, e.g. ``-pf`` (this is *not* the same as " "multiple options merged into a single argument)" msgstr "" -#: ../../library/optparse.rst:122 +#: ../../library/optparse.rst:233 msgid "" "a hyphen followed by a whole word, e.g. ``-file`` (this is technically " "equivalent to the previous syntax, but they aren't usually seen in the same " "program)" msgstr "" -#: ../../library/optparse.rst:126 +#: ../../library/optparse.rst:237 msgid "" "a plus sign followed by a single letter, or a few letters, or a word, e.g. " "``+f``, ``+rgb``" msgstr "" -#: ../../library/optparse.rst:129 +#: ../../library/optparse.rst:240 msgid "" "a slash followed by a letter, or a few letters, or a word, e.g. ``/f``, ``/" "file``" msgstr "" -#: ../../library/optparse.rst:132 +#: ../../library/optparse.rst:243 msgid "" "These option syntaxes are not supported by :mod:`optparse`, and they never " "will be. This is deliberate: the first three are non-standard on any " @@ -213,11 +434,11 @@ msgid "" "Windows or certain legacy platforms (e.g. VMS, MS-DOS)." msgstr "" -#: ../../library/optparse.rst:137 +#: ../../library/optparse.rst:248 msgid "option argument" -msgstr "" +msgstr "選項引數" -#: ../../library/optparse.rst:138 +#: ../../library/optparse.rst:249 msgid "" "an argument that follows an option, is closely associated with that option, " "and is consumed from the argument list when that option is. With :mod:" @@ -225,23 +446,27 @@ msgid "" "option:" msgstr "" -#: ../../library/optparse.rst:143 +#: ../../library/optparse.rst:254 msgid "" "-f foo\n" "--file foo" msgstr "" +"-f foo\n" +"--file foo" -#: ../../library/optparse.rst:148 +#: ../../library/optparse.rst:259 msgid "or included in the same argument:" msgstr "" -#: ../../library/optparse.rst:150 +#: ../../library/optparse.rst:261 msgid "" "-ffoo\n" "--file=foo" msgstr "" +"-ffoo\n" +"--file=foo" -#: ../../library/optparse.rst:155 +#: ../../library/optparse.rst:266 msgid "" "Typically, a given option either takes an argument or it doesn't. Lots of " "people want an \"optional option arguments\" feature, meaning that some " @@ -252,22 +477,22 @@ msgid "" "support this feature." msgstr "" -#: ../../library/optparse.rst:163 +#: ../../library/optparse.rst:274 msgid "positional argument" -msgstr "" +msgstr "位置引數" -#: ../../library/optparse.rst:164 +#: ../../library/optparse.rst:275 msgid "" "something leftover in the argument list after options have been parsed, i.e. " "after options and their arguments have been parsed and removed from the " "argument list." msgstr "" -#: ../../library/optparse.rst:168 +#: ../../library/optparse.rst:279 msgid "required option" msgstr "" -#: ../../library/optparse.rst:169 +#: ../../library/optparse.rst:280 msgid "" "an option that must be supplied on the command-line; note that the phrase " "\"required option\" is self-contradictory in English. :mod:`optparse` " @@ -275,26 +500,26 @@ msgid "" "much help at it either." msgstr "" -#: ../../library/optparse.rst:174 +#: ../../library/optparse.rst:285 msgid "For example, consider this hypothetical command-line::" msgstr "" -#: ../../library/optparse.rst:176 +#: ../../library/optparse.rst:287 msgid "prog -v --report report.txt foo bar" -msgstr "" +msgstr "prog -v --report report.txt foo bar" -#: ../../library/optparse.rst:178 +#: ../../library/optparse.rst:289 msgid "" "``-v`` and ``--report`` are both options. Assuming that ``--report`` takes " "one argument, ``report.txt`` is an option argument. ``foo`` and ``bar`` are " "positional arguments." msgstr "" -#: ../../library/optparse.rst:186 +#: ../../library/optparse.rst:297 msgid "What are options for?" msgstr "" -#: ../../library/optparse.rst:188 +#: ../../library/optparse.rst:299 msgid "" "Options are used to provide extra information to tune or customize the " "execution of a program. In case it wasn't clear, options are usually " @@ -306,7 +531,7 @@ msgid "" "interfaces.)" msgstr "" -#: ../../library/optparse.rst:196 +#: ../../library/optparse.rst:307 msgid "" "Lots of people want their programs to have \"required options\". Think " "about it. If it's required, then it's *not optional*! If there is a piece " @@ -314,7 +539,7 @@ msgid "" "successfully, that's what positional arguments are for." msgstr "" -#: ../../library/optparse.rst:201 +#: ../../library/optparse.rst:312 msgid "" "As an example of good command-line interface design, consider the humble " "``cp`` utility, for copying files. It doesn't make much sense to try to " @@ -323,13 +548,15 @@ msgid "" "useful syntax that does not require any options at all::" msgstr "" -#: ../../library/optparse.rst:207 +#: ../../library/optparse.rst:318 msgid "" "cp SOURCE DEST\n" "cp SOURCE ... DEST-DIR" msgstr "" +"cp SOURCE DEST\n" +"cp SOURCE ... DEST-DIR" -#: ../../library/optparse.rst:210 +#: ../../library/optparse.rst:321 msgid "" "You can get pretty far with just that. Most ``cp`` implementations provide " "a bunch of options to tweak exactly how the files are copied: you can " @@ -339,17 +566,17 @@ msgid "" "files to another directory." msgstr "" -#: ../../library/optparse.rst:221 +#: ../../library/optparse.rst:332 msgid "What are positional arguments for?" msgstr "" -#: ../../library/optparse.rst:223 +#: ../../library/optparse.rst:334 msgid "" "Positional arguments are for those pieces of information that your program " "absolutely, positively requires to run." msgstr "" -#: ../../library/optparse.rst:226 +#: ../../library/optparse.rst:337 msgid "" "A good user interface should have as few absolute requirements as possible. " "If your program requires 17 distinct pieces of information in order to run " @@ -360,7 +587,7 @@ msgid "" "most of them will simply give up." msgstr "" -#: ../../library/optparse.rst:234 +#: ../../library/optparse.rst:345 msgid "" "In short, try to minimize the amount of information that users are " "absolutely required to supply---use sensible defaults whenever possible. Of " @@ -373,65 +600,70 @@ msgid "" "make your code much harder to maintain." msgstr "" -#: ../../library/optparse.rst:247 +#: ../../library/optparse.rst:358 msgid "Tutorial" msgstr "教學" -#: ../../library/optparse.rst:249 +#: ../../library/optparse.rst:360 msgid "" "While :mod:`optparse` is quite flexible and powerful, it's also " "straightforward to use in most cases. This section covers the code patterns " "that are common to any :mod:`optparse`\\ -based program." msgstr "" -#: ../../library/optparse.rst:253 +#: ../../library/optparse.rst:364 msgid "" "First, you need to import the OptionParser class; then, early in the main " "program, create an OptionParser instance::" msgstr "" -#: ../../library/optparse.rst:256 +#: ../../library/optparse.rst:367 msgid "" "from optparse import OptionParser\n" "...\n" "parser = OptionParser()" msgstr "" +"from optparse import OptionParser\n" +"...\n" +"parser = OptionParser()" -#: ../../library/optparse.rst:260 +#: ../../library/optparse.rst:371 msgid "Then you can start defining options. The basic syntax is::" msgstr "" -#: ../../library/optparse.rst:262 +#: ../../library/optparse.rst:373 msgid "" "parser.add_option(opt_str, ...,\n" " attr=value, ...)" msgstr "" +"parser.add_option(opt_str, ...,\n" +" attr=value, ...)" -#: ../../library/optparse.rst:265 +#: ../../library/optparse.rst:376 msgid "" "Each option has one or more option strings, such as ``-f`` or ``--file``, " "and several option attributes that tell :mod:`optparse` what to expect and " "what to do when it encounters that option on the command line." msgstr "" -#: ../../library/optparse.rst:269 +#: ../../library/optparse.rst:380 msgid "" "Typically, each option will have one short option string and one long option " "string, e.g.::" msgstr "" -#: ../../library/optparse.rst:272 +#: ../../library/optparse.rst:383 msgid "parser.add_option(\"-f\", \"--file\", ...)" -msgstr "" +msgstr "parser.add_option(\"-f\", \"--file\", ...)" -#: ../../library/optparse.rst:274 +#: ../../library/optparse.rst:385 msgid "" "You're free to define as many short option strings and as many long option " "strings as you like (including zero), as long as there is at least one " "option string overall." msgstr "" -#: ../../library/optparse.rst:278 +#: ../../library/optparse.rst:389 msgid "" "The option strings passed to :meth:`OptionParser.add_option` are effectively " "labels for the option defined by that call. For brevity, we will frequently " @@ -439,28 +671,28 @@ msgid "" "`optparse` encounters *option strings* and looks up options from them." msgstr "" -#: ../../library/optparse.rst:284 +#: ../../library/optparse.rst:395 msgid "" "Once all of your options are defined, instruct :mod:`optparse` to parse your " "program's command line::" msgstr "" -#: ../../library/optparse.rst:287 +#: ../../library/optparse.rst:398 msgid "(options, args) = parser.parse_args()" -msgstr "" +msgstr "(options, args) = parser.parse_args()" -#: ../../library/optparse.rst:289 +#: ../../library/optparse.rst:400 msgid "" "(If you like, you can pass a custom argument list to :meth:`~OptionParser." "parse_args`, but that's rarely necessary: by default it uses ``sys." "argv[1:]``.)" msgstr "" -#: ../../library/optparse.rst:292 +#: ../../library/optparse.rst:403 msgid ":meth:`~OptionParser.parse_args` returns two values:" msgstr ":meth:`~OptionParser.parse_args` 回傳兩個值:" -#: ../../library/optparse.rst:294 +#: ../../library/optparse.rst:405 msgid "" "``options``, an object containing values for all of your options---e.g. if " "``--file`` takes a single string argument, then ``options.file`` will be the " @@ -468,12 +700,12 @@ msgid "" "option" msgstr "" -#: ../../library/optparse.rst:299 +#: ../../library/optparse.rst:410 msgid "" "``args``, the list of positional arguments leftover after parsing options" msgstr "" -#: ../../library/optparse.rst:301 +#: ../../library/optparse.rst:412 msgid "" "This tutorial section only covers the four most important option " "attributes: :attr:`~Option.action`, :attr:`~Option.type`, :attr:`~Option." @@ -481,11 +713,11 @@ msgid "" "action` is the most fundamental." msgstr "" -#: ../../library/optparse.rst:310 +#: ../../library/optparse.rst:421 msgid "Understanding option actions" msgstr "" -#: ../../library/optparse.rst:312 +#: ../../library/optparse.rst:423 msgid "" "Actions tell :mod:`optparse` what to do when it encounters an option on the " "command line. There is a fixed set of actions hard-coded into :mod:" @@ -495,44 +727,48 @@ msgid "" "and store it in an attribute of ``options``." msgstr "" -#: ../../library/optparse.rst:319 +#: ../../library/optparse.rst:430 msgid "" "If you don't specify an option action, :mod:`optparse` defaults to ``store``." msgstr "" -#: ../../library/optparse.rst:325 +#: ../../library/optparse.rst:436 msgid "The store action" msgstr "" -#: ../../library/optparse.rst:327 +#: ../../library/optparse.rst:438 msgid "" "The most common option action is ``store``, which tells :mod:`optparse` to " "take the next argument (or the remainder of the current argument), ensure " "that it is of the correct type, and store it to your chosen destination." msgstr "" -#: ../../library/optparse.rst:331 +#: ../../library/optparse.rst:442 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/optparse.rst:333 +#: ../../library/optparse.rst:444 msgid "" "parser.add_option(\"-f\", \"--file\",\n" " action=\"store\", type=\"string\", dest=\"filename\")" msgstr "" +"parser.add_option(\"-f\", \"--file\",\n" +" action=\"store\", type=\"string\", dest=\"filename\")" -#: ../../library/optparse.rst:336 +#: ../../library/optparse.rst:447 msgid "" "Now let's make up a fake command line and ask :mod:`optparse` to parse it::" msgstr "" -#: ../../library/optparse.rst:338 +#: ../../library/optparse.rst:449 msgid "" "args = [\"-f\", \"foo.txt\"]\n" "(options, args) = parser.parse_args(args)" msgstr "" +"args = [\"-f\", \"foo.txt\"]\n" +"(options, args) = parser.parse_args(args)" -#: ../../library/optparse.rst:341 +#: ../../library/optparse.rst:452 msgid "" "When :mod:`optparse` sees the option string ``-f``, it consumes the next " "argument, ``foo.txt``, and stores it in ``options.filename``. So, after " @@ -540,51 +776,53 @@ msgid "" "``\"foo.txt\"``." msgstr "" -#: ../../library/optparse.rst:345 +#: ../../library/optparse.rst:456 msgid "" "Some other option types supported by :mod:`optparse` are ``int`` and " "``float``. Here's an option that expects an integer argument::" msgstr "" -#: ../../library/optparse.rst:348 +#: ../../library/optparse.rst:459 msgid "parser.add_option(\"-n\", type=\"int\", dest=\"num\")" -msgstr "" +msgstr "parser.add_option(\"-n\", type=\"int\", dest=\"num\")" -#: ../../library/optparse.rst:350 +#: ../../library/optparse.rst:461 msgid "" "Note that this option has no long option string, which is perfectly " "acceptable. Also, there's no explicit action, since the default is ``store``." msgstr "" -#: ../../library/optparse.rst:353 +#: ../../library/optparse.rst:464 msgid "" "Let's parse another fake command-line. This time, we'll jam the option " "argument right up against the option: since ``-n42`` (one argument) is " "equivalent to ``-n 42`` (two arguments), the code ::" msgstr "" -#: ../../library/optparse.rst:357 +#: ../../library/optparse.rst:468 msgid "" "(options, args) = parser.parse_args([\"-n42\"])\n" "print(options.num)" msgstr "" +"(options, args) = parser.parse_args([\"-n42\"])\n" +"print(options.num)" -#: ../../library/optparse.rst:360 +#: ../../library/optparse.rst:471 msgid "will print ``42``." -msgstr "" +msgstr "會印出 ``42``。" -#: ../../library/optparse.rst:362 +#: ../../library/optparse.rst:473 msgid "" "If you don't specify a type, :mod:`optparse` assumes ``string``. Combined " "with the fact that the default action is ``store``, that means our first " "example can be a lot shorter::" msgstr "" -#: ../../library/optparse.rst:366 +#: ../../library/optparse.rst:477 msgid "parser.add_option(\"-f\", \"--file\", dest=\"filename\")" -msgstr "" +msgstr "parser.add_option(\"-f\", \"--file\", dest=\"filename\")" -#: ../../library/optparse.rst:368 +#: ../../library/optparse.rst:479 msgid "" "If you don't supply a destination, :mod:`optparse` figures out a sensible " "default from the option strings: if the first long option string is ``--foo-" @@ -593,17 +831,17 @@ msgid "" "default destination for ``-f`` is ``f``." msgstr "" -#: ../../library/optparse.rst:374 +#: ../../library/optparse.rst:485 msgid "" ":mod:`optparse` also includes the built-in ``complex`` type. Adding types " "is covered in section :ref:`optparse-extending-optparse`." msgstr "" -#: ../../library/optparse.rst:381 +#: ../../library/optparse.rst:492 msgid "Handling boolean (flag) options" msgstr "" -#: ../../library/optparse.rst:383 +#: ../../library/optparse.rst:494 msgid "" "Flag options---set a variable to true or false when a particular option is " "seen---are quite common. :mod:`optparse` supports them with two separate " @@ -611,77 +849,79 @@ msgid "" "``verbose`` flag that is turned on with ``-v`` and off with ``-q``::" msgstr "" -#: ../../library/optparse.rst:388 +#: ../../library/optparse.rst:499 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\")\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\")" msgstr "" +"parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\")\n" +"parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\")" -#: ../../library/optparse.rst:391 +#: ../../library/optparse.rst:502 msgid "" "Here we have two different options with the same destination, which is " "perfectly OK. (It just means you have to be a bit careful when setting " "default values---see below.)" msgstr "" -#: ../../library/optparse.rst:395 +#: ../../library/optparse.rst:506 msgid "" "When :mod:`optparse` encounters ``-v`` on the command line, it sets " "``options.verbose`` to ``True``; when it encounters ``-q``, ``options." "verbose`` is set to ``False``." msgstr "" -#: ../../library/optparse.rst:403 +#: ../../library/optparse.rst:514 msgid "Other actions" msgstr "" -#: ../../library/optparse.rst:405 +#: ../../library/optparse.rst:516 msgid "Some other actions supported by :mod:`optparse` are:" msgstr "" -#: ../../library/optparse.rst:407 ../../library/optparse.rst:929 +#: ../../library/optparse.rst:518 ../../library/optparse.rst:1040 msgid "``\"store_const\"``" msgstr "``\"store_const\"``" -#: ../../library/optparse.rst:408 ../../library/optparse.rst:930 +#: ../../library/optparse.rst:519 ../../library/optparse.rst:1041 msgid "store a constant value, pre-set via :attr:`Option.const`" msgstr "" -#: ../../library/optparse.rst:410 ../../library/optparse.rst:938 +#: ../../library/optparse.rst:521 ../../library/optparse.rst:1049 msgid "``\"append\"``" msgstr "``\"append\"``" -#: ../../library/optparse.rst:411 ../../library/optparse.rst:939 +#: ../../library/optparse.rst:522 ../../library/optparse.rst:1050 msgid "append this option's argument to a list" msgstr "" -#: ../../library/optparse.rst:413 ../../library/optparse.rst:944 +#: ../../library/optparse.rst:524 ../../library/optparse.rst:1055 msgid "``\"count\"``" msgstr "``\"count\"``" -#: ../../library/optparse.rst:414 ../../library/optparse.rst:945 +#: ../../library/optparse.rst:525 ../../library/optparse.rst:1056 msgid "increment a counter by one" msgstr "" -#: ../../library/optparse.rst:416 ../../library/optparse.rst:947 +#: ../../library/optparse.rst:527 ../../library/optparse.rst:1058 msgid "``\"callback\"``" msgstr "``\"callback\"``" -#: ../../library/optparse.rst:417 ../../library/optparse.rst:948 +#: ../../library/optparse.rst:528 ../../library/optparse.rst:1059 msgid "call a specified function" msgstr "" -#: ../../library/optparse.rst:419 +#: ../../library/optparse.rst:530 msgid "" "These are covered in section :ref:`optparse-reference-guide`, and section :" "ref:`optparse-option-callbacks`." msgstr "" -#: ../../library/optparse.rst:426 +#: ../../library/optparse.rst:537 msgid "Default values" -msgstr "" +msgstr "預設值" -#: ../../library/optparse.rst:428 +#: ../../library/optparse.rst:539 msgid "" "All of the above examples involve setting some variable (the " "\"destination\") when certain command-line options are seen. What happens " @@ -691,77 +931,87 @@ msgid "" "destination, which is assigned before the command line is parsed." msgstr "" -#: ../../library/optparse.rst:435 +#: ../../library/optparse.rst:546 msgid "" "First, consider the verbose/quiet example. If we want :mod:`optparse` to " "set ``verbose`` to ``True`` unless ``-q`` is seen, then we can do this::" msgstr "" -#: ../../library/optparse.rst:438 +#: ../../library/optparse.rst:549 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\", " "default=True)\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\")" msgstr "" +"parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\", " +"default=True)\n" +"parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\")" -#: ../../library/optparse.rst:441 +#: ../../library/optparse.rst:552 msgid "" "Since default values apply to the *destination* rather than to any " "particular option, and these two options happen to have the same " "destination, this is exactly equivalent::" msgstr "" -#: ../../library/optparse.rst:445 +#: ../../library/optparse.rst:556 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\")\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\", " "default=True)" msgstr "" -#: ../../library/optparse.rst:448 +#: ../../library/optparse.rst:559 msgid "Consider this::" msgstr "" -#: ../../library/optparse.rst:450 +#: ../../library/optparse.rst:561 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\", " "default=False)\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\", " "default=True)" msgstr "" +"parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\", " +"default=False)\n" +"parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\", " +"default=True)" -#: ../../library/optparse.rst:453 +#: ../../library/optparse.rst:564 msgid "" "Again, the default value for ``verbose`` will be ``True``: the last default " "value supplied for any particular destination is the one that counts." msgstr "" -#: ../../library/optparse.rst:456 +#: ../../library/optparse.rst:567 msgid "" "A clearer way to specify default values is the :meth:`set_defaults` method " "of OptionParser, which you can call at any time before calling :meth:" "`~OptionParser.parse_args`::" msgstr "" -#: ../../library/optparse.rst:460 +#: ../../library/optparse.rst:571 msgid "" "parser.set_defaults(verbose=True)\n" "parser.add_option(...)\n" "(options, args) = parser.parse_args()" msgstr "" +"parser.set_defaults(verbose=True)\n" +"parser.add_option(...)\n" +"(options, args) = parser.parse_args()" -#: ../../library/optparse.rst:464 +#: ../../library/optparse.rst:575 msgid "" "As before, the last value specified for a given option destination is the " "one that counts. For clarity, try to use one method or the other of setting " "default values, not both." msgstr "" -#: ../../library/optparse.rst:472 +#: ../../library/optparse.rst:583 msgid "Generating help" msgstr "" -#: ../../library/optparse.rst:474 +#: ../../library/optparse.rst:585 msgid "" ":mod:`optparse`'s ability to generate help and usage text automatically is " "useful for creating user-friendly command-line interfaces. All you have to " @@ -770,7 +1020,7 @@ msgid "" "populated with user-friendly (documented) options::" msgstr "" -#: ../../library/optparse.rst:480 +#: ../../library/optparse.rst:591 msgid "" "usage = \"usage: %prog [options] arg1 arg2\"\n" "parser = OptionParser(usage=usage)\n" @@ -787,15 +1037,29 @@ msgid "" " help=\"interaction mode: novice, intermediate, \"\n" " \"or expert [default: %default]\")" msgstr "" +"usage = \"usage: %prog [options] arg1 arg2\"\n" +"parser = OptionParser(usage=usage)\n" +"parser.add_option(\"-v\", \"--verbose\",\n" +" action=\"store_true\", dest=\"verbose\", default=True,\n" +" help=\"make lots of noise [default]\")\n" +"parser.add_option(\"-q\", \"--quiet\",\n" +" action=\"store_false\", dest=\"verbose\",\n" +" help=\"be vewwy quiet (I'm hunting wabbits)\")\n" +"parser.add_option(\"-f\", \"--filename\",\n" +" metavar=\"FILE\", help=\"write output to FILE\")\n" +"parser.add_option(\"-m\", \"--mode\",\n" +" default=\"intermediate\",\n" +" help=\"interaction mode: novice, intermediate, \"\n" +" \"or expert [default: %default]\")" -#: ../../library/optparse.rst:495 +#: ../../library/optparse.rst:606 msgid "" "If :mod:`optparse` encounters either ``-h`` or ``--help`` on the command-" "line, or if you just call :meth:`parser.print_help`, it prints the following " "to standard output:" msgstr "" -#: ../../library/optparse.rst:499 +#: ../../library/optparse.rst:610 msgid "" "Usage: [options] arg1 arg2\n" "\n" @@ -808,59 +1072,69 @@ msgid "" " -m MODE, --mode=MODE interaction mode: novice, intermediate, or\n" " expert [default: intermediate]" msgstr "" +"Usage: [options] arg1 arg2\n" +"\n" +"Options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbose make lots of noise [default]\n" +" -q, --quiet be vewwy quiet (I'm hunting wabbits)\n" +" -f FILE, --filename=FILE\n" +" write output to FILE\n" +" -m MODE, --mode=MODE interaction mode: novice, intermediate, or\n" +" expert [default: intermediate]" -#: ../../library/optparse.rst:512 +#: ../../library/optparse.rst:623 msgid "" "(If the help output is triggered by a help option, :mod:`optparse` exits " "after printing the help text.)" msgstr "" -#: ../../library/optparse.rst:515 +#: ../../library/optparse.rst:626 msgid "" "There's a lot going on here to help :mod:`optparse` generate the best " "possible help message:" msgstr "" -#: ../../library/optparse.rst:518 +#: ../../library/optparse.rst:629 msgid "the script defines its own usage message::" msgstr "" -#: ../../library/optparse.rst:520 +#: ../../library/optparse.rst:631 msgid "usage = \"usage: %prog [options] arg1 arg2\"" -msgstr "" +msgstr "usage = \"usage: %prog [options] arg1 arg2\"" -#: ../../library/optparse.rst:522 +#: ../../library/optparse.rst:633 msgid "" ":mod:`optparse` expands ``%prog`` in the usage string to the name of the " "current program, i.e. ``os.path.basename(sys.argv[0])``. The expanded " "string is then printed before the detailed option help." msgstr "" -#: ../../library/optparse.rst:526 +#: ../../library/optparse.rst:637 msgid "" "If you don't supply a usage string, :mod:`optparse` uses a bland but " "sensible default: ``\"Usage: %prog [options]\"``, which is fine if your " "script doesn't take any positional arguments." msgstr "" -#: ../../library/optparse.rst:530 +#: ../../library/optparse.rst:641 msgid "" "every option defines a help string, and doesn't worry about line-wrapping---" "\\ :mod:`optparse` takes care of wrapping lines and making the help output " "look good." msgstr "" -#: ../../library/optparse.rst:534 +#: ../../library/optparse.rst:645 msgid "" "options that take a value indicate this fact in their automatically " "generated help message, e.g. for the \"mode\" option::" msgstr "" -#: ../../library/optparse.rst:537 +#: ../../library/optparse.rst:648 msgid "-m MODE, --mode=MODE" -msgstr "" +msgstr "-m MODE, --mode=MODE" -#: ../../library/optparse.rst:539 +#: ../../library/optparse.rst:650 msgid "" "Here, \"MODE\" is called the meta-variable: it stands for the argument that " "the user is expected to supply to ``-m``/``--mode``. By default, :mod:" @@ -870,11 +1144,11 @@ msgid "" "this automatically generated option description::" msgstr "" -#: ../../library/optparse.rst:546 +#: ../../library/optparse.rst:657 msgid "-f FILE, --filename=FILE" -msgstr "" +msgstr "-f FILE, --filename=FILE" -#: ../../library/optparse.rst:548 +#: ../../library/optparse.rst:659 msgid "" "This is important for more than just saving space, though: the manually " "written help text uses the meta-variable ``FILE`` to clue the user in that " @@ -884,7 +1158,7 @@ msgid "" "users." msgstr "" -#: ../../library/optparse.rst:554 +#: ../../library/optparse.rst:665 msgid "" "options that have a default value can include ``%default`` in the help " "string---\\ :mod:`optparse` will replace it with :func:`str` of the option's " @@ -892,58 +1166,58 @@ msgid "" "``None``), ``%default`` expands to ``none``." msgstr "" -#: ../../library/optparse.rst:560 +#: ../../library/optparse.rst:671 msgid "Grouping Options" msgstr "" -#: ../../library/optparse.rst:562 +#: ../../library/optparse.rst:673 msgid "" "When dealing with many options, it is convenient to group these options for " "better help output. An :class:`OptionParser` can contain several option " "groups, each of which can contain several options." msgstr "" -#: ../../library/optparse.rst:566 +#: ../../library/optparse.rst:677 msgid "An option group is obtained using the class :class:`OptionGroup`:" msgstr "" -#: ../../library/optparse.rst:570 ../../library/optparse.rst:1641 +#: ../../library/optparse.rst:681 ../../library/optparse.rst:1752 msgid "where" msgstr "" -#: ../../library/optparse.rst:572 +#: ../../library/optparse.rst:683 msgid "" "parser is the :class:`OptionParser` instance the group will be inserted in to" msgstr "" -#: ../../library/optparse.rst:574 +#: ../../library/optparse.rst:685 msgid "title is the group title" msgstr "" -#: ../../library/optparse.rst:575 +#: ../../library/optparse.rst:686 msgid "description, optional, is a long description of the group" msgstr "" -#: ../../library/optparse.rst:577 +#: ../../library/optparse.rst:688 msgid "" ":class:`OptionGroup` inherits from :class:`OptionContainer` (like :class:" "`OptionParser`) and so the :meth:`add_option` method can be used to add an " "option to the group." msgstr "" -#: ../../library/optparse.rst:581 +#: ../../library/optparse.rst:692 msgid "" "Once all the options are declared, using the :class:`OptionParser` method :" "meth:`add_option_group` the group is added to the previously defined parser." msgstr "" -#: ../../library/optparse.rst:584 +#: ../../library/optparse.rst:695 msgid "" "Continuing with the parser defined in the previous section, adding an :class:" "`OptionGroup` to a parser is easy::" msgstr "" -#: ../../library/optparse.rst:587 +#: ../../library/optparse.rst:698 msgid "" "group = OptionGroup(parser, \"Dangerous Options\",\n" " \"Caution: use these options at your own risk. \"\n" @@ -951,12 +1225,17 @@ msgid "" "group.add_option(\"-g\", action=\"store_true\", help=\"Group option.\")\n" "parser.add_option_group(group)" msgstr "" +"group = OptionGroup(parser, \"Dangerous Options\",\n" +" \"Caution: use these options at your own risk. \"\n" +" \"It is believed that some of them bite.\")\n" +"group.add_option(\"-g\", action=\"store_true\", help=\"Group option.\")\n" +"parser.add_option_group(group)" -#: ../../library/optparse.rst:593 +#: ../../library/optparse.rst:704 msgid "This would result in the following help output:" msgstr "" -#: ../../library/optparse.rst:595 +#: ../../library/optparse.rst:706 msgid "" "Usage: [options] arg1 arg2\n" "\n" @@ -975,15 +1254,46 @@ msgid "" "\n" " -g Group option." msgstr "" +"Usage: [options] arg1 arg2\n" +"\n" +"Options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbose make lots of noise [default]\n" +" -q, --quiet be vewwy quiet (I'm hunting wabbits)\n" +" -f FILE, --filename=FILE\n" +" write output to FILE\n" +" -m MODE, --mode=MODE interaction mode: novice, intermediate, or\n" +" expert [default: intermediate]\n" +"\n" +" Dangerous Options:\n" +" Caution: use these options at your own risk. It is believed that some\n" +" of them bite.\n" +"\n" +" -g Group option." -#: ../../library/optparse.rst:614 +#: ../../library/optparse.rst:725 msgid "" "A bit more complete example might involve using more than one group: still " "extending the previous example::" msgstr "" - -#: ../../library/optparse.rst:617 -msgid "" + +#: ../../library/optparse.rst:728 +msgid "" +"group = OptionGroup(parser, \"Dangerous Options\",\n" +" \"Caution: use these options at your own risk. \"\n" +" \"It is believed that some of them bite.\")\n" +"group.add_option(\"-g\", action=\"store_true\", help=\"Group option.\")\n" +"parser.add_option_group(group)\n" +"\n" +"group = OptionGroup(parser, \"Debug Options\")\n" +"group.add_option(\"-d\", \"--debug\", action=\"store_true\",\n" +" help=\"Print debug information\")\n" +"group.add_option(\"-s\", \"--sql\", action=\"store_true\",\n" +" help=\"Print all SQL statements executed\")\n" +"group.add_option(\"-e\", action=\"store_true\", help=\"Print every action " +"done\")\n" +"parser.add_option_group(group)" +msgstr "" "group = OptionGroup(parser, \"Dangerous Options\",\n" " \"Caution: use these options at your own risk. \"\n" " \"It is believed that some of them bite.\")\n" @@ -998,13 +1308,12 @@ msgid "" "group.add_option(\"-e\", action=\"store_true\", help=\"Print every action " "done\")\n" "parser.add_option_group(group)" -msgstr "" -#: ../../library/optparse.rst:631 +#: ../../library/optparse.rst:742 msgid "that results in the following output:" msgstr "" -#: ../../library/optparse.rst:633 +#: ../../library/optparse.rst:744 msgid "" "Usage: [options] arg1 arg2\n" "\n" @@ -1028,36 +1337,58 @@ msgid "" " -s, --sql Print all SQL statements executed\n" " -e Print every action done" msgstr "" +"Usage: [options] arg1 arg2\n" +"\n" +"Options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbose make lots of noise [default]\n" +" -q, --quiet be vewwy quiet (I'm hunting wabbits)\n" +" -f FILE, --filename=FILE\n" +" write output to FILE\n" +" -m MODE, --mode=MODE interaction mode: novice, intermediate, or expert\n" +" [default: intermediate]\n" +"\n" +" Dangerous Options:\n" +" Caution: use these options at your own risk. It is believed that some\n" +" of them bite.\n" +"\n" +" -g Group option.\n" +"\n" +" Debug Options:\n" +" -d, --debug Print debug information\n" +" -s, --sql Print all SQL statements executed\n" +" -e Print every action done" -#: ../../library/optparse.rst:657 +#: ../../library/optparse.rst:768 msgid "" "Another interesting method, in particular when working programmatically with " "option groups is:" msgstr "" -#: ../../library/optparse.rst:662 +#: ../../library/optparse.rst:773 msgid "" "Return the :class:`OptionGroup` to which the short or long option string " "*opt_str* (e.g. ``'-o'`` or ``'--option'``) belongs. If there's no such :" "class:`OptionGroup`, return ``None``." msgstr "" -#: ../../library/optparse.rst:669 +#: ../../library/optparse.rst:780 msgid "Printing a version string" msgstr "" -#: ../../library/optparse.rst:671 +#: ../../library/optparse.rst:782 msgid "" "Similar to the brief usage string, :mod:`optparse` can also print a version " "string for your program. You have to supply the string as the ``version`` " "argument to OptionParser::" msgstr "" -#: ../../library/optparse.rst:675 +#: ../../library/optparse.rst:786 msgid "parser = OptionParser(usage=\"%prog [-f] [-q]\", version=\"%prog 1.0\")" msgstr "" +"parser = OptionParser(usage=\"%prog [-f] [-q]\", version=\"%prog 1.0\")" -#: ../../library/optparse.rst:677 +#: ../../library/optparse.rst:788 msgid "" "``%prog`` is expanded just like it is in ``usage``. Apart from that, " "``version`` can contain anything you like. When you supply it, :mod:" @@ -1066,23 +1397,25 @@ msgid "" "string (by replacing ``%prog``), prints it to stdout, and exits." msgstr "" -#: ../../library/optparse.rst:683 +#: ../../library/optparse.rst:794 msgid "For example, if your script is called ``/usr/bin/foo``:" msgstr "" -#: ../../library/optparse.rst:685 +#: ../../library/optparse.rst:796 msgid "" "$ /usr/bin/foo --version\n" "foo 1.0" msgstr "" +"$ /usr/bin/foo --version\n" +"foo 1.0" -#: ../../library/optparse.rst:690 +#: ../../library/optparse.rst:801 msgid "" "The following two methods can be used to print and get the ``version`` " "string:" msgstr "" -#: ../../library/optparse.rst:694 +#: ../../library/optparse.rst:805 msgid "" "Print the version message for the current program (``self.version``) to " "*file* (default stdout). As with :meth:`print_usage`, any occurrence of " @@ -1090,17 +1423,17 @@ msgid "" "program. Does nothing if ``self.version`` is empty or undefined." msgstr "" -#: ../../library/optparse.rst:701 +#: ../../library/optparse.rst:812 msgid "" "Same as :meth:`print_version` but returns the version string instead of " "printing it." msgstr "" -#: ../../library/optparse.rst:708 +#: ../../library/optparse.rst:819 msgid "How :mod:`optparse` handles errors" msgstr "" -#: ../../library/optparse.rst:710 +#: ../../library/optparse.rst:821 msgid "" "There are two broad classes of errors that :mod:`optparse` has to worry " "about: programmer errors and user errors. Programmer errors are usually " @@ -1110,7 +1443,7 @@ msgid "" "OptionError` or :exc:`TypeError`) and let the program crash." msgstr "" -#: ../../library/optparse.rst:717 +#: ../../library/optparse.rst:828 msgid "" "Handling user errors is much more important, since they are guaranteed to " "happen no matter how stable your code is. :mod:`optparse` can automatically " @@ -1121,70 +1454,82 @@ msgid "" "error condition::" msgstr "" -#: ../../library/optparse.rst:725 +#: ../../library/optparse.rst:836 msgid "" "(options, args) = parser.parse_args()\n" "...\n" "if options.a and options.b:\n" " parser.error(\"options -a and -b are mutually exclusive\")" msgstr "" +"(options, args) = parser.parse_args()\n" +"...\n" +"if options.a and options.b:\n" +" parser.error(\"options -a and -b are mutually exclusive\")" -#: ../../library/optparse.rst:730 +#: ../../library/optparse.rst:841 msgid "" "In either case, :mod:`optparse` handles the error the same way: it prints " "the program's usage message and an error message to standard error and exits " "with error status 2." msgstr "" -#: ../../library/optparse.rst:734 +#: ../../library/optparse.rst:845 msgid "" "Consider the first example above, where the user passes ``4x`` to an option " "that takes an integer:" msgstr "" -#: ../../library/optparse.rst:737 +#: ../../library/optparse.rst:848 msgid "" "$ /usr/bin/foo -n 4x\n" "Usage: foo [options]\n" "\n" "foo: error: option -n: invalid integer value: '4x'" msgstr "" +"$ /usr/bin/foo -n 4x\n" +"Usage: foo [options]\n" +"\n" +"foo: error: option -n: invalid integer value: '4x'" -#: ../../library/optparse.rst:744 +#: ../../library/optparse.rst:855 msgid "Or, where the user fails to pass a value at all:" msgstr "" -#: ../../library/optparse.rst:746 +#: ../../library/optparse.rst:857 msgid "" "$ /usr/bin/foo -n\n" "Usage: foo [options]\n" "\n" "foo: error: -n option requires an argument" msgstr "" +"$ /usr/bin/foo -n\n" +"Usage: foo [options]\n" +"\n" +"foo: error: -n option requires an argument" -#: ../../library/optparse.rst:753 +#: ../../library/optparse.rst:864 msgid "" ":mod:`optparse`\\ -generated error messages take care always to mention the " "option involved in the error; be sure to do the same when calling :func:" "`OptionParser.error` from your application code." msgstr "" -#: ../../library/optparse.rst:757 +#: ../../library/optparse.rst:868 msgid "" "If :mod:`optparse`'s default error-handling behaviour does not suit your " "needs, you'll need to subclass OptionParser and override its :meth:" "`~OptionParser.exit` and/or :meth:`~OptionParser.error` methods." msgstr "" -#: ../../library/optparse.rst:765 +#: ../../library/optparse.rst:876 msgid "Putting it all together" msgstr "" -#: ../../library/optparse.rst:767 +#: ../../library/optparse.rst:878 msgid "Here's what :mod:`optparse`\\ -based scripts usually look like::" msgstr "" -#: ../../library/optparse.rst:769 +#: ../../library/optparse.rst:880 msgid "" "from optparse import OptionParser\n" "...\n" @@ -1208,33 +1553,54 @@ msgid "" "if __name__ == \"__main__\":\n" " main()" msgstr "" +"from optparse import OptionParser\n" +"...\n" +"def main():\n" +" usage = \"usage: %prog [options] arg\"\n" +" parser = OptionParser(usage)\n" +" parser.add_option(\"-f\", \"--file\", dest=\"filename\",\n" +" help=\"read data from FILENAME\")\n" +" parser.add_option(\"-v\", \"--verbose\",\n" +" action=\"store_true\", dest=\"verbose\")\n" +" parser.add_option(\"-q\", \"--quiet\",\n" +" action=\"store_false\", dest=\"verbose\")\n" +" ...\n" +" (options, args) = parser.parse_args()\n" +" if len(args) != 1:\n" +" parser.error(\"incorrect number of arguments\")\n" +" if options.verbose:\n" +" print(\"reading %s...\" % options.filename)\n" +" ...\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" -#: ../../library/optparse.rst:795 +#: ../../library/optparse.rst:906 msgid "Reference Guide" msgstr "" -#: ../../library/optparse.rst:801 +#: ../../library/optparse.rst:912 msgid "Creating the parser" msgstr "" -#: ../../library/optparse.rst:803 +#: ../../library/optparse.rst:914 msgid "" "The first step in using :mod:`optparse` is to create an OptionParser " "instance." msgstr "" -#: ../../library/optparse.rst:807 +#: ../../library/optparse.rst:918 msgid "" "The OptionParser constructor has no required arguments, but a number of " "optional keyword arguments. You should always pass them as keyword " "arguments, i.e. do not rely on the order in which the arguments are declared." msgstr "" -#: ../../library/optparse.rst:811 +#: ../../library/optparse.rst:922 msgid "``usage`` (default: ``\"%prog [options]\"``)" msgstr "" -#: ../../library/optparse.rst:812 +#: ../../library/optparse.rst:923 msgid "" "The usage summary to print when your program is run incorrectly or with a " "help option. When :mod:`optparse` prints the usage string, it expands " @@ -1243,11 +1609,11 @@ msgid "" "value :const:`optparse.SUPPRESS_USAGE`." msgstr "" -#: ../../library/optparse.rst:818 +#: ../../library/optparse.rst:929 msgid "``option_list`` (default: ``[]``)" msgstr "" -#: ../../library/optparse.rst:819 +#: ../../library/optparse.rst:930 msgid "" "A list of Option objects to populate the parser with. The options in " "``option_list`` are added after any options in ``standard_option_list`` (a " @@ -1256,19 +1622,19 @@ msgid "" "the parser instead." msgstr "" -#: ../../library/optparse.rst:825 +#: ../../library/optparse.rst:936 msgid "``option_class`` (default: optparse.Option)" msgstr "" -#: ../../library/optparse.rst:826 +#: ../../library/optparse.rst:937 msgid "Class to use when adding options to the parser in :meth:`add_option`." msgstr "" -#: ../../library/optparse.rst:828 +#: ../../library/optparse.rst:939 msgid "``version`` (default: ``None``)" msgstr "" -#: ../../library/optparse.rst:829 +#: ../../library/optparse.rst:940 msgid "" "A version string to print when the user supplies a version option. If you " "supply a true value for ``version``, :mod:`optparse` automatically adds a " @@ -1276,21 +1642,21 @@ msgid "" "``%prog`` is expanded the same as for ``usage``." msgstr "" -#: ../../library/optparse.rst:834 +#: ../../library/optparse.rst:945 msgid "``conflict_handler`` (default: ``\"error\"``)" msgstr "" -#: ../../library/optparse.rst:835 +#: ../../library/optparse.rst:946 msgid "" "Specifies what to do when options with conflicting option strings are added " "to the parser; see section :ref:`optparse-conflicts-between-options`." msgstr "" -#: ../../library/optparse.rst:839 +#: ../../library/optparse.rst:950 msgid "``description`` (default: ``None``)" msgstr "" -#: ../../library/optparse.rst:840 +#: ../../library/optparse.rst:951 msgid "" "A paragraph of text giving a brief overview of your program. :mod:`optparse` " "reformats this paragraph to fit the current terminal width and prints it " @@ -1298,74 +1664,74 @@ msgid "" "options)." msgstr "" -#: ../../library/optparse.rst:845 +#: ../../library/optparse.rst:956 msgid "``formatter`` (default: a new :class:`IndentedHelpFormatter`)" msgstr "" -#: ../../library/optparse.rst:846 +#: ../../library/optparse.rst:957 msgid "" "An instance of optparse.HelpFormatter that will be used for printing help " "text. :mod:`optparse` provides two concrete classes for this purpose: " "IndentedHelpFormatter and TitledHelpFormatter." msgstr "" -#: ../../library/optparse.rst:850 +#: ../../library/optparse.rst:961 msgid "``add_help_option`` (default: ``True``)" msgstr "" -#: ../../library/optparse.rst:851 +#: ../../library/optparse.rst:962 msgid "" "If true, :mod:`optparse` will add a help option (with option strings ``-h`` " "and ``--help``) to the parser." msgstr "" -#: ../../library/optparse.rst:854 +#: ../../library/optparse.rst:965 msgid "``prog``" msgstr "``prog``" -#: ../../library/optparse.rst:855 +#: ../../library/optparse.rst:966 msgid "" "The string to use when expanding ``%prog`` in ``usage`` and ``version`` " "instead of ``os.path.basename(sys.argv[0])``." msgstr "" -#: ../../library/optparse.rst:858 +#: ../../library/optparse.rst:969 msgid "``epilog`` (default: ``None``)" msgstr "" -#: ../../library/optparse.rst:859 +#: ../../library/optparse.rst:970 msgid "A paragraph of help text to print after the option help." msgstr "" -#: ../../library/optparse.rst:864 +#: ../../library/optparse.rst:975 msgid "Populating the parser" msgstr "" -#: ../../library/optparse.rst:866 +#: ../../library/optparse.rst:977 msgid "" "There are several ways to populate the parser with options. The preferred " "way is by using :meth:`OptionParser.add_option`, as shown in section :ref:" "`optparse-tutorial`. :meth:`add_option` can be called in one of two ways:" msgstr "" -#: ../../library/optparse.rst:870 +#: ../../library/optparse.rst:981 msgid "pass it an Option instance (as returned by :func:`make_option`)" msgstr "" -#: ../../library/optparse.rst:872 +#: ../../library/optparse.rst:983 msgid "" "pass it any combination of positional and keyword arguments that are " "acceptable to :func:`make_option` (i.e., to the Option constructor), and it " "will create the Option instance for you" msgstr "" -#: ../../library/optparse.rst:876 +#: ../../library/optparse.rst:987 msgid "" "The other alternative is to pass a list of pre-constructed Option instances " "to the OptionParser constructor, as in::" msgstr "" -#: ../../library/optparse.rst:879 +#: ../../library/optparse.rst:990 msgid "" "option_list = [\n" " make_option(\"-f\", \"--filename\",\n" @@ -1375,8 +1741,15 @@ msgid "" " ]\n" "parser = OptionParser(option_list=option_list)" msgstr "" +"option_list = [\n" +" make_option(\"-f\", \"--filename\",\n" +" action=\"store\", type=\"string\", dest=\"filename\"),\n" +" make_option(\"-q\", \"--quiet\",\n" +" action=\"store_false\", dest=\"verbose\"),\n" +" ]\n" +"parser = OptionParser(option_list=option_list)" -#: ../../library/optparse.rst:887 +#: ../../library/optparse.rst:998 msgid "" "(:func:`make_option` is a factory function for creating Option instances; " "currently it is an alias for the Option constructor. A future version of :" @@ -1385,40 +1758,40 @@ msgid "" "Option directly.)" msgstr "" -#: ../../library/optparse.rst:896 +#: ../../library/optparse.rst:1007 msgid "Defining options" -msgstr "" +msgstr "定義選項" -#: ../../library/optparse.rst:898 +#: ../../library/optparse.rst:1009 msgid "" "Each Option instance represents a set of synonymous command-line option " "strings, e.g. ``-f`` and ``--file``. You can specify any number of short or " "long option strings, but you must specify at least one overall option string." msgstr "" -#: ../../library/optparse.rst:902 +#: ../../library/optparse.rst:1013 msgid "" "The canonical way to create an :class:`Option` instance is with the :meth:" "`add_option` method of :class:`OptionParser`." msgstr "" -#: ../../library/optparse.rst:908 +#: ../../library/optparse.rst:1019 msgid "To define an option with only a short option string::" msgstr "" -#: ../../library/optparse.rst:910 +#: ../../library/optparse.rst:1021 msgid "parser.add_option(\"-f\", attr=value, ...)" -msgstr "" +msgstr "parser.add_option(\"-f\", attr=value, ...)" -#: ../../library/optparse.rst:912 +#: ../../library/optparse.rst:1023 msgid "And to define an option with only a long option string::" msgstr "" -#: ../../library/optparse.rst:914 +#: ../../library/optparse.rst:1025 msgid "parser.add_option(\"--foo\", attr=value, ...)" -msgstr "" +msgstr "parser.add_option(\"--foo\", attr=value, ...)" -#: ../../library/optparse.rst:916 +#: ../../library/optparse.rst:1027 msgid "" "The keyword arguments define attributes of the new Option object. The most " "important option attribute is :attr:`~Option.action`, and it largely " @@ -1427,69 +1800,69 @@ msgid "" "raises an :exc:`OptionError` exception explaining your mistake." msgstr "" -#: ../../library/optparse.rst:922 +#: ../../library/optparse.rst:1033 msgid "" "An option's *action* determines what :mod:`optparse` does when it encounters " "this option on the command-line. The standard option actions hard-coded " "into :mod:`optparse` are:" msgstr "" -#: ../../library/optparse.rst:926 +#: ../../library/optparse.rst:1037 msgid "``\"store\"``" msgstr "``\"store\"``" -#: ../../library/optparse.rst:927 +#: ../../library/optparse.rst:1038 msgid "store this option's argument (default)" msgstr "" -#: ../../library/optparse.rst:932 +#: ../../library/optparse.rst:1043 msgid "``\"store_true\"``" msgstr "``\"store_true\"``" -#: ../../library/optparse.rst:933 +#: ../../library/optparse.rst:1044 msgid "store ``True``" msgstr "" -#: ../../library/optparse.rst:935 +#: ../../library/optparse.rst:1046 msgid "``\"store_false\"``" msgstr "``\"store_false\"``" -#: ../../library/optparse.rst:936 +#: ../../library/optparse.rst:1047 msgid "store ``False``" msgstr "" -#: ../../library/optparse.rst:941 +#: ../../library/optparse.rst:1052 msgid "``\"append_const\"``" msgstr "``\"append_const\"``" -#: ../../library/optparse.rst:942 +#: ../../library/optparse.rst:1053 msgid "append a constant value to a list, pre-set via :attr:`Option.const`" msgstr "" -#: ../../library/optparse.rst:950 ../../library/optparse.rst:1245 +#: ../../library/optparse.rst:1061 ../../library/optparse.rst:1356 msgid "``\"help\"``" msgstr "``\"help\"``" -#: ../../library/optparse.rst:951 +#: ../../library/optparse.rst:1062 msgid "" "print a usage message including all options and the documentation for them" msgstr "" -#: ../../library/optparse.rst:953 +#: ../../library/optparse.rst:1064 msgid "" "(If you don't supply an action, the default is ``\"store\"``. For this " "action, you may also supply :attr:`~Option.type` and :attr:`~Option.dest` " "option attributes; see :ref:`optparse-standard-option-actions`.)" msgstr "" -#: ../../library/optparse.rst:957 +#: ../../library/optparse.rst:1068 msgid "" "As you can see, most actions involve storing or updating a value somewhere. :" "mod:`optparse` always creates a special object for this, conventionally " "called ``options``, which is an instance of :class:`optparse.Values`." msgstr "" -#: ../../library/optparse.rst:963 +#: ../../library/optparse.rst:1074 msgid "" "An object holding parsed argument names and values as attributes. Normally " "created by calling when calling :meth:`OptionParser.parse_args`, and can be " @@ -1498,35 +1871,35 @@ msgid "" "arguments`)." msgstr "" -#: ../../library/optparse.rst:968 +#: ../../library/optparse.rst:1079 msgid "" "Option arguments (and various other values) are stored as attributes of this " "object, according to the :attr:`~Option.dest` (destination) option attribute." msgstr "" -#: ../../library/optparse.rst:972 +#: ../../library/optparse.rst:1083 msgid "For example, when you call ::" msgstr "例如說,當你呼叫: ::" -#: ../../library/optparse.rst:974 +#: ../../library/optparse.rst:1085 msgid "parser.parse_args()" msgstr "parser.parse_args()" -#: ../../library/optparse.rst:976 +#: ../../library/optparse.rst:1087 msgid "" "one of the first things :mod:`optparse` does is create the ``options`` " "object::" msgstr "" -#: ../../library/optparse.rst:978 +#: ../../library/optparse.rst:1089 msgid "options = Values()" msgstr "options = Values()" -#: ../../library/optparse.rst:980 +#: ../../library/optparse.rst:1091 msgid "If one of the options in this parser is defined with ::" msgstr "" -#: ../../library/optparse.rst:982 +#: ../../library/optparse.rst:1093 msgid "" "parser.add_option(\"-f\", \"--file\", action=\"store\", type=\"string\", " "dest=\"filename\")" @@ -1534,11 +1907,11 @@ msgstr "" "parser.add_option(\"-f\", \"--file\", action=\"store\", type=\"string\", " "dest=\"filename\")" -#: ../../library/optparse.rst:984 +#: ../../library/optparse.rst:1095 msgid "and the command-line being parsed includes any of the following::" msgstr "" -#: ../../library/optparse.rst:986 +#: ../../library/optparse.rst:1097 msgid "" "-ffoo\n" "-f foo\n" @@ -1550,27 +1923,27 @@ msgstr "" "--file=foo\n" "--file foo" -#: ../../library/optparse.rst:991 +#: ../../library/optparse.rst:1102 msgid "" "then :mod:`optparse`, on seeing this option, will do the equivalent of ::" msgstr "" -#: ../../library/optparse.rst:993 +#: ../../library/optparse.rst:1104 msgid "options.filename = \"foo\"" msgstr "options.filename = \"foo\"" -#: ../../library/optparse.rst:995 +#: ../../library/optparse.rst:1106 msgid "" "The :attr:`~Option.type` and :attr:`~Option.dest` option attributes are " "almost as important as :attr:`~Option.action`, but :attr:`~Option.action` is " "the only one that makes sense for *all* options." msgstr "" -#: ../../library/optparse.rst:1003 +#: ../../library/optparse.rst:1114 msgid "Option attributes" -msgstr "" +msgstr "選項屬性" -#: ../../library/optparse.rst:1007 +#: ../../library/optparse.rst:1118 msgid "" "A single command line argument, with various attributes passed by keyword to " "the constructor. Normally created with :meth:`OptionParser.add_option` " @@ -1578,7 +1951,7 @@ msgid "" "*option_class* argument to :class:`OptionParser`." msgstr "" -#: ../../library/optparse.rst:1013 +#: ../../library/optparse.rst:1124 msgid "" "The following option attributes may be passed as keyword arguments to :meth:" "`OptionParser.add_option`. If you pass an option attribute that is not " @@ -1586,33 +1959,33 @@ msgid "" "attribute, :mod:`optparse` raises :exc:`OptionError`." msgstr "" -#: ../../library/optparse.rst:1020 +#: ../../library/optparse.rst:1131 msgid "(default: ``\"store\"``)" msgstr "(預設值: ``\"store\"`` )" -#: ../../library/optparse.rst:1022 +#: ../../library/optparse.rst:1133 msgid "" "Determines :mod:`optparse`'s behaviour when this option is seen on the " "command line; the available options are documented :ref:`here `." msgstr "" -#: ../../library/optparse.rst:1028 +#: ../../library/optparse.rst:1139 msgid "(default: ``\"string\"``)" msgstr "(預設值: ``\"string\"`` )" -#: ../../library/optparse.rst:1030 +#: ../../library/optparse.rst:1141 msgid "" "The argument type expected by this option (e.g., ``\"string\"`` or " "``\"int\"``); the available option types are documented :ref:`here `." msgstr "" -#: ../../library/optparse.rst:1036 ../../library/optparse.rst:1086 +#: ../../library/optparse.rst:1147 ../../library/optparse.rst:1197 msgid "(default: derived from option strings)" msgstr "" -#: ../../library/optparse.rst:1038 +#: ../../library/optparse.rst:1149 msgid "" "If the option's action implies writing or modifying a value somewhere, this " "tells :mod:`optparse` where to write it: :attr:`~Option.dest` names an " @@ -1620,47 +1993,47 @@ msgid "" "the command line." msgstr "" -#: ../../library/optparse.rst:1045 +#: ../../library/optparse.rst:1156 msgid "" "The value to use for this option's destination if the option is not seen on " "the command line. See also :meth:`OptionParser.set_defaults`." msgstr "" -#: ../../library/optparse.rst:1050 +#: ../../library/optparse.rst:1161 msgid "(default: 1)" msgstr "(預設值:1)" -#: ../../library/optparse.rst:1052 +#: ../../library/optparse.rst:1163 msgid "" "How many arguments of type :attr:`~Option.type` should be consumed when this " "option is seen. If > 1, :mod:`optparse` will store a tuple of values to :" "attr:`~Option.dest`." msgstr "" -#: ../../library/optparse.rst:1058 +#: ../../library/optparse.rst:1169 msgid "For actions that store a constant value, the constant value to store." msgstr "" -#: ../../library/optparse.rst:1062 +#: ../../library/optparse.rst:1173 msgid "" "For options of type ``\"choice\"``, the list of strings the user may choose " "from." msgstr "" -#: ../../library/optparse.rst:1067 +#: ../../library/optparse.rst:1178 msgid "" "For options with action ``\"callback\"``, the callable to call when this " "option is seen. See section :ref:`optparse-option-callbacks` for detail on " "the arguments passed to the callable." msgstr "" -#: ../../library/optparse.rst:1074 +#: ../../library/optparse.rst:1185 msgid "" "Additional positional and keyword arguments to pass to ``callback`` after " "the four standard callback arguments." msgstr "" -#: ../../library/optparse.rst:1079 +#: ../../library/optparse.rst:1190 msgid "" "Help text to print for this option when listing all available options after " "the user supplies a :attr:`~Option.help` option (such as ``--help``). If no " @@ -1668,17 +2041,17 @@ msgid "" "this option, use the special value :const:`optparse.SUPPRESS_HELP`." msgstr "" -#: ../../library/optparse.rst:1088 +#: ../../library/optparse.rst:1199 msgid "" "Stand-in for the option argument(s) to use when printing help text. See " "section :ref:`optparse-tutorial` for an example." msgstr "" -#: ../../library/optparse.rst:1095 +#: ../../library/optparse.rst:1206 msgid "Standard option actions" msgstr "" -#: ../../library/optparse.rst:1097 +#: ../../library/optparse.rst:1208 msgid "" "The various option actions all have slightly different requirements and " "effects. Most actions have several relevant option attributes which you may " @@ -1686,13 +2059,13 @@ msgid "" "attributes, which you must specify for any option using that action." msgstr "" -#: ../../library/optparse.rst:1102 +#: ../../library/optparse.rst:1213 msgid "" "``\"store\"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:" "`~Option.nargs`, :attr:`~Option.choices`]" msgstr "" -#: ../../library/optparse.rst:1105 +#: ../../library/optparse.rst:1216 msgid "" "The option must be followed by an argument, which is converted to a value " "according to :attr:`~Option.type` and stored in :attr:`~Option.dest`. If :" @@ -1702,17 +2075,17 @@ msgid "" "option-types` section." msgstr "" -#: ../../library/optparse.rst:1112 +#: ../../library/optparse.rst:1223 msgid "" "If :attr:`~Option.choices` is supplied (a list or tuple of strings), the " "type defaults to ``\"choice\"``." msgstr "" -#: ../../library/optparse.rst:1115 +#: ../../library/optparse.rst:1226 msgid "If :attr:`~Option.type` is not supplied, it defaults to ``\"string\"``." msgstr "" -#: ../../library/optparse.rst:1117 +#: ../../library/optparse.rst:1228 msgid "" "If :attr:`~Option.dest` is not supplied, :mod:`optparse` derives a " "destination from the first long option string (e.g., ``--foo-bar`` implies " @@ -1720,13 +2093,13 @@ msgid "" "destination from the first short option string (e.g., ``-f`` implies ``f``)." msgstr "" -#: ../../library/optparse.rst:1122 ../../library/optparse.rst:1142 -#: ../../library/optparse.rst:1164 ../../library/optparse.rst:1182 -#: ../../library/optparse.rst:1221 ../../library/optparse.rst:1259 +#: ../../library/optparse.rst:1233 ../../library/optparse.rst:1253 +#: ../../library/optparse.rst:1275 ../../library/optparse.rst:1293 +#: ../../library/optparse.rst:1332 ../../library/optparse.rst:1370 msgid "Example::" msgstr "範例: ::" -#: ../../library/optparse.rst:1124 +#: ../../library/optparse.rst:1235 msgid "" "parser.add_option(\"-f\")\n" "parser.add_option(\"-p\", type=\"float\", nargs=3, dest=\"point\")" @@ -1734,19 +2107,19 @@ msgstr "" "parser.add_option(\"-f\")\n" "parser.add_option(\"-p\", type=\"float\", nargs=3, dest=\"point\")" -#: ../../library/optparse.rst:1127 +#: ../../library/optparse.rst:1238 msgid "As it parses the command line ::" msgstr "" -#: ../../library/optparse.rst:1129 +#: ../../library/optparse.rst:1240 msgid "-f foo.txt -p 1 -3.5 4 -fbar.txt" msgstr "-f foo.txt -p 1 -3.5 4 -fbar.txt" -#: ../../library/optparse.rst:1131 +#: ../../library/optparse.rst:1242 msgid ":mod:`optparse` will set ::" msgstr "" -#: ../../library/optparse.rst:1133 +#: ../../library/optparse.rst:1244 msgid "" "options.f = \"foo.txt\"\n" "options.point = (1.0, -3.5, 4.0)\n" @@ -1756,17 +2129,17 @@ msgstr "" "options.point = (1.0, -3.5, 4.0)\n" "options.f = \"bar.txt\"" -#: ../../library/optparse.rst:1137 +#: ../../library/optparse.rst:1248 msgid "" "``\"store_const\"`` [required: :attr:`~Option.const`; relevant: :attr:" "`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1140 +#: ../../library/optparse.rst:1251 msgid "The value :attr:`~Option.const` is stored in :attr:`~Option.dest`." msgstr "" -#: ../../library/optparse.rst:1144 +#: ../../library/optparse.rst:1255 msgid "" "parser.add_option(\"-q\", \"--quiet\",\n" " action=\"store_const\", const=0, dest=\"verbose\")\n" @@ -1782,33 +2155,33 @@ msgstr "" "parser.add_option(\"--noisy\",\n" " action=\"store_const\", const=2, dest=\"verbose\")" -#: ../../library/optparse.rst:1151 +#: ../../library/optparse.rst:1262 msgid "If ``--noisy`` is seen, :mod:`optparse` will set ::" msgstr "" -#: ../../library/optparse.rst:1153 +#: ../../library/optparse.rst:1264 msgid "options.verbose = 2" msgstr "options.verbose = 2" -#: ../../library/optparse.rst:1155 +#: ../../library/optparse.rst:1266 msgid "``\"store_true\"`` [relevant: :attr:`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1157 +#: ../../library/optparse.rst:1268 msgid "" "A special case of ``\"store_const\"`` that stores ``True`` to :attr:`~Option." "dest`." msgstr "" -#: ../../library/optparse.rst:1160 +#: ../../library/optparse.rst:1271 msgid "``\"store_false\"`` [relevant: :attr:`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1162 +#: ../../library/optparse.rst:1273 msgid "Like ``\"store_true\"``, but stores ``False``." msgstr "" -#: ../../library/optparse.rst:1166 +#: ../../library/optparse.rst:1277 msgid "" "parser.add_option(\"--clobber\", action=\"store_true\", dest=\"clobber\")\n" "parser.add_option(\"--no-clobber\", action=\"store_false\", dest=\"clobber\")" @@ -1816,13 +2189,13 @@ msgstr "" "parser.add_option(\"--clobber\", action=\"store_true\", dest=\"clobber\")\n" "parser.add_option(\"--no-clobber\", action=\"store_false\", dest=\"clobber\")" -#: ../../library/optparse.rst:1169 +#: ../../library/optparse.rst:1280 msgid "" "``\"append\"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:" "`~Option.nargs`, :attr:`~Option.choices`]" msgstr "" -#: ../../library/optparse.rst:1172 +#: ../../library/optparse.rst:1283 msgid "" "The option must be followed by an argument, which is appended to the list " "in :attr:`~Option.dest`. If no default value for :attr:`~Option.dest` is " @@ -1832,25 +2205,25 @@ msgid "" "is appended to :attr:`~Option.dest`." msgstr "" -#: ../../library/optparse.rst:1179 +#: ../../library/optparse.rst:1290 msgid "" "The defaults for :attr:`~Option.type` and :attr:`~Option.dest` are the same " "as for the ``\"store\"`` action." msgstr "" -#: ../../library/optparse.rst:1184 +#: ../../library/optparse.rst:1295 msgid "" "parser.add_option(\"-t\", \"--tracks\", action=\"append\", type=\"int\")" msgstr "" "parser.add_option(\"-t\", \"--tracks\", action=\"append\", type=\"int\")" -#: ../../library/optparse.rst:1186 +#: ../../library/optparse.rst:1297 msgid "" "If ``-t3`` is seen on the command-line, :mod:`optparse` does the equivalent " "of::" msgstr "" -#: ../../library/optparse.rst:1189 +#: ../../library/optparse.rst:1300 msgid "" "options.tracks = []\n" "options.tracks.append(int(\"3\"))" @@ -1858,15 +2231,15 @@ msgstr "" "options.tracks = []\n" "options.tracks.append(int(\"3\"))" -#: ../../library/optparse.rst:1192 +#: ../../library/optparse.rst:1303 msgid "If, a little later on, ``--tracks=4`` is seen, it does::" msgstr "" -#: ../../library/optparse.rst:1194 +#: ../../library/optparse.rst:1305 msgid "options.tracks.append(int(\"4\"))" msgstr "options.tracks.append(int(\"4\"))" -#: ../../library/optparse.rst:1196 +#: ../../library/optparse.rst:1307 msgid "" "The ``append`` action calls the ``append`` method on the current value of " "the option. This means that any default value specified must have an " @@ -1875,7 +2248,7 @@ msgid "" "with any values from the command line appended after those default values::" msgstr "" -#: ../../library/optparse.rst:1202 +#: ../../library/optparse.rst:1313 msgid "" ">>> parser.add_option(\"--files\", action=\"append\", default=['~/.mypkg/" "defaults'])\n" @@ -1889,13 +2262,13 @@ msgstr "" ">>> opts.files\n" "['~/.mypkg/defaults', 'overrides.mypkg']" -#: ../../library/optparse.rst:1207 +#: ../../library/optparse.rst:1318 msgid "" "``\"append_const\"`` [required: :attr:`~Option.const`; relevant: :attr:" "`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1210 +#: ../../library/optparse.rst:1321 msgid "" "Like ``\"store_const\"``, but the value :attr:`~Option.const` is appended " "to :attr:`~Option.dest`; as with ``\"append\"``, :attr:`~Option.dest` " @@ -1903,28 +2276,28 @@ msgid "" "time the option is encountered." msgstr "" -#: ../../library/optparse.rst:1215 +#: ../../library/optparse.rst:1326 msgid "``\"count\"`` [relevant: :attr:`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1217 +#: ../../library/optparse.rst:1328 msgid "" "Increment the integer stored at :attr:`~Option.dest`. If no default value " "is supplied, :attr:`~Option.dest` is set to zero before being incremented " "the first time." msgstr "" -#: ../../library/optparse.rst:1223 +#: ../../library/optparse.rst:1334 msgid "parser.add_option(\"-v\", action=\"count\", dest=\"verbosity\")" msgstr "parser.add_option(\"-v\", action=\"count\", dest=\"verbosity\")" -#: ../../library/optparse.rst:1225 +#: ../../library/optparse.rst:1336 msgid "" "The first time ``-v`` is seen on the command line, :mod:`optparse` does the " "equivalent of::" msgstr "" -#: ../../library/optparse.rst:1228 +#: ../../library/optparse.rst:1339 msgid "" "options.verbosity = 0\n" "options.verbosity += 1" @@ -1932,36 +2305,36 @@ msgstr "" "options.verbosity = 0\n" "options.verbosity += 1" -#: ../../library/optparse.rst:1231 +#: ../../library/optparse.rst:1342 msgid "Every subsequent occurrence of ``-v`` results in ::" msgstr "" -#: ../../library/optparse.rst:1233 +#: ../../library/optparse.rst:1344 msgid "options.verbosity += 1" msgstr "options.verbosity += 1" -#: ../../library/optparse.rst:1235 +#: ../../library/optparse.rst:1346 msgid "" "``\"callback\"`` [required: :attr:`~Option.callback`; relevant: :attr:" "`~Option.type`, :attr:`~Option.nargs`, :attr:`~Option.callback_args`, :attr:" "`~Option.callback_kwargs`]" msgstr "" -#: ../../library/optparse.rst:1239 +#: ../../library/optparse.rst:1350 msgid "" "Call the function specified by :attr:`~Option.callback`, which is called " "as ::" msgstr "" -#: ../../library/optparse.rst:1241 ../../library/optparse.rst:1639 +#: ../../library/optparse.rst:1352 ../../library/optparse.rst:1750 msgid "func(option, opt_str, value, parser, *args, **kwargs)" msgstr "func(option, opt_str, value, parser, *args, **kwargs)" -#: ../../library/optparse.rst:1243 +#: ../../library/optparse.rst:1354 msgid "See section :ref:`optparse-option-callbacks` for more detail." msgstr "更多細節請見 :ref:`optparse-option-callbacks`。" -#: ../../library/optparse.rst:1247 +#: ../../library/optparse.rst:1358 msgid "" "Prints a complete help message for all the options in the current option " "parser. The help message is constructed from the ``usage`` string passed to " @@ -1969,20 +2342,20 @@ msgid "" "every option." msgstr "" -#: ../../library/optparse.rst:1252 +#: ../../library/optparse.rst:1363 msgid "" "If no :attr:`~Option.help` string is supplied for an option, it will still " "be listed in the help message. To omit an option entirely, use the special " "value :const:`optparse.SUPPRESS_HELP`." msgstr "" -#: ../../library/optparse.rst:1256 +#: ../../library/optparse.rst:1367 msgid "" ":mod:`optparse` automatically adds a :attr:`~Option.help` option to all " "OptionParsers, so you do not normally need to create one." msgstr "" -#: ../../library/optparse.rst:1261 +#: ../../library/optparse.rst:1372 msgid "" "from optparse import OptionParser, SUPPRESS_HELP\n" "\n" @@ -1998,14 +2371,14 @@ msgid "" "parser.add_option(\"--secret\", help=SUPPRESS_HELP)" msgstr "" -#: ../../library/optparse.rst:1274 +#: ../../library/optparse.rst:1385 msgid "" "If :mod:`optparse` sees either ``-h`` or ``--help`` on the command line, it " "will print something like the following help message to stdout (assuming " "``sys.argv[0]`` is ``\"foo.py\"``):" msgstr "" -#: ../../library/optparse.rst:1278 +#: ../../library/optparse.rst:1389 msgid "" "Usage: foo.py [options]\n" "\n" @@ -2021,17 +2394,17 @@ msgstr "" " -v Be moderately verbose\n" " --file=FILENAME Input file to read data from" -#: ../../library/optparse.rst:1287 +#: ../../library/optparse.rst:1398 msgid "" "After printing the help message, :mod:`optparse` terminates your process " "with ``sys.exit(0)``." msgstr "" -#: ../../library/optparse.rst:1290 +#: ../../library/optparse.rst:1401 msgid "``\"version\"``" msgstr "``\"version\"``" -#: ../../library/optparse.rst:1292 +#: ../../library/optparse.rst:1403 msgid "" "Prints the version number supplied to the OptionParser to stdout and exits. " "The version number is actually formatted and printed by the " @@ -2041,58 +2414,58 @@ msgid "" "since :mod:`optparse` automatically adds them when needed." msgstr "" -#: ../../library/optparse.rst:1303 +#: ../../library/optparse.rst:1414 msgid "Standard option types" msgstr "" -#: ../../library/optparse.rst:1305 +#: ../../library/optparse.rst:1416 msgid "" ":mod:`optparse` has five built-in option types: ``\"string\"``, ``\"int\"``, " "``\"choice\"``, ``\"float\"`` and ``\"complex\"``. If you need to add new " "option types, see section :ref:`optparse-extending-optparse`." msgstr "" -#: ../../library/optparse.rst:1309 +#: ../../library/optparse.rst:1420 msgid "" "Arguments to string options are not checked or converted in any way: the " "text on the command line is stored in the destination (or passed to the " "callback) as-is." msgstr "" -#: ../../library/optparse.rst:1312 +#: ../../library/optparse.rst:1423 msgid "Integer arguments (type ``\"int\"``) are parsed as follows:" msgstr "" -#: ../../library/optparse.rst:1314 +#: ../../library/optparse.rst:1425 msgid "if the number starts with ``0x``, it is parsed as a hexadecimal number" msgstr "" -#: ../../library/optparse.rst:1316 +#: ../../library/optparse.rst:1427 msgid "if the number starts with ``0``, it is parsed as an octal number" msgstr "" -#: ../../library/optparse.rst:1318 +#: ../../library/optparse.rst:1429 msgid "if the number starts with ``0b``, it is parsed as a binary number" msgstr "" -#: ../../library/optparse.rst:1320 +#: ../../library/optparse.rst:1431 msgid "otherwise, the number is parsed as a decimal number" msgstr "" -#: ../../library/optparse.rst:1323 +#: ../../library/optparse.rst:1434 msgid "" "The conversion is done by calling :func:`int` with the appropriate base (2, " "8, 10, or 16). If this fails, so will :mod:`optparse`, although with a more " "useful error message." msgstr "" -#: ../../library/optparse.rst:1327 +#: ../../library/optparse.rst:1438 msgid "" "``\"float\"`` and ``\"complex\"`` option arguments are converted directly " "with :func:`float` and :func:`complex`, with similar error-handling." msgstr "" -#: ../../library/optparse.rst:1330 +#: ../../library/optparse.rst:1441 msgid "" "``\"choice\"`` options are a subtype of ``\"string\"`` options. The :attr:" "`~Option.choices` option attribute (a sequence of strings) defines the set " @@ -2101,63 +2474,63 @@ msgid "" "`OptionValueError` if an invalid string is given." msgstr "" -#: ../../library/optparse.rst:1340 +#: ../../library/optparse.rst:1451 msgid "Parsing arguments" msgstr "剖析引數" -#: ../../library/optparse.rst:1342 +#: ../../library/optparse.rst:1453 msgid "" "The whole point of creating and populating an OptionParser is to call its :" "meth:`~OptionParser.parse_args` method." msgstr "" -#: ../../library/optparse.rst:1347 +#: ../../library/optparse.rst:1458 msgid "Parse the command-line options found in *args*." msgstr "" -#: ../../library/optparse.rst:1349 +#: ../../library/optparse.rst:1460 msgid "The input parameters are" msgstr "" -#: ../../library/optparse.rst:1351 ../../library/optparse.rst:1365 -#: ../../library/optparse.rst:1683 +#: ../../library/optparse.rst:1462 ../../library/optparse.rst:1476 +#: ../../library/optparse.rst:1794 msgid "``args``" msgstr "``args``" -#: ../../library/optparse.rst:1352 +#: ../../library/optparse.rst:1463 msgid "the list of arguments to process (default: ``sys.argv[1:]``)" msgstr "" -#: ../../library/optparse.rst:1354 +#: ../../library/optparse.rst:1465 msgid "``values``" msgstr "``values``" -#: ../../library/optparse.rst:1355 +#: ../../library/optparse.rst:1466 msgid "" "a :class:`Values` object to store option arguments in (default: a new " "instance of :class:`Values`) -- if you give an existing object, the option " "defaults will not be initialized on it" msgstr "" -#: ../../library/optparse.rst:1359 +#: ../../library/optparse.rst:1470 msgid "and the return value is a pair ``(options, args)`` where" msgstr "" -#: ../../library/optparse.rst:1361 +#: ../../library/optparse.rst:1472 msgid "``options``" msgstr "``options``" -#: ../../library/optparse.rst:1362 +#: ../../library/optparse.rst:1473 msgid "" "the same object that was passed in as *values*, or the ``optparse.Values`` " "instance created by :mod:`optparse`" msgstr "" -#: ../../library/optparse.rst:1366 +#: ../../library/optparse.rst:1477 msgid "the leftover positional arguments after all options have been processed" msgstr "" -#: ../../library/optparse.rst:1368 +#: ../../library/optparse.rst:1479 msgid "" "The most common usage is to supply neither keyword argument. If you supply " "``values``, it will be modified with repeated :func:`setattr` calls (roughly " @@ -2165,7 +2538,7 @@ msgid "" "by :meth:`~OptionParser.parse_args`." msgstr "" -#: ../../library/optparse.rst:1373 +#: ../../library/optparse.rst:1484 msgid "" "If :meth:`~OptionParser.parse_args` encounters any errors in the argument " "list, it calls the OptionParser's :meth:`error` method with an appropriate " @@ -2173,69 +2546,69 @@ msgid "" "status of 2 (the traditional Unix exit status for command-line errors)." msgstr "" -#: ../../library/optparse.rst:1382 +#: ../../library/optparse.rst:1493 msgid "Querying and manipulating your option parser" msgstr "" -#: ../../library/optparse.rst:1384 +#: ../../library/optparse.rst:1495 msgid "" "The default behavior of the option parser can be customized slightly, and " "you can also poke around your option parser and see what's there. " "OptionParser provides several methods to help you out:" msgstr "" -#: ../../library/optparse.rst:1390 +#: ../../library/optparse.rst:1501 msgid "" "Set parsing to stop on the first non-option. For example, if ``-a`` and ``-" "b`` are both simple options that take no arguments, :mod:`optparse` normally " "accepts this syntax::" msgstr "" -#: ../../library/optparse.rst:1394 +#: ../../library/optparse.rst:1505 msgid "prog -a arg1 -b arg2" msgstr "prog -a arg1 -b arg2" -#: ../../library/optparse.rst:1396 +#: ../../library/optparse.rst:1507 msgid "and treats it as equivalent to ::" msgstr "" -#: ../../library/optparse.rst:1398 +#: ../../library/optparse.rst:1509 msgid "prog -a -b arg1 arg2" msgstr "prog -a -b arg1 arg2" -#: ../../library/optparse.rst:1400 +#: ../../library/optparse.rst:1511 msgid "" "To disable this feature, call :meth:`disable_interspersed_args`. This " "restores traditional Unix syntax, where option parsing stops with the first " "non-option argument." msgstr "" -#: ../../library/optparse.rst:1404 +#: ../../library/optparse.rst:1515 msgid "" "Use this if you have a command processor which runs another command which " "has options of its own and you want to make sure these options don't get " "confused. For example, each command might have a different set of options." msgstr "" -#: ../../library/optparse.rst:1410 +#: ../../library/optparse.rst:1521 msgid "" "Set parsing to not stop on the first non-option, allowing interspersing " "switches with command arguments. This is the default behavior." msgstr "" -#: ../../library/optparse.rst:1415 +#: ../../library/optparse.rst:1526 msgid "" "Returns the Option instance with the option string *opt_str*, or ``None`` if " "no options have that option string." msgstr "" -#: ../../library/optparse.rst:1420 +#: ../../library/optparse.rst:1531 msgid "" "Return ``True`` if the OptionParser has an option with option string " "*opt_str* (e.g., ``-q`` or ``--verbose``)." msgstr "" -#: ../../library/optparse.rst:1425 +#: ../../library/optparse.rst:1536 msgid "" "If the :class:`OptionParser` has an option corresponding to *opt_str*, that " "option is removed. If that option provided any other option strings, all of " @@ -2243,17 +2616,17 @@ msgid "" "option belonging to this :class:`OptionParser`, raises :exc:`ValueError`." msgstr "" -#: ../../library/optparse.rst:1434 +#: ../../library/optparse.rst:1545 msgid "Conflicts between options" msgstr "" -#: ../../library/optparse.rst:1436 +#: ../../library/optparse.rst:1547 msgid "" "If you're not careful, it's easy to define options with conflicting option " "strings::" msgstr "" -#: ../../library/optparse.rst:1439 +#: ../../library/optparse.rst:1550 msgid "" "parser.add_option(\"-n\", \"--dry-run\", ...)\n" "...\n" @@ -2263,13 +2636,13 @@ msgstr "" "...\n" "parser.add_option(\"-n\", \"--noisy\", ...)" -#: ../../library/optparse.rst:1443 +#: ../../library/optparse.rst:1554 msgid "" "(This is particularly true if you've defined your own OptionParser subclass " "with some standard options.)" msgstr "" -#: ../../library/optparse.rst:1446 +#: ../../library/optparse.rst:1557 msgid "" "Every time you add an option, :mod:`optparse` checks for conflicts with " "existing options. If it finds any, it invokes the current conflict-handling " @@ -2277,47 +2650,47 @@ msgid "" "constructor::" msgstr "" -#: ../../library/optparse.rst:1450 +#: ../../library/optparse.rst:1561 msgid "parser = OptionParser(..., conflict_handler=handler)" msgstr "parser = OptionParser(..., conflict_handler=handler)" -#: ../../library/optparse.rst:1452 +#: ../../library/optparse.rst:1563 msgid "or with a separate call::" msgstr "" -#: ../../library/optparse.rst:1454 +#: ../../library/optparse.rst:1565 msgid "parser.set_conflict_handler(handler)" msgstr "parser.set_conflict_handler(handler)" -#: ../../library/optparse.rst:1456 +#: ../../library/optparse.rst:1567 msgid "The available conflict handlers are:" msgstr "" -#: ../../library/optparse.rst:1458 +#: ../../library/optparse.rst:1569 msgid "``\"error\"`` (default)" msgstr "" -#: ../../library/optparse.rst:1459 +#: ../../library/optparse.rst:1570 msgid "" "assume option conflicts are a programming error and raise :exc:" "`OptionConflictError`" msgstr "" -#: ../../library/optparse.rst:1462 +#: ../../library/optparse.rst:1573 msgid "``\"resolve\"``" msgstr "``\"resolve\"``" -#: ../../library/optparse.rst:1463 +#: ../../library/optparse.rst:1574 msgid "resolve option conflicts intelligently (see below)" msgstr "" -#: ../../library/optparse.rst:1466 +#: ../../library/optparse.rst:1577 msgid "" "As an example, let's define an :class:`OptionParser` that resolves conflicts " "intelligently and add conflicting options to it::" msgstr "" -#: ../../library/optparse.rst:1469 +#: ../../library/optparse.rst:1580 msgid "" "parser = OptionParser(conflict_handler=\"resolve\")\n" "parser.add_option(\"-n\", \"--dry-run\", ..., help=\"do no harm\")\n" @@ -2327,7 +2700,7 @@ msgstr "" "parser.add_option(\"-n\", \"--dry-run\", ..., help=\"do no harm\")\n" "parser.add_option(\"-n\", \"--noisy\", ..., help=\"be noisy\")" -#: ../../library/optparse.rst:1473 +#: ../../library/optparse.rst:1584 msgid "" "At this point, :mod:`optparse` detects that a previously added option is " "already using the ``-n`` option string. Since ``conflict_handler`` is " @@ -2337,7 +2710,7 @@ msgid "" "message will reflect that::" msgstr "" -#: ../../library/optparse.rst:1479 +#: ../../library/optparse.rst:1590 msgid "" "Options:\n" " --dry-run do no harm\n" @@ -2345,7 +2718,7 @@ msgid "" " -n, --noisy be noisy" msgstr "" -#: ../../library/optparse.rst:1484 +#: ../../library/optparse.rst:1595 msgid "" "It's possible to whittle away the option strings for a previously added " "option until there are none left, and the user has no way of invoking that " @@ -2354,17 +2727,17 @@ msgid "" "Carrying on with our existing OptionParser::" msgstr "" -#: ../../library/optparse.rst:1490 +#: ../../library/optparse.rst:1601 msgid "parser.add_option(\"--dry-run\", ..., help=\"new dry-run option\")" msgstr "parser.add_option(\"--dry-run\", ..., help=\"new dry-run option\")" -#: ../../library/optparse.rst:1492 +#: ../../library/optparse.rst:1603 msgid "" "At this point, the original ``-n``/``--dry-run`` option is no longer " "accessible, so :mod:`optparse` removes it, leaving this help text::" msgstr "" -#: ../../library/optparse.rst:1495 +#: ../../library/optparse.rst:1606 msgid "" "Options:\n" " ...\n" @@ -2376,11 +2749,11 @@ msgstr "" " -n, --noisy be noisy\n" " --dry-run new dry-run option" -#: ../../library/optparse.rst:1504 +#: ../../library/optparse.rst:1615 msgid "Cleanup" msgstr "" -#: ../../library/optparse.rst:1506 +#: ../../library/optparse.rst:1617 msgid "" "OptionParser instances have several cyclic references. This should not be a " "problem for Python's garbage collector, but you may wish to break the cyclic " @@ -2390,15 +2763,15 @@ msgid "" "OptionParser." msgstr "" -#: ../../library/optparse.rst:1517 +#: ../../library/optparse.rst:1628 msgid "Other methods" msgstr "其他方法" -#: ../../library/optparse.rst:1519 +#: ../../library/optparse.rst:1630 msgid "OptionParser supports several other public methods:" msgstr "" -#: ../../library/optparse.rst:1523 +#: ../../library/optparse.rst:1634 msgid "" "Set the usage string according to the rules described above for the " "``usage`` constructor keyword argument. Passing ``None`` sets the default " @@ -2406,7 +2779,7 @@ msgid "" "message." msgstr "" -#: ../../library/optparse.rst:1529 +#: ../../library/optparse.rst:1640 msgid "" "Print the usage message for the current program (``self.usage``) to *file* " "(default stdout). Any occurrence of the string ``%prog`` in ``self.usage`` " @@ -2414,13 +2787,13 @@ msgid "" "usage`` is empty or not defined." msgstr "" -#: ../../library/optparse.rst:1536 +#: ../../library/optparse.rst:1647 msgid "" "Same as :meth:`print_usage` but returns the usage string instead of printing " "it." msgstr "" -#: ../../library/optparse.rst:1541 +#: ../../library/optparse.rst:1652 msgid "" "Set default values for several option destinations at once. Using :meth:" "`set_defaults` is the preferred way to set default values for options, since " @@ -2429,7 +2802,7 @@ msgid "" "default, and the last one wins::" msgstr "" -#: ../../library/optparse.rst:1547 +#: ../../library/optparse.rst:1658 msgid "" "parser.add_option(\"--advanced\", action=\"store_const\",\n" " dest=\"mode\", const=\"advanced\",\n" @@ -2439,11 +2812,11 @@ msgid "" " default=\"advanced\") # overrides above setting" msgstr "" -#: ../../library/optparse.rst:1554 +#: ../../library/optparse.rst:1665 msgid "To avoid this confusion, use :meth:`set_defaults`::" msgstr "" -#: ../../library/optparse.rst:1556 +#: ../../library/optparse.rst:1667 msgid "" "parser.set_defaults(mode=\"advanced\")\n" "parser.add_option(\"--advanced\", action=\"store_const\",\n" @@ -2457,11 +2830,11 @@ msgstr "" "parser.add_option(\"--novice\", action=\"store_const\",\n" " dest=\"mode\", const=\"novice\")" -#: ../../library/optparse.rst:1566 +#: ../../library/optparse.rst:1677 msgid "Option Callbacks" msgstr "" -#: ../../library/optparse.rst:1568 +#: ../../library/optparse.rst:1679 msgid "" "When :mod:`optparse`'s built-in actions and types aren't quite enough for " "your needs, you have two choices: extend :mod:`optparse` or define a " @@ -2469,25 +2842,25 @@ msgid "" "a lot of simple cases. Quite often a simple callback is all you need." msgstr "" -#: ../../library/optparse.rst:1573 +#: ../../library/optparse.rst:1684 msgid "There are two steps to defining a callback option:" msgstr "" -#: ../../library/optparse.rst:1575 +#: ../../library/optparse.rst:1686 msgid "define the option itself using the ``\"callback\"`` action" msgstr "" -#: ../../library/optparse.rst:1577 +#: ../../library/optparse.rst:1688 msgid "" "write the callback; this is a function (or method) that takes at least four " "arguments, as described below" msgstr "" -#: ../../library/optparse.rst:1584 +#: ../../library/optparse.rst:1695 msgid "Defining a callback option" msgstr "" -#: ../../library/optparse.rst:1586 +#: ../../library/optparse.rst:1697 msgid "" "As always, the easiest way to define a callback option is by using the :meth:" "`OptionParser.add_option` method. Apart from :attr:`~Option.action`, the " @@ -2495,11 +2868,11 @@ msgid "" "call::" msgstr "" -#: ../../library/optparse.rst:1590 +#: ../../library/optparse.rst:1701 msgid "parser.add_option(\"-c\", action=\"callback\", callback=my_callback)" msgstr "parser.add_option(\"-c\", action=\"callback\", callback=my_callback)" -#: ../../library/optparse.rst:1592 +#: ../../library/optparse.rst:1703 msgid "" "``callback`` is a function (or other callable object), so you must have " "already defined ``my_callback()`` when you create this callback option. In " @@ -2511,7 +2884,7 @@ msgid "" "tricky; it's covered later in this section." msgstr "" -#: ../../library/optparse.rst:1601 +#: ../../library/optparse.rst:1712 msgid "" ":mod:`optparse` always passes four particular arguments to your callback, " "and it will only pass additional arguments if you specify them via :attr:" @@ -2519,25 +2892,25 @@ msgid "" "minimal callback function signature is::" msgstr "" -#: ../../library/optparse.rst:1606 +#: ../../library/optparse.rst:1717 msgid "def my_callback(option, opt, value, parser):" msgstr "def my_callback(option, opt, value, parser):" -#: ../../library/optparse.rst:1608 +#: ../../library/optparse.rst:1719 msgid "The four arguments to a callback are described below." msgstr "" -#: ../../library/optparse.rst:1610 +#: ../../library/optparse.rst:1721 msgid "" "There are several other option attributes that you can supply when you " "define a callback option:" msgstr "" -#: ../../library/optparse.rst:1613 +#: ../../library/optparse.rst:1724 msgid ":attr:`~Option.type`" msgstr ":attr:`~Option.type`" -#: ../../library/optparse.rst:1614 +#: ../../library/optparse.rst:1725 msgid "" "has its usual meaning: as with the ``\"store\"`` or ``\"append\"`` actions, " "it instructs :mod:`optparse` to consume one argument and convert it to :attr:" @@ -2545,11 +2918,11 @@ msgid "" "though, :mod:`optparse` passes it to your callback function." msgstr "" -#: ../../library/optparse.rst:1619 +#: ../../library/optparse.rst:1730 msgid ":attr:`~Option.nargs`" msgstr ":attr:`~Option.nargs`" -#: ../../library/optparse.rst:1620 +#: ../../library/optparse.rst:1731 msgid "" "also has its usual meaning: if it is supplied and > 1, :mod:`optparse` will " "consume :attr:`~Option.nargs` arguments, each of which must be convertible " @@ -2557,43 +2930,43 @@ msgid "" "callback." msgstr "" -#: ../../library/optparse.rst:1625 +#: ../../library/optparse.rst:1736 msgid ":attr:`~Option.callback_args`" msgstr ":attr:`~Option.callback_args`" -#: ../../library/optparse.rst:1626 +#: ../../library/optparse.rst:1737 msgid "a tuple of extra positional arguments to pass to the callback" msgstr "" -#: ../../library/optparse.rst:1628 +#: ../../library/optparse.rst:1739 msgid ":attr:`~Option.callback_kwargs`" msgstr ":attr:`~Option.callback_kwargs`" -#: ../../library/optparse.rst:1629 +#: ../../library/optparse.rst:1740 msgid "a dictionary of extra keyword arguments to pass to the callback" msgstr "" -#: ../../library/optparse.rst:1635 +#: ../../library/optparse.rst:1746 msgid "How callbacks are called" msgstr "" -#: ../../library/optparse.rst:1637 +#: ../../library/optparse.rst:1748 msgid "All callbacks are called as follows::" msgstr "" -#: ../../library/optparse.rst:1643 +#: ../../library/optparse.rst:1754 msgid "``option``" msgstr "``option``" -#: ../../library/optparse.rst:1644 +#: ../../library/optparse.rst:1755 msgid "is the Option instance that's calling the callback" msgstr "" -#: ../../library/optparse.rst:1646 +#: ../../library/optparse.rst:1757 msgid "``opt_str``" msgstr "``opt_str``" -#: ../../library/optparse.rst:1647 +#: ../../library/optparse.rst:1758 msgid "" "is the option string seen on the command-line that's triggering the " "callback. (If an abbreviated long option was used, ``opt_str`` will be the " @@ -2602,11 +2975,11 @@ msgid "" "``\"--foobar\"``.)" msgstr "" -#: ../../library/optparse.rst:1653 +#: ../../library/optparse.rst:1764 msgid "``value``" msgstr "``value``" -#: ../../library/optparse.rst:1654 +#: ../../library/optparse.rst:1765 msgid "" "is the argument to this option seen on the command-line. :mod:`optparse` " "will only expect an argument if :attr:`~Option.type` is set; the type of " @@ -2616,21 +2989,21 @@ msgid "" "of values of the appropriate type." msgstr "" -#: ../../library/optparse.rst:1660 +#: ../../library/optparse.rst:1771 msgid "``parser``" msgstr "``parser``" -#: ../../library/optparse.rst:1661 +#: ../../library/optparse.rst:1772 msgid "" "is the OptionParser instance driving the whole thing, mainly useful because " "you can access some other interesting data through its instance attributes:" msgstr "" -#: ../../library/optparse.rst:1664 +#: ../../library/optparse.rst:1775 msgid "``parser.largs``" msgstr "``parser.largs``" -#: ../../library/optparse.rst:1665 +#: ../../library/optparse.rst:1776 msgid "" "the current list of leftover arguments, ie. arguments that have been " "consumed but are neither options nor option arguments. Feel free to modify " @@ -2639,22 +3012,22 @@ msgid "" "parse_args`.)" msgstr "" -#: ../../library/optparse.rst:1670 +#: ../../library/optparse.rst:1781 msgid "``parser.rargs``" msgstr "``parser.rargs``" -#: ../../library/optparse.rst:1671 +#: ../../library/optparse.rst:1782 msgid "" "the current list of remaining arguments, ie. with ``opt_str`` and ``value`` " "(if applicable) removed, and only the arguments following them still there. " "Feel free to modify ``parser.rargs``, e.g. by consuming more arguments." msgstr "" -#: ../../library/optparse.rst:1676 +#: ../../library/optparse.rst:1787 msgid "``parser.values``" msgstr "``parser.values``" -#: ../../library/optparse.rst:1677 +#: ../../library/optparse.rst:1788 msgid "" "the object where option values are by default stored (an instance of " "optparse.OptionValues). This lets callbacks use the same mechanism as the " @@ -2663,27 +3036,27 @@ msgid "" "of any options already encountered on the command-line." msgstr "" -#: ../../library/optparse.rst:1684 +#: ../../library/optparse.rst:1795 msgid "" "is a tuple of arbitrary positional arguments supplied via the :attr:`~Option." "callback_args` option attribute." msgstr "" -#: ../../library/optparse.rst:1687 +#: ../../library/optparse.rst:1798 msgid "``kwargs``" msgstr "``kwargs``" -#: ../../library/optparse.rst:1688 +#: ../../library/optparse.rst:1799 msgid "" "is a dictionary of arbitrary keyword arguments supplied via :attr:`~Option." "callback_kwargs`." msgstr "" -#: ../../library/optparse.rst:1695 +#: ../../library/optparse.rst:1806 msgid "Raising errors in a callback" msgstr "" -#: ../../library/optparse.rst:1697 +#: ../../library/optparse.rst:1808 msgid "" "The callback function should raise :exc:`OptionValueError` if there are any " "problems with the option or its argument(s). :mod:`optparse` catches this " @@ -2693,17 +3066,17 @@ msgid "" "they did wrong." msgstr "" -#: ../../library/optparse.rst:1707 +#: ../../library/optparse.rst:1818 msgid "Callback example 1: trivial callback" msgstr "" -#: ../../library/optparse.rst:1709 +#: ../../library/optparse.rst:1820 msgid "" "Here's an example of a callback option that takes no arguments, and simply " "records that the option was seen::" msgstr "" -#: ../../library/optparse.rst:1712 +#: ../../library/optparse.rst:1823 msgid "" "def record_foo_seen(option, opt_str, value, parser):\n" " parser.values.saw_foo = True\n" @@ -2715,21 +3088,21 @@ msgstr "" "\n" "parser.add_option(\"--foo\", action=\"callback\", callback=record_foo_seen)" -#: ../../library/optparse.rst:1717 +#: ../../library/optparse.rst:1828 msgid "Of course, you could do that with the ``\"store_true\"`` action." msgstr "" -#: ../../library/optparse.rst:1723 +#: ../../library/optparse.rst:1834 msgid "Callback example 2: check option order" msgstr "" -#: ../../library/optparse.rst:1725 +#: ../../library/optparse.rst:1836 msgid "" "Here's a slightly more interesting example: record the fact that ``-a`` is " "seen, but blow up if it comes after ``-b`` in the command-line. ::" msgstr "" -#: ../../library/optparse.rst:1728 +#: ../../library/optparse.rst:1839 msgid "" "def check_order(option, opt_str, value, parser):\n" " if parser.values.b:\n" @@ -2747,18 +3120,18 @@ msgstr "" "parser.add_option(\"-a\", action=\"callback\", callback=check_order)\n" "parser.add_option(\"-b\", action=\"store_true\", dest=\"b\")" -#: ../../library/optparse.rst:1740 +#: ../../library/optparse.rst:1851 msgid "Callback example 3: check option order (generalized)" msgstr "" -#: ../../library/optparse.rst:1742 +#: ../../library/optparse.rst:1853 msgid "" "If you want to reuse this callback for several similar options (set a flag, " "but blow up if ``-b`` has already been seen), it needs a bit of work: the " "error message and the flag that it sets must be generalized. ::" msgstr "" -#: ../../library/optparse.rst:1746 +#: ../../library/optparse.rst:1857 msgid "" "def check_order(option, opt_str, value, parser):\n" " if parser.values.b:\n" @@ -2782,11 +3155,11 @@ msgstr "" "parser.add_option(\"-c\", action=\"callback\", callback=check_order, " "dest='c')" -#: ../../library/optparse.rst:1759 +#: ../../library/optparse.rst:1870 msgid "Callback example 4: check arbitrary condition" msgstr "" -#: ../../library/optparse.rst:1761 +#: ../../library/optparse.rst:1872 msgid "" "Of course, you could put any condition in there---you're not limited to " "checking the values of already-defined options. For example, if you have " @@ -2794,7 +3167,7 @@ msgid "" "is this::" msgstr "" -#: ../../library/optparse.rst:1765 +#: ../../library/optparse.rst:1876 msgid "" "def check_moon(option, opt_str, value, parser):\n" " if is_moon_full():\n" @@ -2814,16 +3187,16 @@ msgstr "" "parser.add_option(\"--foo\",\n" " action=\"callback\", callback=check_moon, dest=\"foo\")" -#: ../../library/optparse.rst:1774 +#: ../../library/optparse.rst:1885 msgid "" "(The definition of ``is_moon_full()`` is left as an exercise for the reader.)" msgstr "" -#: ../../library/optparse.rst:1780 +#: ../../library/optparse.rst:1891 msgid "Callback example 5: fixed arguments" msgstr "" -#: ../../library/optparse.rst:1782 +#: ../../library/optparse.rst:1893 msgid "" "Things get slightly more interesting when you define callback options that " "take a fixed number of arguments. Specifying that a callback option takes " @@ -2833,12 +3206,12 @@ msgid "" "nargs`, then the option takes :attr:`~Option.nargs` arguments." msgstr "" -#: ../../library/optparse.rst:1789 +#: ../../library/optparse.rst:1900 msgid "" "Here's an example that just emulates the standard ``\"store\"`` action::" msgstr "" -#: ../../library/optparse.rst:1791 +#: ../../library/optparse.rst:1902 msgid "" "def store_value(option, opt_str, value, parser):\n" " setattr(parser.values, option.dest, value)\n" @@ -2854,18 +3227,18 @@ msgstr "" " action=\"callback\", callback=store_value,\n" " type=\"int\", nargs=3, dest=\"foo\")" -#: ../../library/optparse.rst:1798 +#: ../../library/optparse.rst:1909 msgid "" "Note that :mod:`optparse` takes care of consuming 3 arguments and converting " "them to integers for you; all you have to do is store them. (Or whatever; " "obviously you don't need a callback for this example.)" msgstr "" -#: ../../library/optparse.rst:1806 +#: ../../library/optparse.rst:1917 msgid "Callback example 6: variable arguments" msgstr "" -#: ../../library/optparse.rst:1808 +#: ../../library/optparse.rst:1919 msgid "" "Things get hairy when you want an option to take a variable number of " "arguments. For this case, you must write a callback, as :mod:`optparse` " @@ -2875,23 +3248,23 @@ msgid "" "implement the conventional rules for bare ``--`` and ``-`` arguments:" msgstr "" -#: ../../library/optparse.rst:1815 +#: ../../library/optparse.rst:1926 msgid "either ``--`` or ``-`` can be option arguments" msgstr "" -#: ../../library/optparse.rst:1817 +#: ../../library/optparse.rst:1928 msgid "" "bare ``--`` (if not the argument to some option): halt command-line " "processing and discard the ``--``" msgstr "" -#: ../../library/optparse.rst:1820 +#: ../../library/optparse.rst:1931 msgid "" "bare ``-`` (if not the argument to some option): halt command-line " "processing but keep the ``-`` (append it to ``parser.largs``)" msgstr "" -#: ../../library/optparse.rst:1823 +#: ../../library/optparse.rst:1934 msgid "" "If you want an option that takes a variable number of arguments, there are " "several subtle, tricky issues to worry about. The exact implementation you " @@ -2900,13 +3273,13 @@ msgid "" "directly)." msgstr "" -#: ../../library/optparse.rst:1829 +#: ../../library/optparse.rst:1940 msgid "" "Nevertheless, here's a stab at a callback for an option with variable " "arguments::" msgstr "" -#: ../../library/optparse.rst:1832 +#: ../../library/optparse.rst:1943 msgid "" "def vararg_callback(option, opt_str, value, parser):\n" " assert value is None\n" @@ -2936,22 +3309,22 @@ msgid "" " action=\"callback\", callback=vararg_callback)" msgstr "" -#: ../../library/optparse.rst:1863 +#: ../../library/optparse.rst:1974 msgid "Extending :mod:`optparse`" msgstr "" -#: ../../library/optparse.rst:1865 +#: ../../library/optparse.rst:1976 msgid "" "Since the two major controlling factors in how :mod:`optparse` interprets " "command-line options are the action and type of each option, the most likely " "direction of extension is to add new actions and new types." msgstr "" -#: ../../library/optparse.rst:1873 +#: ../../library/optparse.rst:1984 msgid "Adding new types" msgstr "" -#: ../../library/optparse.rst:1875 +#: ../../library/optparse.rst:1986 msgid "" "To add new types, you need to define your own subclass of :mod:`optparse`'s :" "class:`Option` class. This class has a couple of attributes that define :" @@ -2959,23 +3332,23 @@ msgid "" "TYPE_CHECKER`." msgstr "" -#: ../../library/optparse.rst:1881 +#: ../../library/optparse.rst:1992 msgid "" "A tuple of type names; in your subclass, simply define a new tuple :attr:" "`TYPES` that builds on the standard one." msgstr "" -#: ../../library/optparse.rst:1886 +#: ../../library/optparse.rst:1997 msgid "" "A dictionary mapping type names to type-checking functions. A type-checking " "function has the following signature::" msgstr "" -#: ../../library/optparse.rst:1889 +#: ../../library/optparse.rst:2000 msgid "def check_mytype(option, opt, value)" msgstr "def check_mytype(option, opt, value)" -#: ../../library/optparse.rst:1891 +#: ../../library/optparse.rst:2002 msgid "" "where ``option`` is an :class:`Option` instance, ``opt`` is an option string " "(e.g., ``-f``), and ``value`` is the string from the command line that must " @@ -2986,7 +3359,7 @@ msgid "" "``value`` parameter." msgstr "" -#: ../../library/optparse.rst:1899 +#: ../../library/optparse.rst:2010 msgid "" "Your type-checking function should raise :exc:`OptionValueError` if it " "encounters any problems. :exc:`OptionValueError` takes a single string " @@ -2995,7 +3368,7 @@ msgid "" "\"`` and prints everything to stderr before terminating the process." msgstr "" -#: ../../library/optparse.rst:1905 +#: ../../library/optparse.rst:2016 msgid "" "Here's a silly example that demonstrates adding a ``\"complex\"`` option " "type to parse Python-style complex numbers on the command line. (This is " @@ -3003,11 +3376,11 @@ msgid "" "support for complex numbers, but never mind.)" msgstr "" -#: ../../library/optparse.rst:1910 +#: ../../library/optparse.rst:2021 msgid "First, the necessary imports::" msgstr "" -#: ../../library/optparse.rst:1912 +#: ../../library/optparse.rst:2023 msgid "" "from copy import copy\n" "from optparse import Option, OptionValueError" @@ -3015,13 +3388,13 @@ msgstr "" "from copy import copy\n" "from optparse import Option, OptionValueError" -#: ../../library/optparse.rst:1915 +#: ../../library/optparse.rst:2026 msgid "" "You need to define your type-checker first, since it's referred to later (in " "the :attr:`~Option.TYPE_CHECKER` class attribute of your Option subclass)::" msgstr "" -#: ../../library/optparse.rst:1918 +#: ../../library/optparse.rst:2029 msgid "" "def check_complex(option, opt, value):\n" " try:\n" @@ -3037,11 +3410,11 @@ msgstr "" " raise OptionValueError(\n" " \"option %s: invalid complex value: %r\" % (opt, value))" -#: ../../library/optparse.rst:1925 +#: ../../library/optparse.rst:2036 msgid "Finally, the Option subclass::" msgstr "" -#: ../../library/optparse.rst:1927 +#: ../../library/optparse.rst:2038 msgid "" "class MyOption (Option):\n" " TYPES = Option.TYPES + (\"complex\",)\n" @@ -3053,7 +3426,7 @@ msgstr "" " TYPE_CHECKER = copy(Option.TYPE_CHECKER)\n" " TYPE_CHECKER[\"complex\"] = check_complex" -#: ../../library/optparse.rst:1932 +#: ../../library/optparse.rst:2043 msgid "" "(If we didn't make a :func:`copy` of :attr:`Option.TYPE_CHECKER`, we would " "end up modifying the :attr:`~Option.TYPE_CHECKER` attribute of :mod:" @@ -3061,14 +3434,14 @@ msgid "" "that except good manners and common sense.)" msgstr "" -#: ../../library/optparse.rst:1937 +#: ../../library/optparse.rst:2048 msgid "" "That's it! Now you can write a script that uses the new option type just " "like any other :mod:`optparse`\\ -based script, except you have to instruct " "your OptionParser to use MyOption instead of Option::" msgstr "" -#: ../../library/optparse.rst:1941 +#: ../../library/optparse.rst:2052 msgid "" "parser = OptionParser(option_class=MyOption)\n" "parser.add_option(\"-c\", type=\"complex\")" @@ -3076,14 +3449,14 @@ msgstr "" "parser = OptionParser(option_class=MyOption)\n" "parser.add_option(\"-c\", type=\"complex\")" -#: ../../library/optparse.rst:1944 +#: ../../library/optparse.rst:2055 msgid "" "Alternately, you can build your own option list and pass it to OptionParser; " "if you don't use :meth:`add_option` in the above way, you don't need to tell " "OptionParser which option class to use::" msgstr "" -#: ../../library/optparse.rst:1948 +#: ../../library/optparse.rst:2059 msgid "" "option_list = [MyOption(\"-c\", action=\"store\", type=\"complex\", " "dest=\"c\")]\n" @@ -3093,32 +3466,32 @@ msgstr "" "dest=\"c\")]\n" "parser = OptionParser(option_list=option_list)" -#: ../../library/optparse.rst:1955 +#: ../../library/optparse.rst:2066 msgid "Adding new actions" msgstr "" -#: ../../library/optparse.rst:1957 +#: ../../library/optparse.rst:2068 msgid "" "Adding new actions is a bit trickier, because you have to understand that :" "mod:`optparse` has a couple of classifications for actions:" msgstr "" -#: ../../library/optparse.rst:1960 +#: ../../library/optparse.rst:2071 msgid "\"store\" actions" msgstr "" -#: ../../library/optparse.rst:1961 +#: ../../library/optparse.rst:2072 msgid "" "actions that result in :mod:`optparse` storing a value to an attribute of " "the current OptionValues instance; these options require a :attr:`~Option." "dest` attribute to be supplied to the Option constructor." msgstr "" -#: ../../library/optparse.rst:1965 +#: ../../library/optparse.rst:2076 msgid "\"typed\" actions" msgstr "" -#: ../../library/optparse.rst:1966 +#: ../../library/optparse.rst:2077 msgid "" "actions that take a value from the command line and expect it to be of a " "certain type; or rather, a string that can be converted to a certain type. " @@ -3126,7 +3499,7 @@ msgid "" "constructor." msgstr "" -#: ../../library/optparse.rst:1971 +#: ../../library/optparse.rst:2082 msgid "" "These are overlapping sets: some default \"store\" actions are " "``\"store\"``, ``\"store_const\"``, ``\"append\"``, and ``\"count\"``, while " @@ -3134,25 +3507,25 @@ msgid "" "``\"callback\"``." msgstr "" -#: ../../library/optparse.rst:1975 +#: ../../library/optparse.rst:2086 msgid "" "When you add an action, you need to categorize it by listing it in at least " "one of the following class attributes of Option (all are lists of strings):" msgstr "" -#: ../../library/optparse.rst:1980 +#: ../../library/optparse.rst:2091 msgid "All actions must be listed in ACTIONS." msgstr "" -#: ../../library/optparse.rst:1984 +#: ../../library/optparse.rst:2095 msgid "\"store\" actions are additionally listed here." msgstr "" -#: ../../library/optparse.rst:1988 +#: ../../library/optparse.rst:2099 msgid "\"typed\" actions are additionally listed here." msgstr "" -#: ../../library/optparse.rst:1992 +#: ../../library/optparse.rst:2103 msgid "" "Actions that always take a type (i.e. whose options always take a value) are " "additionally listed here. The only effect of this is that :mod:`optparse` " @@ -3160,13 +3533,13 @@ msgid "" "whose action is listed in :attr:`ALWAYS_TYPED_ACTIONS`." msgstr "" -#: ../../library/optparse.rst:1997 +#: ../../library/optparse.rst:2108 msgid "" "In order to actually implement your new action, you must override Option's :" "meth:`take_action` method and add a case that recognizes your action." msgstr "" -#: ../../library/optparse.rst:2000 +#: ../../library/optparse.rst:2111 msgid "" "For example, let's add an ``\"extend\"`` action. This is similar to the " "standard ``\"append\"`` action, but instead of taking a single value from " @@ -3176,23 +3549,23 @@ msgid "" "option of type ``\"string\"``, the command line ::" msgstr "" -#: ../../library/optparse.rst:2007 +#: ../../library/optparse.rst:2118 msgid "--names=foo,bar --names blah --names ding,dong" msgstr "--names=foo,bar --names blah --names ding,dong" -#: ../../library/optparse.rst:2009 +#: ../../library/optparse.rst:2120 msgid "would result in a list ::" msgstr "" -#: ../../library/optparse.rst:2011 +#: ../../library/optparse.rst:2122 msgid "[\"foo\", \"bar\", \"blah\", \"ding\", \"dong\"]" msgstr "[\"foo\", \"bar\", \"blah\", \"ding\", \"dong\"]" -#: ../../library/optparse.rst:2013 +#: ../../library/optparse.rst:2124 msgid "Again we define a subclass of Option::" msgstr "" -#: ../../library/optparse.rst:2015 +#: ../../library/optparse.rst:2126 msgid "" "class MyOption(Option):\n" "\n" @@ -3224,43 +3597,43 @@ msgstr "" " Option.take_action(\n" " self, action, dest, opt, value, values, parser)" -#: ../../library/optparse.rst:2030 +#: ../../library/optparse.rst:2141 msgid "Features of note:" msgstr "" -#: ../../library/optparse.rst:2032 +#: ../../library/optparse.rst:2143 msgid "" "``\"extend\"`` both expects a value on the command-line and stores that " "value somewhere, so it goes in both :attr:`~Option.STORE_ACTIONS` and :attr:" "`~Option.TYPED_ACTIONS`." msgstr "" -#: ../../library/optparse.rst:2036 +#: ../../library/optparse.rst:2147 msgid "" "to ensure that :mod:`optparse` assigns the default type of ``\"string\"`` to " "``\"extend\"`` actions, we put the ``\"extend\"`` action in :attr:`~Option." "ALWAYS_TYPED_ACTIONS` as well." msgstr "" -#: ../../library/optparse.rst:2040 +#: ../../library/optparse.rst:2151 msgid "" ":meth:`MyOption.take_action` implements just this one new action, and passes " "control back to :meth:`Option.take_action` for the standard :mod:`optparse` " "actions." msgstr "" -#: ../../library/optparse.rst:2044 +#: ../../library/optparse.rst:2155 msgid "" "``values`` is an instance of the optparse_parser.Values class, which " "provides the very useful :meth:`ensure_value` method. :meth:`ensure_value` " "is essentially :func:`getattr` with a safety valve; it is called as ::" msgstr "" -#: ../../library/optparse.rst:2048 +#: ../../library/optparse.rst:2159 msgid "values.ensure_value(attr, value)" msgstr "values.ensure_value(attr, value)" -#: ../../library/optparse.rst:2050 +#: ../../library/optparse.rst:2161 msgid "" "If the ``attr`` attribute of ``values`` doesn't exist or is ``None``, then " "ensure_value() first sets it to ``value``, and then returns ``value``. This " @@ -3273,28 +3646,28 @@ msgid "" "meth:`ensure_value` will take care of getting it right when it's needed." msgstr "" -#: ../../library/optparse.rst:2061 +#: ../../library/optparse.rst:2172 msgid "Exceptions" msgstr "例外" -#: ../../library/optparse.rst:2065 +#: ../../library/optparse.rst:2176 msgid "" "Raised if an :class:`Option` instance is created with invalid or " "inconsistent arguments." msgstr "" -#: ../../library/optparse.rst:2070 +#: ../../library/optparse.rst:2181 msgid "Raised if conflicting options are added to an :class:`OptionParser`." msgstr "" -#: ../../library/optparse.rst:2074 +#: ../../library/optparse.rst:2185 msgid "Raised if an invalid option value is encountered on the command line." msgstr "" -#: ../../library/optparse.rst:2078 +#: ../../library/optparse.rst:2189 msgid "Raised if an invalid option is passed on the command line." msgstr "" -#: ../../library/optparse.rst:2082 +#: ../../library/optparse.rst:2193 msgid "Raised if an ambiguous option is passed on the command line." msgstr "" diff --git a/library/os.path.po b/library/os.path.po index 2019487b8c..9518aa11e3 100644 --- a/library/os.path.po +++ b/library/os.path.po @@ -38,7 +38,7 @@ msgid "" "object implementing the :class:`os.PathLike` protocol." msgstr "" "該模組實現了一些有用的路徑名操作函式。若要讀取或寫入檔案,請參閱 :func:" -"`open` 函數,要存取檔案系統,請參閱 :mod:`os` 模組。路徑參數可以以字串、位元" +"`open` 函式,要存取檔案系統,請參閱 :mod:`os` 模組。路徑參數可以以字串、位元" "組或任何依照 :class:`os.PathLike` 協議實作的物件傳遞。" #: ../../library/os.path.rst:19 @@ -62,7 +62,7 @@ msgid "" "their parameters. The result is an object of the same type, if a path or " "file name is returned." msgstr "" -"所有這些函數都只接受位元組或字串物件作為參數。如果回傳的是路徑或檔案名稱,結" +"所有這些函式都只接受位元組或字串物件作為參數。如果回傳的是路徑或檔案名稱,結" "果將是相同型別的物件。" #: ../../library/os.path.rst:37 diff --git a/library/pickle.po b/library/pickle.po index 4846877e33..111cb91b47 100644 --- a/library/pickle.po +++ b/library/pickle.po @@ -562,9 +562,9 @@ msgid "" "class:`io.BytesIO` instance, or any other custom object that meets this " "interface." msgstr "" -"傳予引數 *file* 的物件必須支援可寫入單一位元組的 write() 方法。只要滿足此條" -"件,傳入的物件可以是一個硬碟上二進位檔案、一個 :class:`io.BytesIO` 實例或任何" -"其他滿足這個介面要求的物件。" +"引數 *file* 必須支援可寫入單一位元組引數的 write() 方法。只要滿足此條件,傳入" +"的物件可以是一個硬碟上二進位檔案、一個 :class:`io.BytesIO` 實例或任何其他滿足" +"這個介面要求的物件。" #: ../../library/pickle.rst:313 msgid "" @@ -585,8 +585,8 @@ msgid "" "If *buffer_callback* is ``None`` (the default), buffer views are serialized " "into *file* as part of the pickle stream." msgstr "" -"如果 *buffer_callback* 是 ``None`` (預設值),緩衝區的視圖會作為 pickle 封裝" -"串流的一部分被序列化進 *file* 中。" +"如果 *buffer_callback* 是 ``None``\\ (預設值),緩衝區的視圖會作為 pickle 封" +"裝串流的一部分被序列化進 *file* 中。" #: ../../library/pickle.rst:320 msgid "" @@ -658,10 +658,10 @@ msgid "" "reduction function takes a single argument of the associated class and " "should conform to the same interface as a :meth:`~object.__reduce__` method." msgstr "" -"封裝器(pickler)物件含有的的調度表是一個 *縮減函式* (reduction function)的" -"註冊表,可以使用 :func:`copyreg.pickle` 來宣告這類縮減函式。它是一個以類別為" -"鍵、還原函式為值的映射表。縮減函式應準備接收一個對應類別的引數,並應遵循與 :" -"meth:`~object.__reduce__` 方法相同的介面。" +"封裝器(pickler)物件含有的的調度表是一個\\ *縮減函式*\\ (reduction " +"function)的註冊表,可以使用 :func:`copyreg.pickle` 來宣告這類縮減函式。它是" +"一個以類別為鍵、還原函式為值的映射表。縮減函式應準備接收一個對應類別的引數," +"並應遵循與 :meth:`~object.__reduce__` 方法相同的介面。" #: ../../library/pickle.rst:362 msgid "" @@ -693,7 +693,7 @@ msgid "" msgstr "" "一個可以在 :class:`Pickler` 子類別中被定義的縮減器(reducer)。這個方法的優先" "度高於任何其他 :attr:`分派表 ` 中的縮減器。他應該要有和 :" -"meth:`~object.__reduce__` 方法相同的函數界面,且可以可選地回傳 :data:" +"meth:`~object.__reduce__` 方法相同的函式介面,且可以可選地回傳 :data:" "`NotImplemented` 以退回(fallback)使用 :attr:`分派表 ` 中登" "錄的縮減方法來封裝 ``obj``。" @@ -782,7 +782,7 @@ msgid "" msgstr "" "如果 *buffers* 不是 ``None``,則其應該是一個可疊代物件,內含數個支援緩衝區的" "物件,並且每當 pickle 串流引用一個\\ :ref:`帶外 `\\ 緩衝區視圖時" -"將會被照順序消耗。這些緩衝資料當初建立時應已按照順序給定予 Pickler 物件中的 " +"將會被照順序消耗。這些緩衝資料當初建立時應已按照順序給定於 Pickler 物件中的 " "*buffer_callback*。" #: ../../library/pickle.rst:438 @@ -796,7 +796,7 @@ msgstr "" #: ../../library/pickle.rst:445 msgid "Raise an :exc:`UnpicklingError` by default." -msgstr "預設會拋出 :exc:`UnpicklingError` 例外。" +msgstr "預設會引發 :exc:`UnpicklingError` 例外。" #: ../../library/pickle.rst:447 msgid "" @@ -820,7 +820,7 @@ msgid "" "unlike its name suggests, :meth:`find_class` is also used for finding " "functions." msgstr "" -"如有需要將引入 *module* ,並從中返回名為 *name* 的物件,這裡的 *module* 和 " +"如有需要將引入 *module* ,並從中回傳名為 *name* 的物件,這裡的 *module* 和 " "*name* 引數接受的輸入是 :class:`str` 物件。注意,雖然名稱上看起來不像,但 :" "meth:`find_class` 亦可被用於尋找其他函式。" @@ -850,7 +850,7 @@ msgid "" "`buffer-providing ` object, such as a :term:`bytes-like " "object` or a N-dimensional array." msgstr "" -"一個表示了含有可封裝數據緩衝區的包裝函數(wrapper function)。*buffer* 必須是" +"一個表示了含有可封裝資料緩衝區的包裝函式(wrapper function)。*buffer* 必須是" "一個 :ref:`提供緩衝區 ` 的物件,例如一個 :term:`類位元組物件 " "` 或 N 維陣列。" @@ -883,7 +883,7 @@ msgid "" "``B`` (unsigned bytes). :exc:`BufferError` is raised if the buffer is " "neither C- nor Fortran-contiguous." msgstr "" -"返回此緩衝區底層記憶體區域的 :class:`memoryview`。被返回的物件是一個(在 C 語" +"回傳此緩衝區底層記憶體區域的 :class:`memoryview`。被回傳的物件是一個(在 C 語" "言的 formatter 格式中)以 ``B`` (unsigned bytes) 二進位格式儲存、一維且列連續" "(C-contiguous)的 memoryview。如果緩衝區既不是列連續(C-contiguous)也不是行" "連續(Fortran-contiguous)的,則會引發 :exc:`BufferError`。" @@ -1016,7 +1016,7 @@ msgid "" msgstr "" "同樣地,當類別實例被封裝時,它所屬類別具有的程式碼和資料不會被一起封裝。只有" "實例資料本身會被封裝。這是有意而為的,因為如此你才可以在類別中修正錯誤或新增" -"其他方法,且於此同時仍能夠載入使用較早期版本的類別所建立的物件實例。如果您預" +"其他方法,且於此同時仍能夠載入使用較早期版本的類別所建立的物件實例。如果你預" "計將有長期存在的物件、且該物件將經歷許多版本的更替,你可以在物件中存放一個版" "本號,以便未來能透過 :meth:`~object.__setstate__` 方法來進行適當的版本轉換。" @@ -1131,7 +1131,7 @@ msgid "" "are several cases:" msgstr "" "目標類別可以透過覆寫方法 :meth:`__getstate__` 進一步影響其實例被封裝的方式。" -"封裝時,呼叫該方法所返回的物件將作為該實例的內容被封裝、而非一個預設狀態。以" +"封裝時,呼叫該方法所回傳的物件將作為該實例的內容被封裝、而非一個預設狀態。以" "下列出幾種預設狀態:" #: ../../library/pickle.rst:625 @@ -1195,7 +1195,7 @@ msgid "" "If :meth:`__reduce__` returns a state with value ``None`` at pickling, the :" "meth:`__setstate__` method will not be called upon unpickling." msgstr "" -"如果 :meth:`__reduce__` 在封裝時返回了 ``None`` 狀態,則拆封時就不會去呼叫 :" +"如果 :meth:`__reduce__` 在封裝時回傳了 ``None`` 狀態,則拆封時就不會去呼叫 :" "meth:`__setstate__`。" #: ../../library/pickle.rst:660 @@ -1274,14 +1274,14 @@ msgid "" "Optional items can either be omitted, or ``None`` can be provided as their " "value. The semantics of each item are in order:" msgstr "" -"當返回一個元組時,其長度必須介於兩至六項元素之間。可選項可以被省略,或者其值" +"當回傳一個元組時,其長度必須介於兩至六項元素之間。可選項可以被省略,或者其值" "可以被設為 ``None``。各項物件的語意依序為:" #: ../../library/pickle.rst:704 msgid "" "A callable object that will be called to create the initial version of the " "object." -msgstr "一個將會被呼叫來創建初始版本物件的可呼叫物件。" +msgstr "一個將會被呼叫來建立初始版本物件的可呼叫物件。" #: ../../library/pickle.rst:707 msgid "" @@ -1539,7 +1539,7 @@ msgstr "" "庫中的特定紀錄。\n" " return (\"MemoRecord\", obj.key)\n" " else:\n" -" # 如果 obj 沒有持久 ID,則返回 None。這表示 obj 像平常那樣封裝即" +" # 如果 obj 沒有持久 ID,則回傳 None。這表示 obj 像平常那樣封裝即" "可。\n" " return None\n" "\n" @@ -1556,13 +1556,13 @@ msgstr "" " cursor = self.connection.cursor()\n" " type_tag, key_id = pid\n" " if type_tag == \"MemoRecord\":\n" -" # 從資料庫中抓取所引用的紀錄並返回。\n" +" # 從資料庫中抓取所引用的紀錄並回傳。\n" " cursor.execute(\"SELECT * FROM memos WHERE key=?\", " "(str(key_id),))\n" " key, task = cursor.fetchone()\n" " return MemoRecord(key, task)\n" " else:\n" -" # 如果無法返回正確的物件,則必須拋出錯誤。\n" +" # 如果無法回傳正確的物件,則必須引發錯誤。\n" " # 否則 unpickler 會誤認為 None 是持久 ID 所引用的物件。\n" " raise pickle.UnpicklingError(\"unsupported persistent object\")\n" "\n" @@ -1628,7 +1628,7 @@ msgid "" "modified copy of :data:`!copyreg.dispatch_table` as a private dispatch table." msgstr "" "由 :mod:`copyreg` 模組管理的全域調度表可以 :data:`!copyreg.dispatch_table` 呼" -"叫。你可以透過這個方式來基於原始 :data:`!copyreg.dispatch_table` 創建一個修改" +"叫。你可以透過這個方式來基於原始 :data:`!copyreg.dispatch_table` 建立一個修改" "過的版本,作為你的專屬用途的調度表。" #: ../../library/pickle.rst:801 @@ -1816,7 +1816,7 @@ msgstr "" #: ../../library/pickle.rst:896 msgid "Custom Reduction for Types, Functions, and Other Objects" -msgstr "針對型別、函數或特定物件定製縮減函數" +msgstr "針對型別、函式或特定物件定製縮減函式" #: ../../library/pickle.rst:900 msgid "" @@ -1907,7 +1907,7 @@ msgstr "" "\n" "class MyPickler(pickle.Pickler):\n" " def reducer_override(self, obj):\n" -" \"\"\"MyClass 的自訂縮減函數。\"\"\"\n" +" \"\"\"MyClass 的自訂縮減函式。\"\"\"\n" " if getattr(obj, \"__name__\", None) == \"MyClass\":\n" " return type, (obj.__name__, obj.__bases__,\n" " {'my_attribute': obj.my_attribute})\n" @@ -1967,8 +1967,8 @@ msgid "" "for any large data." msgstr "" "要封裝的大型資料物件,則必須實作一個針對 5 版協定及以上的 :meth:`~object." -"__reduce_ex__` 方法,該方法應返回一個 :class:`PickleBuffer` 實例來處理任何大" -"型資料(而非返回如 :class:`bytes` 物件)。" +"__reduce_ex__` 方法,該方法應回傳一個 :class:`PickleBuffer` 實例來處理任何大" +"型資料(而非回傳如 :class:`bytes` 物件)。" #: ../../library/pickle.rst:980 msgid "" @@ -2002,8 +2002,8 @@ msgid "" "graph. Buffers accumulated by the *buffer_callback* will not see their data " "copied into the pickle stream, only a cheap marker will be inserted." msgstr "" -"傳送端需要傳遞一個調用緩衝區的回呼函數給 :class:`Pickler`\\ (或 :func:" -"`dump` 或 :func:`dumps` 函數)的 *buffer_callback* 引數,使每次生成 :class:" +"傳送端需要傳遞一個調用緩衝區的回呼函式給 :class:`Pickler`\\ (或 :func:" +"`dump` 或 :func:`dumps` 函式)的 *buffer_callback* 引數,使每次生成 :class:" "`PickleBuffer` 時,該物件在處理物件圖時能被呼叫。除了一個簡易標記以外,由 " "*buffer_callback* 累積的緩衝區資料不會被複製到 pickle 串流中。" @@ -2095,7 +2095,7 @@ msgid "" "providing object if it has the right type. This is an easy way to simulate " "zero-copy behaviour on this toy example." msgstr "" -"如果型別正確,重建器(``_reconstruct`` 類別方法)會返回當時提供緩衝區的物件。" +"如果型別正確,重建器(``_reconstruct`` 類別方法)會回傳當時提供緩衝區的物件。" "這個簡易實作可以模擬一個無複製行為的重建器。" #: ../../library/pickle.rst:1043 @@ -2125,7 +2125,7 @@ msgid "" "But if we pass a *buffer_callback* and then give back the accumulated " "buffers when unserializing, we are able to get back the original object::" msgstr "" -"但如果我們傳一個 *buffer_callback* 並在去序列化時正確返回積累的緩衝資料,我們" +"但如果我們傳一個 *buffer_callback* 並在去序列化時正確回傳積累的緩衝資料,我們" "就能拿回原始的物件:::" #: ../../library/pickle.rst:1055 @@ -2153,7 +2153,7 @@ msgid "" "making as few copies as possible) when transferring between distinct " "processes or systems." msgstr "" -"此範例是因為受限於 :class:`bytearray` 會自行分配記憶體:您無法創建以其他物件" +"此範例是因為受限於 :class:`bytearray` 會自行分配記憶體:你無法建立以其他物件" "的記憶體為基礎的 :class:`bytearray` 實例。不過第三方資料型態(如 NumPy 陣列)" "則可能沒有這個限制,而允許在不同程序或系統之間傳輸資料時使用零拷貝封裝(或儘" "可能地減少拷貝次數)。" @@ -2208,7 +2208,7 @@ msgid "" "requested. Thus it is possible to either completely forbid globals or " "restrict them to a safe subset." msgstr "" -"基於以上原因,您可能會希望透過自訂 :meth:`Unpickler.find_class` 來控制哪些是" +"基於以上原因,你可能會希望透過自訂 :meth:`Unpickler.find_class` 來控制哪些是" "能夠被拆封的內容。與其名稱字面意義暗示的不同,實際上每當你請求一個全域物件" "(例如,類別或函式)時,就會調用 :meth:`Unpickler.find_class`。因此,可以透過" "這個方法完全禁止全域物件或將其限制在安全的子集合。" @@ -2272,7 +2272,7 @@ msgstr "" " (module, name))\n" "\n" "def restricted_loads(s):\n" -" \"\"\"一個模擬 pickle.loads() 的輔助函數\"\"\"\n" +" \"\"\"一個模擬 pickle.loads() 的輔助函式\"\"\"\n" " return RestrictedUnpickler(io.BytesIO(s)).load()" #: ../../library/pickle.rst:1129 @@ -2314,8 +2314,8 @@ msgid "" "alternatives such as the marshalling API in :mod:`xmlrpc.client` or third-" "party solutions." msgstr "" -"正如我們的範例所示,必須謹慎審視能被拆封的內容。因此,如果您的應用場景非常關" -"心安全性,您可能需要考慮其他選擇,例如 :mod:`xmlrpc.client` 中的 marshalling " +"正如我們的範例所示,必須謹慎審視能被拆封的內容。因此,如果你的應用場景非常關" +"心安全性,你可能需要考慮其他選擇,例如 :mod:`xmlrpc.client` 中的 marshalling " "API 或其他第三方解決方案。" #: ../../library/pickle.rst:1155 @@ -2449,7 +2449,7 @@ msgid "" "The exception raised will likely be an :exc:`ImportError` or an :exc:" "`AttributeError` but it could be something else." msgstr "" -"拋出的例外應該是 :exc:`ImportError` 或 :exc:`AttributeError`,但也可能是其他" +"引發的例外應該是 :exc:`ImportError` 或 :exc:`AttributeError`,但也可能是其他" "例外。" #: ../../library/pickle.rst:1225 diff --git a/library/random.po b/library/random.po index 08679f4e90..a2417c7d11 100644 --- a/library/random.po +++ b/library/random.po @@ -41,7 +41,7 @@ msgid "" "replacement." msgstr "" "對於整數,可以從範圍中進行均勻選擇。對於序列,有一個隨機元素的均勻選擇,一個" -"用來原地 (in-place) 產生隨機排列清單的函式,以及一個用來隨機採樣不替換的函" +"用來原地 (in-place) 產生隨機排列清單的函式,以及一個用來隨機取樣不替換的函" "式。" #: ../../library/random.rst:19 diff --git a/library/ssl.po b/library/ssl.po index a00c5acbd3..6fa89a6402 100644 --- a/library/ssl.po +++ b/library/ssl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"POT-Creation-Date: 2024-12-20 00:13+0000\n" "PO-Revision-Date: 2024-08-28 00:43+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -3542,10 +3542,11 @@ msgstr "" #: ../../library/ssl.rst:2510 msgid "" "The :mod:`asyncio` module supports :ref:`non-blocking SSL sockets ` and provides a higher level API. It polls for events using " -"the :mod:`selectors` module and handles :exc:`SSLWantWriteError`, :exc:" -"`SSLWantReadError` and :exc:`BlockingIOError` exceptions. It runs the SSL " -"handshake asynchronously as well." +"nonblocking>` and provides a higher level :ref:`Streams API `. It polls for events using the :mod:`selectors` module and " +"handles :exc:`SSLWantWriteError`, :exc:`SSLWantReadError` and :exc:" +"`BlockingIOError` exceptions. It runs the SSL handshake asynchronously as " +"well." msgstr "" #: ../../library/ssl.rst:2519 diff --git a/library/superseded.po b/library/superseded.po index 179f3bcb8a..c9dd877050 100644 --- a/library/superseded.po +++ b/library/superseded.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -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: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2022-02-15 20:45+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,29 @@ msgid "Superseded Modules" msgstr "已被取代的模組" #: ../../library/superseded.rst:7 -#, fuzzy msgid "" -"The modules described in this chapter are deprecated or :term:`soft " -"deprecated` and only kept for backwards compatibility. They have been " -"superseded by other modules." +"The modules described in this chapter have been superseded by other modules " +"for most use cases, and are retained primarily to preserve backwards " +"compatibility." +msgstr "" +"此章節所描述的模組在大多數使用情況下已被其他模組取代,僅為了向後相容性而被保" +"留下來。" + +#: ../../library/superseded.rst:10 +msgid "" +"Modules may appear in this chapter because they only cover a limited subset " +"of a problem space, and a more generally applicable solution is available " +"elsewhere in the standard library (for example, :mod:`getopt` covers the " +"very specific task of \"mimic the C :c:func:`!getopt` API in Python\", " +"rather than the broader command line option parsing and argument parsing " +"capabilities offered by :mod:`optparse` and :mod:`argparse`)." +msgstr "" + +#: ../../library/superseded.rst:17 +msgid "" +"Alternatively, modules may appear in this chapter because they are " +"deprecated outright, and awaiting removal in a future release, or they are :" +"term:`soft deprecated` and their use is actively discouraged in new " +"projects. With the removal of various obsolete modules through :pep:`594`, " +"there are currently no modules in this latter category." msgstr "" -"此章節所描述的模組 (modules) 均已被棄用,僅為了向後相容性而被保留下來。它們已" -"經被其他模組所取代。" diff --git a/library/timeit.po b/library/timeit.po index b7a9d153b8..4b5e7eb49d 100644 --- a/library/timeit.po +++ b/library/timeit.po @@ -110,7 +110,7 @@ msgid "" "repetitions only when the command-line interface is used. In the :ref:" "`timeit-examples` section you can find more advanced examples." msgstr "" -"但請注意,僅當使用命令列界面時 :func:`.timeit` 才會自動確定重複次數。在\\ :" +"但請注意,僅當使用命令列介面時 :func:`.timeit` 才會自動確定重複次數。在\\ :" "ref:`timeit-examples`\\ 章節中有更進階的範例。" #: ../../library/timeit.rst:60 diff --git a/library/tty.po b/library/tty.po index 86b6a46e29..6b2b0efbc6 100644 --- a/library/tty.po +++ b/library/tty.po @@ -81,7 +81,7 @@ msgid "" msgstr "" "將檔案描述器 *fd* 的模式更改為 raw。如果 *when* 被省略,則預設為 :const:" "`termios.TCSAFLUSH`,並傳遞給 :func:`termios.tcsetattr`。:func:`termios." -"tcgetattr` 的回傳值會在設定 *fd* 模式為 raw 之前先儲存起來。此函數回傳這個" +"tcgetattr` 的回傳值會在設定 *fd* 模式為 raw 之前先儲存起來。此函式回傳這個" "值。" #: ../../library/tty.rst:55 ../../library/tty.rst:69 @@ -98,7 +98,7 @@ msgid "" msgstr "" "將檔案描述器 *fd* 的模式更改為 cbreak。如果 *when* 被省略,則預設為 :const:" "`termios.TCSAFLUSH`,並傳遞給 :func:`termios.tcsetattr`。:func:`termios." -"tcgetattr` 的回傳值會在設定 *fd* 模式為 raw 之前先儲存起來。此函數回傳這個" +"tcgetattr` 的回傳值會在設定 *fd* 模式為 raw 之前先儲存起來。此函式回傳這個" "值。" #: ../../library/tty.rst:66 diff --git a/library/unittest.po b/library/unittest.po index bd134aa24b..9b00ef635a 100644 --- a/library/unittest.po +++ b/library/unittest.po @@ -548,11 +548,11 @@ msgstr "" #: ../../library/unittest.rst:291 msgid "The ``discover`` sub-command has the following options:" -msgstr "``discover`` 子指令有以下幾個選項:" +msgstr "``discover`` 子命令有以下幾個選項:" #: ../../library/unittest.rst:297 msgid "Verbose output" -msgstr "詳細(verbose)輸出" +msgstr "詳細 (verbose) 輸出" #: ../../library/unittest.rst:301 msgid "Directory to start discovery (``.`` default)" @@ -564,7 +564,7 @@ msgstr "匹配測試檔案的模式(預設為 ``test*.py``\\ )" #: ../../library/unittest.rst:309 msgid "Top level directory of project (defaults to start directory)" -msgstr "專案的最高階層目錄 (defaults to start directory)" +msgstr "專案的最高階層目錄(預設為開始的資料夾)" #: ../../library/unittest.rst:311 msgid "" @@ -1186,6 +1186,35 @@ msgid "" " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" "AssertionError: 1 != 0" msgstr "" +"======================================================================\n" +"FAIL: test_even (__main__.NumbersTest.test_even) (i=1)\n" +"Test that numbers between 0 and 5 are all even.\n" +"----------------------------------------------------------------------\n" +"Traceback (most recent call last):\n" +" File \"subtests.py\", line 11, in test_even\n" +" self.assertEqual(i % 2, 0)\n" +" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +"AssertionError: 1 != 0\n" +"\n" +"======================================================================\n" +"FAIL: test_even (__main__.NumbersTest.test_even) (i=3)\n" +"Test that numbers between 0 and 5 are all even.\n" +"----------------------------------------------------------------------\n" +"Traceback (most recent call last):\n" +" File \"subtests.py\", line 11, in test_even\n" +" self.assertEqual(i % 2, 0)\n" +" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +"AssertionError: 1 != 0\n" +"\n" +"======================================================================\n" +"FAIL: test_even (__main__.NumbersTest.test_even) (i=5)\n" +"Test that numbers between 0 and 5 are all even.\n" +"----------------------------------------------------------------------\n" +"Traceback (most recent call last):\n" +" File \"subtests.py\", line 11, in test_even\n" +" self.assertEqual(i % 2, 0)\n" +" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +"AssertionError: 1 != 0" #: ../../library/unittest.rst:699 msgid "" @@ -1214,7 +1243,7 @@ msgstr "" #: ../../library/unittest.rst:715 msgid "Classes and functions" -msgstr "" +msgstr "類別與函式" #: ../../library/unittest.rst:717 msgid "This section describes in depth the API of :mod:`unittest`." @@ -1378,7 +1407,7 @@ msgstr "" #: ../../library/unittest.rst:853 ../../library/unittest.rst:974 #: ../../library/unittest.rst:1188 ../../library/unittest.rst:1312 msgid "Method" -msgstr "" +msgstr "方法" #: ../../library/unittest.rst:853 ../../library/unittest.rst:974 #: ../../library/unittest.rst:1188 @@ -1589,13 +1618,15 @@ msgstr ":meth:`assertRaises(exc, fun, *args, **kwds) `" #: ../../library/unittest.rst:976 msgid "``fun(*args, **kwds)`` raises *exc*" -msgstr "" +msgstr "``fun(*args, **kwds)`` 會引發 *exc*" #: ../../library/unittest.rst:979 msgid "" ":meth:`assertRaisesRegex(exc, r, fun, *args, **kwds) `" msgstr "" +":meth:`assertRaisesRegex(exc, r, fun, *args, **kwds) `" #: ../../library/unittest.rst:979 msgid "``fun(*args, **kwds)`` raises *exc* and the message matches regex *r*" @@ -1607,7 +1638,7 @@ msgstr ":meth:`assertWarns(warn, fun, *args, **kwds) `" #: ../../library/unittest.rst:982 msgid "``fun(*args, **kwds)`` raises *warn*" -msgstr "" +msgstr "``fun(*args, **kwds)`` 會引發 *warn*" #: ../../library/unittest.rst:985 msgid "" @@ -1725,6 +1756,8 @@ msgid "" "self.assertRaisesRegex(ValueError, \"invalid literal for.*XYZ'$\",\n" " int, 'XYZ')" msgstr "" +"self.assertRaisesRegex(ValueError, \"invalid literal for.*XYZ'$\",\n" +" int, 'XYZ')" #: ../../library/unittest.rst:1046 ../../library/unittest.rst:1114 msgid "or::" @@ -1818,12 +1851,17 @@ msgid "" " r'legacy_function\\(\\) is deprecated',\n" " legacy_function, 'XYZ')" msgstr "" +"self.assertWarnsRegex(DeprecationWarning,\n" +" r'legacy_function\\(\\) is deprecated',\n" +" legacy_function, 'XYZ')" #: ../../library/unittest.rst:1116 msgid "" "with self.assertWarnsRegex(RuntimeWarning, 'unsafe frobnicating'):\n" " frobnicate('/etc/passwd')" msgstr "" +"with self.assertWarnsRegex(RuntimeWarning, 'unsafe frobnicating'):\n" +" frobnicate('/etc/passwd')" #: ../../library/unittest.rst:1126 msgid "" @@ -1881,6 +1919,11 @@ msgid "" "self.assertEqual(cm.output, ['INFO:foo:first message',\n" " 'ERROR:foo.bar:second message'])" msgstr "" +"with self.assertLogs('foo', level='INFO') as cm:\n" +" logging.getLogger('foo').info('first message')\n" +" logging.getLogger('foo.bar').error('second message')\n" +"self.assertEqual(cm.output, ['INFO:foo:first message',\n" +" 'ERROR:foo.bar:second message'])" #: ../../library/unittest.rst:1168 msgid "" @@ -2016,6 +2059,8 @@ msgid "" ">>> self.assertGreaterEqual(3, 4)\n" "AssertionError: \"3\" unexpectedly not greater than or equal to \"4\"" msgstr "" +">>> self.assertGreaterEqual(3, 4)\n" +"AssertionError: \"3\" unexpectedly not greater than or equal to \"4\"" #: ../../library/unittest.rst:1257 msgid "" @@ -2034,7 +2079,7 @@ msgstr "以 ``assertRegexpMatches`` 為名新增。" msgid "" "The method ``assertRegexpMatches()`` has been renamed to :meth:`." "assertRegex`." -msgstr "" +msgstr "``assertRegexpMatches()`` 方法已重新命名為 :meth:`.assertRegex`。" #: ../../library/unittest.rst:1268 msgid ":meth:`.assertNotRegex`." @@ -2091,7 +2136,7 @@ msgstr ":meth:`assertMultiLineEqual(a, b) `" #: ../../library/unittest.rst:1314 msgid "strings" -msgstr "" +msgstr "字串" #: ../../library/unittest.rst:1317 msgid ":meth:`assertSequenceEqual(a, b) `" @@ -2099,7 +2144,7 @@ msgstr ":meth:`assertSequenceEqual(a, b) `" #: ../../library/unittest.rst:1317 msgid "sequences" -msgstr "" +msgstr "序列" #: ../../library/unittest.rst:1320 msgid ":meth:`assertListEqual(a, b) `" @@ -2107,7 +2152,7 @@ msgstr ":meth:`assertListEqual(a, b) `" #: ../../library/unittest.rst:1320 msgid "lists" -msgstr "" +msgstr "串列" #: ../../library/unittest.rst:1323 msgid ":meth:`assertTupleEqual(a, b) `" @@ -2115,7 +2160,7 @@ msgstr ":meth:`assertTupleEqual(a, b) `" #: ../../library/unittest.rst:1323 msgid "tuples" -msgstr "" +msgstr "元組" #: ../../library/unittest.rst:1326 msgid ":meth:`assertSetEqual(a, b) `" @@ -2123,7 +2168,7 @@ msgstr ":meth:`assertSetEqual(a, b) `" #: ../../library/unittest.rst:1326 msgid "sets or frozensets" -msgstr "" +msgstr "集合或凍結集合" #: ../../library/unittest.rst:1329 msgid ":meth:`assertDictEqual(a, b) `" @@ -2131,7 +2176,7 @@ msgstr ":meth:`assertDictEqual(a, b) `" #: ../../library/unittest.rst:1329 msgid "dicts" -msgstr "" +msgstr "字典" #: ../../library/unittest.rst:1337 msgid "" @@ -3332,7 +3377,7 @@ msgstr "" #: ../../library/unittest.rst:2337 msgid "load_tests Protocol" -msgstr "" +msgstr "load_tests 協定" #: ../../library/unittest.rst:2341 msgid "" @@ -3359,7 +3404,7 @@ msgstr "" #: ../../library/unittest.rst:2352 msgid "It should return a :class:`TestSuite`." -msgstr "" +msgstr "它應該回傳一個 :class:`TestSuite`。" #: ../../library/unittest.rst:2354 msgid "" @@ -3497,7 +3542,7 @@ msgstr "" #: ../../library/unittest.rst:2440 msgid "setUpClass and tearDownClass" -msgstr "" +msgstr "setUpClass 和 tearDownClass" #: ../../library/unittest.rst:2442 msgid "These must be implemented as class methods::" @@ -3545,7 +3590,7 @@ msgstr "" #: ../../library/unittest.rst:2467 msgid "setUpModule and tearDownModule" -msgstr "" +msgstr "setUpModule 和 tearDownModule" #: ../../library/unittest.rst:2469 msgid "These should be implemented as functions::" diff --git a/reference/compound_stmts.po b/reference/compound_stmts.po index 6c12ef1f85..d5a74fad17 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: 2024-11-12 00:13+0000\n" +"POT-Creation-Date: 2024-12-29 11: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-" @@ -610,8 +610,8 @@ msgid "" msgstr "" #: ../../reference/compound_stmts.rst:526 -#: ../../reference/compound_stmts.rst:1544 -#: ../../reference/compound_stmts.rst:1585 +#: ../../reference/compound_stmts.rst:1547 +#: ../../reference/compound_stmts.rst:1588 msgid "The following code::" msgstr "以下程式碼: ::" @@ -624,8 +624,8 @@ msgstr "" " SUITE" #: ../../reference/compound_stmts.rst:531 -#: ../../reference/compound_stmts.rst:553 -#: ../../reference/compound_stmts.rst:1590 +#: ../../reference/compound_stmts.rst:556 +#: ../../reference/compound_stmts.rst:1593 msgid "is semantically equivalent to::" msgstr "在語義上等同於: ::" @@ -635,37 +635,43 @@ msgid "" "enter = type(manager).__enter__\n" "exit = type(manager).__exit__\n" "value = enter(manager)\n" +"hit_except = False\n" "\n" "try:\n" " TARGET = value\n" " SUITE\n" "except:\n" +" hit_except = True\n" " if not exit(manager, *sys.exc_info()):\n" " raise\n" -"else:\n" -" exit(manager, None, None, None)" +"finally:\n" +" if not hit_except:\n" +" exit(manager, None, None, None)" msgstr "" "manager = (EXPRESSION)\n" "enter = type(manager).__enter__\n" "exit = type(manager).__exit__\n" "value = enter(manager)\n" +"hit_except = False\n" "\n" "try:\n" " TARGET = value\n" " SUITE\n" "except:\n" +" hit_except = True\n" " if not exit(manager, *sys.exc_info()):\n" " raise\n" -"else:\n" -" exit(manager, None, None, None)" +"finally:\n" +" if not hit_except:\n" +" exit(manager, None, None, None)" -#: ../../reference/compound_stmts.rst:547 +#: ../../reference/compound_stmts.rst:550 msgid "" "With more than one item, the context managers are processed as if multiple :" "keyword:`with` statements were nested::" msgstr "" -#: ../../reference/compound_stmts.rst:550 +#: ../../reference/compound_stmts.rst:553 msgid "" "with A() as a, B() as b:\n" " SUITE" @@ -673,7 +679,7 @@ msgstr "" "with A() as a, B() as b:\n" " SUITE" -#: ../../reference/compound_stmts.rst:555 +#: ../../reference/compound_stmts.rst:558 msgid "" "with A() as a:\n" " with B() as b:\n" @@ -683,13 +689,13 @@ msgstr "" " with B() as b:\n" " SUITE" -#: ../../reference/compound_stmts.rst:559 +#: ../../reference/compound_stmts.rst:562 msgid "" "You can also write multi-item context managers in multiple lines if the " "items are surrounded by parentheses. For example::" msgstr "" -#: ../../reference/compound_stmts.rst:562 +#: ../../reference/compound_stmts.rst:565 msgid "" "with (\n" " A() as a,\n" @@ -703,88 +709,88 @@ msgstr "" "):\n" " SUITE" -#: ../../reference/compound_stmts.rst:568 +#: ../../reference/compound_stmts.rst:571 msgid "Support for multiple context expressions." msgstr "" -#: ../../reference/compound_stmts.rst:571 +#: ../../reference/compound_stmts.rst:574 msgid "" "Support for using grouping parentheses to break the statement in multiple " "lines." msgstr "" -#: ../../reference/compound_stmts.rst:576 +#: ../../reference/compound_stmts.rst:579 msgid ":pep:`343` - The \"with\" statement" msgstr "" -#: ../../reference/compound_stmts.rst:577 +#: ../../reference/compound_stmts.rst:580 msgid "" "The specification, background, and examples for the Python :keyword:`with` " "statement." msgstr "" -#: ../../reference/compound_stmts.rst:583 +#: ../../reference/compound_stmts.rst:586 msgid "The :keyword:`!match` statement" msgstr ":keyword:`!match` 陳述式" -#: ../../reference/compound_stmts.rst:597 +#: ../../reference/compound_stmts.rst:600 msgid "The match statement is used for pattern matching. Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:606 +#: ../../reference/compound_stmts.rst:609 msgid "" "This section uses single quotes to denote :ref:`soft keywords `." msgstr "" -#: ../../reference/compound_stmts.rst:609 +#: ../../reference/compound_stmts.rst:612 msgid "" "Pattern matching takes a pattern as input (following ``case``) and a subject " "value (following ``match``). The pattern (which may contain subpatterns) is " "matched against the subject value. The outcomes are:" msgstr "" -#: ../../reference/compound_stmts.rst:613 +#: ../../reference/compound_stmts.rst:616 msgid "A match success or failure (also termed a pattern success or failure)." msgstr "" -#: ../../reference/compound_stmts.rst:615 +#: ../../reference/compound_stmts.rst:618 msgid "" "Possible binding of matched values to a name. The prerequisites for this " "are further discussed below." msgstr "" -#: ../../reference/compound_stmts.rst:618 +#: ../../reference/compound_stmts.rst:621 msgid "" "The ``match`` and ``case`` keywords are :ref:`soft keywords `." msgstr "" -#: ../../reference/compound_stmts.rst:622 -#: ../../reference/compound_stmts.rst:1179 +#: ../../reference/compound_stmts.rst:625 +#: ../../reference/compound_stmts.rst:1182 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" -#: ../../reference/compound_stmts.rst:623 -#: ../../reference/compound_stmts.rst:1180 +#: ../../reference/compound_stmts.rst:626 +#: ../../reference/compound_stmts.rst:1183 msgid ":pep:`636` -- Structural Pattern Matching: Tutorial" msgstr "" -#: ../../reference/compound_stmts.rst:627 +#: ../../reference/compound_stmts.rst:630 msgid "Overview" msgstr "" -#: ../../reference/compound_stmts.rst:629 +#: ../../reference/compound_stmts.rst:632 msgid "Here's an overview of the logical flow of a match statement:" msgstr "" -#: ../../reference/compound_stmts.rst:632 +#: ../../reference/compound_stmts.rst:635 msgid "" "The subject expression ``subject_expr`` is evaluated and a resulting subject " "value obtained. If the subject expression contains a comma, a tuple is " "constructed using :ref:`the standard rules `." msgstr "" -#: ../../reference/compound_stmts.rst:636 +#: ../../reference/compound_stmts.rst:639 msgid "" "Each pattern in a ``case_block`` is attempted to match with the subject " "value. The specific rules for success or failure are described below. The " @@ -794,7 +800,7 @@ msgid "" "outlive the executed block and can be used after the match statement**." msgstr "" -#: ../../reference/compound_stmts.rst:645 +#: ../../reference/compound_stmts.rst:648 msgid "" "During failed pattern matches, some subpatterns may succeed. Do not rely on " "bindings being made for a failed match. Conversely, do not rely on " @@ -803,38 +809,38 @@ msgid "" "made to allow different implementations to add optimizations." msgstr "" -#: ../../reference/compound_stmts.rst:652 +#: ../../reference/compound_stmts.rst:655 msgid "" "If the pattern succeeds, the corresponding guard (if present) is evaluated. " "In this case all name bindings are guaranteed to have happened." msgstr "" -#: ../../reference/compound_stmts.rst:655 +#: ../../reference/compound_stmts.rst:658 msgid "" "If the guard evaluates as true or is missing, the ``block`` inside " "``case_block`` is executed." msgstr "" -#: ../../reference/compound_stmts.rst:658 +#: ../../reference/compound_stmts.rst:661 msgid "Otherwise, the next ``case_block`` is attempted as described above." msgstr "" -#: ../../reference/compound_stmts.rst:660 +#: ../../reference/compound_stmts.rst:663 msgid "If there are no further case blocks, the match statement is completed." msgstr "" -#: ../../reference/compound_stmts.rst:664 +#: ../../reference/compound_stmts.rst:667 msgid "" "Users should generally never rely on a pattern being evaluated. Depending " "on implementation, the interpreter may cache values or use other " "optimizations which skip repeated evaluations." msgstr "" -#: ../../reference/compound_stmts.rst:668 +#: ../../reference/compound_stmts.rst:671 msgid "A sample match statement::" msgstr "" -#: ../../reference/compound_stmts.rst:670 +#: ../../reference/compound_stmts.rst:673 msgid "" ">>> flag = False\n" ">>> match (100, 200):\n" @@ -850,56 +856,56 @@ msgid "" "Case 3, y: 200" msgstr "" -#: ../../reference/compound_stmts.rst:684 +#: ../../reference/compound_stmts.rst:687 msgid "" "In this case, ``if flag`` is a guard. Read more about that in the next " "section." msgstr "" -#: ../../reference/compound_stmts.rst:687 +#: ../../reference/compound_stmts.rst:690 msgid "Guards" msgstr "" -#: ../../reference/compound_stmts.rst:694 +#: ../../reference/compound_stmts.rst:697 msgid "" "A ``guard`` (which is part of the ``case``) must succeed for code inside the " "``case`` block to execute. It takes the form: :keyword:`if` followed by an " "expression." msgstr "" -#: ../../reference/compound_stmts.rst:699 +#: ../../reference/compound_stmts.rst:702 msgid "The logical flow of a ``case`` block with a ``guard`` follows:" msgstr "" -#: ../../reference/compound_stmts.rst:701 +#: ../../reference/compound_stmts.rst:704 msgid "" "Check that the pattern in the ``case`` block succeeded. If the pattern " "failed, the ``guard`` is not evaluated and the next ``case`` block is " "checked." msgstr "" -#: ../../reference/compound_stmts.rst:705 +#: ../../reference/compound_stmts.rst:708 msgid "If the pattern succeeded, evaluate the ``guard``." msgstr "" -#: ../../reference/compound_stmts.rst:707 +#: ../../reference/compound_stmts.rst:710 msgid "" "If the ``guard`` condition evaluates as true, the case block is selected." msgstr "" -#: ../../reference/compound_stmts.rst:710 +#: ../../reference/compound_stmts.rst:713 msgid "" "If the ``guard`` condition evaluates as false, the case block is not " "selected." msgstr "" -#: ../../reference/compound_stmts.rst:713 +#: ../../reference/compound_stmts.rst:716 msgid "" "If the ``guard`` raises an exception during evaluation, the exception " "bubbles up." msgstr "" -#: ../../reference/compound_stmts.rst:716 +#: ../../reference/compound_stmts.rst:719 msgid "" "Guards are allowed to have side effects as they are expressions. Guard " "evaluation must proceed from the first to the last case block, one at a " @@ -908,17 +914,17 @@ msgid "" "block is selected." msgstr "" -#: ../../reference/compound_stmts.rst:726 +#: ../../reference/compound_stmts.rst:729 msgid "Irrefutable Case Blocks" msgstr "" -#: ../../reference/compound_stmts.rst:730 +#: ../../reference/compound_stmts.rst:733 msgid "" "An irrefutable case block is a match-all case block. A match statement may " "have at most one irrefutable case block, and it must be last." msgstr "" -#: ../../reference/compound_stmts.rst:733 +#: ../../reference/compound_stmts.rst:736 msgid "" "A case block is considered irrefutable if it has no guard and its pattern is " "irrefutable. A pattern is considered irrefutable if we can prove from its " @@ -926,47 +932,47 @@ msgid "" "irrefutable:" msgstr "" -#: ../../reference/compound_stmts.rst:738 +#: ../../reference/compound_stmts.rst:741 msgid ":ref:`as-patterns` whose left-hand side is irrefutable" msgstr "" -#: ../../reference/compound_stmts.rst:740 +#: ../../reference/compound_stmts.rst:743 msgid ":ref:`or-patterns` containing at least one irrefutable pattern" msgstr "" -#: ../../reference/compound_stmts.rst:742 +#: ../../reference/compound_stmts.rst:745 msgid ":ref:`capture-patterns`" msgstr ":ref:`capture-patterns`" -#: ../../reference/compound_stmts.rst:744 +#: ../../reference/compound_stmts.rst:747 msgid ":ref:`wildcard-patterns`" msgstr ":ref:`wildcard-patterns`" -#: ../../reference/compound_stmts.rst:746 +#: ../../reference/compound_stmts.rst:749 msgid "parenthesized irrefutable patterns" msgstr "" -#: ../../reference/compound_stmts.rst:750 +#: ../../reference/compound_stmts.rst:753 msgid "Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:757 +#: ../../reference/compound_stmts.rst:760 msgid "This section uses grammar notations beyond standard EBNF:" msgstr "" -#: ../../reference/compound_stmts.rst:759 +#: ../../reference/compound_stmts.rst:762 msgid "the notation ``SEP.RULE+`` is shorthand for ``RULE (SEP RULE)*``" msgstr "" -#: ../../reference/compound_stmts.rst:761 +#: ../../reference/compound_stmts.rst:764 msgid "the notation ``!RULE`` is shorthand for a negative lookahead assertion" msgstr "" -#: ../../reference/compound_stmts.rst:764 +#: ../../reference/compound_stmts.rst:767 msgid "The top-level syntax for ``patterns`` is:" msgstr "" -#: ../../reference/compound_stmts.rst:778 +#: ../../reference/compound_stmts.rst:781 msgid "" "The descriptions below will include a description \"in simple terms\" of " "what a pattern does for illustration purposes (credits to Raymond Hettinger " @@ -976,70 +982,70 @@ msgid "" "forms." msgstr "" -#: ../../reference/compound_stmts.rst:788 +#: ../../reference/compound_stmts.rst:791 msgid "OR Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:790 +#: ../../reference/compound_stmts.rst:793 msgid "" "An OR pattern is two or more patterns separated by vertical bars ``|``. " "Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:796 +#: ../../reference/compound_stmts.rst:799 msgid "" "Only the final subpattern may be :ref:`irrefutable `, and " "each subpattern must bind the same set of names to avoid ambiguity." msgstr "" -#: ../../reference/compound_stmts.rst:799 +#: ../../reference/compound_stmts.rst:802 msgid "" "An OR pattern matches each of its subpatterns in turn to the subject value, " "until one succeeds. The OR pattern is then considered successful. " "Otherwise, if none of the subpatterns succeed, the OR pattern fails." msgstr "" -#: ../../reference/compound_stmts.rst:803 +#: ../../reference/compound_stmts.rst:806 msgid "" "In simple terms, ``P1 | P2 | ...`` will try to match ``P1``, if it fails it " "will try to match ``P2``, succeeding immediately if any succeeds, failing " "otherwise." msgstr "" -#: ../../reference/compound_stmts.rst:809 +#: ../../reference/compound_stmts.rst:812 msgid "AS Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:811 +#: ../../reference/compound_stmts.rst:814 msgid "" "An AS pattern matches an OR pattern on the left of the :keyword:`as` keyword " "against a subject. Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:817 +#: ../../reference/compound_stmts.rst:820 msgid "" "If the OR pattern fails, the AS pattern fails. Otherwise, the AS pattern " "binds the subject to the name on the right of the as keyword and succeeds. " "``capture_pattern`` cannot be a ``_``." msgstr "" -#: ../../reference/compound_stmts.rst:821 +#: ../../reference/compound_stmts.rst:824 msgid "" "In simple terms ``P as NAME`` will match with ``P``, and on success it will " "set ``NAME = ``." msgstr "" -#: ../../reference/compound_stmts.rst:828 +#: ../../reference/compound_stmts.rst:831 msgid "Literal Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:830 +#: ../../reference/compound_stmts.rst:833 msgid "" "A literal pattern corresponds to most :ref:`literals ` in Python. " "Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:843 +#: ../../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 " @@ -1047,42 +1053,42 @@ msgid "" "are not supported." msgstr "" -#: ../../reference/compound_stmts.rst:848 +#: ../../reference/compound_stmts.rst:851 msgid "" "The forms ``signed_number '+' NUMBER`` and ``signed_number '-' NUMBER`` are " "for expressing :ref:`complex numbers `; they require a real " "number on the left and an imaginary number on the right. E.g. ``3 + 4j``." msgstr "" -#: ../../reference/compound_stmts.rst:852 +#: ../../reference/compound_stmts.rst:855 msgid "" "In simple terms, ``LITERAL`` will succeed only if `` == LITERAL``. " "For the singletons ``None``, ``True`` and ``False``, the :keyword:`is` " "operator is used." msgstr "" -#: ../../reference/compound_stmts.rst:858 +#: ../../reference/compound_stmts.rst:861 msgid "Capture Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:860 +#: ../../reference/compound_stmts.rst:863 msgid "A capture pattern binds the subject value to a name. Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:866 +#: ../../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`." msgstr "" -#: ../../reference/compound_stmts.rst:870 +#: ../../reference/compound_stmts.rst:873 msgid "" "In a given pattern, a given name can only be bound once. E.g. ``case x, " "x: ...`` is invalid while ``case [x] | x: ...`` is allowed." msgstr "" -#: ../../reference/compound_stmts.rst:873 +#: ../../reference/compound_stmts.rst:876 msgid "" "Capture patterns always succeed. The binding follows scoping rules " "established by the assignment expression operator in :pep:`572`; the name " @@ -1090,55 +1096,55 @@ msgid "" "there's an applicable :keyword:`global` or :keyword:`nonlocal` statement." msgstr "" -#: ../../reference/compound_stmts.rst:878 +#: ../../reference/compound_stmts.rst:881 msgid "" "In simple terms ``NAME`` will always succeed and it will set ``NAME = " "``." msgstr "" -#: ../../reference/compound_stmts.rst:883 +#: ../../reference/compound_stmts.rst:886 msgid "Wildcard Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:885 +#: ../../reference/compound_stmts.rst:888 msgid "" "A wildcard pattern always succeeds (matches anything) and binds no name. " "Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:891 +#: ../../reference/compound_stmts.rst:894 msgid "" "``_`` is a :ref:`soft keyword ` within any pattern, but only " "within patterns. It is an identifier, as usual, even within ``match`` " "subject expressions, ``guard``\\ s, and ``case`` blocks." msgstr "" -#: ../../reference/compound_stmts.rst:895 +#: ../../reference/compound_stmts.rst:898 msgid "In simple terms, ``_`` will always succeed." msgstr "" -#: ../../reference/compound_stmts.rst:900 +#: ../../reference/compound_stmts.rst:903 msgid "Value Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:902 +#: ../../reference/compound_stmts.rst:905 msgid "A value pattern represents a named value in Python. Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:910 +#: ../../reference/compound_stmts.rst:913 msgid "" "The dotted name in the pattern is looked up using standard Python :ref:`name " "resolution rules `. The pattern succeeds if the value found " "compares equal to the subject value (using the ``==`` equality operator)." msgstr "" -#: ../../reference/compound_stmts.rst:915 +#: ../../reference/compound_stmts.rst:918 msgid "" "In simple terms ``NAME1.NAME2`` will succeed only if `` == NAME1." "NAME2``" msgstr "" -#: ../../reference/compound_stmts.rst:919 +#: ../../reference/compound_stmts.rst:922 msgid "" "If the same value occurs multiple times in the same match statement, the " "interpreter may cache the first value found and reuse it rather than repeat " @@ -1146,44 +1152,44 @@ msgid "" "given match statement." msgstr "" -#: ../../reference/compound_stmts.rst:927 +#: ../../reference/compound_stmts.rst:930 msgid "Group Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:929 +#: ../../reference/compound_stmts.rst:932 msgid "" "A group pattern allows users to add parentheses around patterns to emphasize " "the intended grouping. Otherwise, it has no additional syntax. Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:936 +#: ../../reference/compound_stmts.rst:939 msgid "In simple terms ``(P)`` has the same effect as ``P``." msgstr "" -#: ../../reference/compound_stmts.rst:941 +#: ../../reference/compound_stmts.rst:944 msgid "Sequence Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:943 +#: ../../reference/compound_stmts.rst:946 msgid "" "A sequence pattern contains several subpatterns to be matched against " "sequence elements. The syntax is similar to the unpacking of a list or tuple." msgstr "" -#: ../../reference/compound_stmts.rst:954 +#: ../../reference/compound_stmts.rst:957 msgid "" "There is no difference if parentheses or square brackets are used for " "sequence patterns (i.e. ``(...)`` vs ``[...]`` )." msgstr "" -#: ../../reference/compound_stmts.rst:958 +#: ../../reference/compound_stmts.rst:961 msgid "" "A single pattern enclosed in parentheses without a trailing comma (e.g. ``(3 " "| 4)``) is a :ref:`group pattern `. While a single pattern " "enclosed in square brackets (e.g. ``[3 | 4]``) is still a sequence pattern." msgstr "" -#: ../../reference/compound_stmts.rst:963 +#: ../../reference/compound_stmts.rst:966 msgid "" "At most one star subpattern may be in a sequence pattern. The star " "subpattern may occur in any position. If no star subpattern is present, the " @@ -1191,40 +1197,40 @@ msgid "" "variable-length sequence pattern." msgstr "" -#: ../../reference/compound_stmts.rst:968 +#: ../../reference/compound_stmts.rst:971 msgid "" "The following is the logical flow for matching a sequence pattern against a " "subject value:" msgstr "" -#: ../../reference/compound_stmts.rst:971 +#: ../../reference/compound_stmts.rst:974 msgid "" "If the subject value is not a sequence [#]_, the sequence pattern fails." msgstr "" -#: ../../reference/compound_stmts.rst:974 +#: ../../reference/compound_stmts.rst:977 msgid "" "If the subject value is an instance of ``str``, ``bytes`` or ``bytearray`` " "the sequence pattern fails." msgstr "" -#: ../../reference/compound_stmts.rst:977 +#: ../../reference/compound_stmts.rst:980 msgid "" "The subsequent steps depend on whether the sequence pattern is fixed or " "variable-length." msgstr "" -#: ../../reference/compound_stmts.rst:980 +#: ../../reference/compound_stmts.rst:983 msgid "If the sequence pattern is fixed-length:" msgstr "" -#: ../../reference/compound_stmts.rst:982 +#: ../../reference/compound_stmts.rst:985 msgid "" "If the length of the subject sequence is not equal to the number of " "subpatterns, the sequence pattern fails" msgstr "" -#: ../../reference/compound_stmts.rst:985 +#: ../../reference/compound_stmts.rst:988 msgid "" "Subpatterns in the sequence pattern are matched to their corresponding items " "in the subject sequence from left to right. Matching stops as soon as a " @@ -1232,118 +1238,118 @@ msgid "" "corresponding item, the sequence pattern succeeds." msgstr "" -#: ../../reference/compound_stmts.rst:990 +#: ../../reference/compound_stmts.rst:993 msgid "Otherwise, if the sequence pattern is variable-length:" msgstr "" -#: ../../reference/compound_stmts.rst:992 +#: ../../reference/compound_stmts.rst:995 msgid "" "If the length of the subject sequence is less than the number of non-star " "subpatterns, the sequence pattern fails." msgstr "" -#: ../../reference/compound_stmts.rst:995 +#: ../../reference/compound_stmts.rst:998 msgid "" "The leading non-star subpatterns are matched to their corresponding items as " "for fixed-length sequences." msgstr "" -#: ../../reference/compound_stmts.rst:998 +#: ../../reference/compound_stmts.rst:1001 msgid "" "If the previous step succeeds, the star subpattern matches a list formed of " "the remaining subject items, excluding the remaining items corresponding to " "non-star subpatterns following the star subpattern." msgstr "" -#: ../../reference/compound_stmts.rst:1002 +#: ../../reference/compound_stmts.rst:1005 msgid "" "Remaining non-star subpatterns are matched to their corresponding subject " "items, as for a fixed-length sequence." msgstr "" -#: ../../reference/compound_stmts.rst:1005 +#: ../../reference/compound_stmts.rst:1008 msgid "" "The length of the subject sequence is obtained via :func:`len` (i.e. via " "the :meth:`__len__` protocol). This length may be cached by the interpreter " "in a similar manner as :ref:`value patterns `." msgstr "" -#: ../../reference/compound_stmts.rst:1011 +#: ../../reference/compound_stmts.rst:1014 msgid "" "In simple terms ``[P1, P2, P3,`` ... ``, P]`` matches only if all the " "following happens:" msgstr "" -#: ../../reference/compound_stmts.rst:1014 +#: ../../reference/compound_stmts.rst:1017 msgid "check ```` is a sequence" msgstr "" -#: ../../reference/compound_stmts.rst:1015 +#: ../../reference/compound_stmts.rst:1018 msgid "``len(subject) == ``" msgstr "``len(subject) == ``" -#: ../../reference/compound_stmts.rst:1016 +#: ../../reference/compound_stmts.rst:1019 msgid "" "``P1`` matches ``[0]`` (note that this match can also bind names)" msgstr "" -#: ../../reference/compound_stmts.rst:1017 +#: ../../reference/compound_stmts.rst:1020 msgid "" "``P2`` matches ``[1]`` (note that this match can also bind names)" msgstr "" -#: ../../reference/compound_stmts.rst:1018 +#: ../../reference/compound_stmts.rst:1021 msgid "... and so on for the corresponding pattern/element." msgstr "" -#: ../../reference/compound_stmts.rst:1023 +#: ../../reference/compound_stmts.rst:1026 msgid "Mapping Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:1025 +#: ../../reference/compound_stmts.rst:1028 msgid "" "A mapping pattern contains one or more key-value patterns. The syntax is " "similar to the construction of a dictionary. Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:1036 +#: ../../reference/compound_stmts.rst:1039 msgid "" "At most one double star pattern may be in a mapping pattern. The double " "star pattern must be the last subpattern in the mapping pattern." msgstr "" -#: ../../reference/compound_stmts.rst:1039 +#: ../../reference/compound_stmts.rst:1042 msgid "" "Duplicate keys in mapping patterns are disallowed. Duplicate literal keys " "will raise a :exc:`SyntaxError`. Two keys that otherwise have the same value " "will raise a :exc:`ValueError` at runtime." msgstr "" -#: ../../reference/compound_stmts.rst:1043 +#: ../../reference/compound_stmts.rst:1046 msgid "" "The following is the logical flow for matching a mapping pattern against a " "subject value:" msgstr "" -#: ../../reference/compound_stmts.rst:1046 +#: ../../reference/compound_stmts.rst:1049 msgid "If the subject value is not a mapping [#]_,the mapping pattern fails." msgstr "" -#: ../../reference/compound_stmts.rst:1048 +#: ../../reference/compound_stmts.rst:1051 msgid "" "If every key given in the mapping pattern is present in the subject mapping, " "and the pattern for each key matches the corresponding item of the subject " "mapping, the mapping pattern succeeds." msgstr "" -#: ../../reference/compound_stmts.rst:1052 +#: ../../reference/compound_stmts.rst:1055 msgid "" "If duplicate keys are detected in the mapping pattern, the pattern is " "considered invalid. A :exc:`SyntaxError` is raised for duplicate literal " "values; or a :exc:`ValueError` for named keys of the same value." msgstr "" -#: ../../reference/compound_stmts.rst:1056 +#: ../../reference/compound_stmts.rst:1059 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 " @@ -1351,256 +1357,256 @@ msgid "" "`~object.__getitem__`." msgstr "" -#: ../../reference/compound_stmts.rst:1061 +#: ../../reference/compound_stmts.rst:1064 msgid "" "In simple terms ``{KEY1: P1, KEY2: P2, ... }`` matches only if all the " "following happens:" msgstr "" -#: ../../reference/compound_stmts.rst:1064 +#: ../../reference/compound_stmts.rst:1067 msgid "check ```` is a mapping" msgstr "" -#: ../../reference/compound_stmts.rst:1065 +#: ../../reference/compound_stmts.rst:1068 msgid "``KEY1 in ``" msgstr "``KEY1 in ``" -#: ../../reference/compound_stmts.rst:1066 +#: ../../reference/compound_stmts.rst:1069 msgid "``P1`` matches ``[KEY1]``" msgstr "" -#: ../../reference/compound_stmts.rst:1067 +#: ../../reference/compound_stmts.rst:1070 msgid "... and so on for the corresponding KEY/pattern pair." msgstr "" -#: ../../reference/compound_stmts.rst:1073 +#: ../../reference/compound_stmts.rst:1076 msgid "Class Patterns" msgstr "" -#: ../../reference/compound_stmts.rst:1075 +#: ../../reference/compound_stmts.rst:1078 msgid "" "A class pattern represents a class and its positional and keyword arguments " "(if any). Syntax:" msgstr "" -#: ../../reference/compound_stmts.rst:1086 +#: ../../reference/compound_stmts.rst:1089 msgid "The same keyword should not be repeated in class patterns." msgstr "" -#: ../../reference/compound_stmts.rst:1088 +#: ../../reference/compound_stmts.rst:1091 msgid "" "The following is the logical flow for matching a class pattern against a " "subject value:" msgstr "" -#: ../../reference/compound_stmts.rst:1091 +#: ../../reference/compound_stmts.rst:1094 msgid "" "If ``name_or_attr`` is not an instance of the builtin :class:`type` , raise :" "exc:`TypeError`." msgstr "" -#: ../../reference/compound_stmts.rst:1094 +#: ../../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." msgstr "" -#: ../../reference/compound_stmts.rst:1097 +#: ../../reference/compound_stmts.rst:1100 msgid "" "If no pattern arguments are present, the pattern succeeds. Otherwise, the " "subsequent steps depend on whether keyword or positional argument patterns " "are present." msgstr "" -#: ../../reference/compound_stmts.rst:1101 +#: ../../reference/compound_stmts.rst:1104 msgid "" "For a number of built-in types (specified below), a single positional " "subpattern is accepted which will match the entire subject; for these types " "keyword patterns also work as for other types." msgstr "" -#: ../../reference/compound_stmts.rst:1105 +#: ../../reference/compound_stmts.rst:1108 msgid "" "If only keyword patterns are present, they are processed as follows, one by " "one:" msgstr "" -#: ../../reference/compound_stmts.rst:1108 +#: ../../reference/compound_stmts.rst:1111 msgid "I. The keyword is looked up as an attribute on the subject." msgstr "" -#: ../../reference/compound_stmts.rst:1110 +#: ../../reference/compound_stmts.rst:1113 msgid "" "If this raises an exception other than :exc:`AttributeError`, the exception " "bubbles up." msgstr "" -#: ../../reference/compound_stmts.rst:1113 +#: ../../reference/compound_stmts.rst:1116 msgid "If this raises :exc:`AttributeError`, the class pattern has failed." msgstr "" -#: ../../reference/compound_stmts.rst:1115 +#: ../../reference/compound_stmts.rst:1118 msgid "" "Else, the subpattern associated with the keyword pattern is matched against " "the subject's attribute value. If this fails, the class pattern fails; if " "this succeeds, the match proceeds to the next keyword." msgstr "" -#: ../../reference/compound_stmts.rst:1120 +#: ../../reference/compound_stmts.rst:1123 msgid "II. If all keyword patterns succeed, the class pattern succeeds." msgstr "" -#: ../../reference/compound_stmts.rst:1122 +#: ../../reference/compound_stmts.rst:1125 msgid "" "If any positional patterns are present, they are converted to keyword " "patterns using the :data:`~object.__match_args__` attribute on the class " "``name_or_attr`` before matching:" msgstr "" -#: ../../reference/compound_stmts.rst:1126 +#: ../../reference/compound_stmts.rst:1129 msgid "" "I. The equivalent of ``getattr(cls, \"__match_args__\", ())`` is called." msgstr "" -#: ../../reference/compound_stmts.rst:1128 +#: ../../reference/compound_stmts.rst:1131 msgid "If this raises an exception, the exception bubbles up." msgstr "" -#: ../../reference/compound_stmts.rst:1130 +#: ../../reference/compound_stmts.rst:1133 msgid "" "If the returned value is not a tuple, the conversion fails and :exc:" "`TypeError` is raised." msgstr "" -#: ../../reference/compound_stmts.rst:1133 +#: ../../reference/compound_stmts.rst:1136 msgid "" "If there are more positional patterns than ``len(cls.__match_args__)``, :exc:" "`TypeError` is raised." msgstr "" -#: ../../reference/compound_stmts.rst:1136 +#: ../../reference/compound_stmts.rst:1139 msgid "" "Otherwise, positional pattern ``i`` is converted to a keyword pattern using " "``__match_args__[i]`` as the keyword. ``__match_args__[i]`` must be a " "string; if not :exc:`TypeError` is raised." msgstr "" -#: ../../reference/compound_stmts.rst:1140 +#: ../../reference/compound_stmts.rst:1143 msgid "If there are duplicate keywords, :exc:`TypeError` is raised." msgstr "" -#: ../../reference/compound_stmts.rst:1142 +#: ../../reference/compound_stmts.rst:1145 msgid ":ref:`class-pattern-matching`" msgstr ":ref:`class-pattern-matching`" -#: ../../reference/compound_stmts.rst:1144 +#: ../../reference/compound_stmts.rst:1147 msgid "" "II. Once all positional patterns have been converted to keyword patterns," msgstr "" -#: ../../reference/compound_stmts.rst:1145 +#: ../../reference/compound_stmts.rst:1148 msgid "the match proceeds as if there were only keyword patterns." msgstr "" -#: ../../reference/compound_stmts.rst:1147 +#: ../../reference/compound_stmts.rst:1150 msgid "" "For the following built-in types the handling of positional subpatterns is " "different:" msgstr "" -#: ../../reference/compound_stmts.rst:1150 +#: ../../reference/compound_stmts.rst:1153 msgid ":class:`bool`" msgstr ":class:`bool`" -#: ../../reference/compound_stmts.rst:1151 +#: ../../reference/compound_stmts.rst:1154 msgid ":class:`bytearray`" msgstr ":class:`bytearray`" -#: ../../reference/compound_stmts.rst:1152 +#: ../../reference/compound_stmts.rst:1155 msgid ":class:`bytes`" msgstr ":class:`bytes`" -#: ../../reference/compound_stmts.rst:1153 +#: ../../reference/compound_stmts.rst:1156 msgid ":class:`dict`" msgstr ":class:`dict`" -#: ../../reference/compound_stmts.rst:1154 +#: ../../reference/compound_stmts.rst:1157 msgid ":class:`float`" msgstr ":class:`float`" -#: ../../reference/compound_stmts.rst:1155 +#: ../../reference/compound_stmts.rst:1158 msgid ":class:`frozenset`" msgstr ":class:`frozenset`" -#: ../../reference/compound_stmts.rst:1156 +#: ../../reference/compound_stmts.rst:1159 msgid ":class:`int`" msgstr ":class:`int`" -#: ../../reference/compound_stmts.rst:1157 -#: ../../reference/compound_stmts.rst:1875 +#: ../../reference/compound_stmts.rst:1160 +#: ../../reference/compound_stmts.rst:1878 msgid ":class:`list`" msgstr ":class:`list`" -#: ../../reference/compound_stmts.rst:1158 +#: ../../reference/compound_stmts.rst:1161 msgid ":class:`set`" msgstr ":class:`set`" -#: ../../reference/compound_stmts.rst:1159 +#: ../../reference/compound_stmts.rst:1162 msgid ":class:`str`" msgstr ":class:`str`" -#: ../../reference/compound_stmts.rst:1160 -#: ../../reference/compound_stmts.rst:1878 +#: ../../reference/compound_stmts.rst:1163 +#: ../../reference/compound_stmts.rst:1881 msgid ":class:`tuple`" msgstr ":class:`tuple`" -#: ../../reference/compound_stmts.rst:1162 +#: ../../reference/compound_stmts.rst:1165 msgid "" "These classes accept a single positional argument, and the pattern there is " "matched against the whole object rather than an attribute. For example " "``int(0|1)`` matches the value ``0``, but not the value ``0.0``." msgstr "" -#: ../../reference/compound_stmts.rst:1166 +#: ../../reference/compound_stmts.rst:1169 msgid "" "In simple terms ``CLS(P1, attr=P2)`` matches only if the following happens:" msgstr "" -#: ../../reference/compound_stmts.rst:1168 +#: ../../reference/compound_stmts.rst:1171 msgid "``isinstance(, CLS)``" msgstr "``isinstance(, CLS)``" -#: ../../reference/compound_stmts.rst:1169 +#: ../../reference/compound_stmts.rst:1172 msgid "convert ``P1`` to a keyword pattern using ``CLS.__match_args__``" msgstr "" -#: ../../reference/compound_stmts.rst:1170 +#: ../../reference/compound_stmts.rst:1173 msgid "For each keyword argument ``attr=P2``:" msgstr "" -#: ../../reference/compound_stmts.rst:1172 +#: ../../reference/compound_stmts.rst:1175 msgid "``hasattr(, \"attr\")``" msgstr "``hasattr(, \"attr\")``" -#: ../../reference/compound_stmts.rst:1173 +#: ../../reference/compound_stmts.rst:1176 msgid "``P2`` matches ``.attr``" msgstr "" -#: ../../reference/compound_stmts.rst:1175 +#: ../../reference/compound_stmts.rst:1178 msgid "... and so on for the corresponding keyword argument/pattern pair." msgstr "" -#: ../../reference/compound_stmts.rst:1190 +#: ../../reference/compound_stmts.rst:1193 msgid "Function definitions" msgstr "函式定義" -#: ../../reference/compound_stmts.rst:1205 +#: ../../reference/compound_stmts.rst:1208 msgid "" "A function definition defines a user-defined function object (see section :" "ref:`types`):" msgstr "" -#: ../../reference/compound_stmts.rst:1225 +#: ../../reference/compound_stmts.rst:1228 msgid "" "A function definition is an executable statement. Its execution binds the " "function name in the current local namespace to a function object (a wrapper " @@ -1609,13 +1615,13 @@ msgid "" "used when the function is called." msgstr "" -#: ../../reference/compound_stmts.rst:1231 +#: ../../reference/compound_stmts.rst:1234 msgid "" "The function definition does not execute the function body; this gets " "executed only when the function is called. [#]_" msgstr "" -#: ../../reference/compound_stmts.rst:1237 +#: ../../reference/compound_stmts.rst:1240 msgid "" "A function definition may be wrapped by one or more :term:`decorator` " "expressions. Decorator expressions are evaluated when the function is " @@ -1626,7 +1632,7 @@ msgid "" "example, the following code ::" msgstr "" -#: ../../reference/compound_stmts.rst:1244 +#: ../../reference/compound_stmts.rst:1247 msgid "" "@f1(arg)\n" "@f2\n" @@ -1636,12 +1642,12 @@ msgstr "" "@f2\n" "def func(): pass" -#: ../../reference/compound_stmts.rst:1248 -#: ../../reference/compound_stmts.rst:1443 +#: ../../reference/compound_stmts.rst:1251 +#: ../../reference/compound_stmts.rst:1446 msgid "is roughly equivalent to ::" msgstr "大致等價於: ::" -#: ../../reference/compound_stmts.rst:1250 +#: ../../reference/compound_stmts.rst:1253 msgid "" "def func(): pass\n" "func = f1(arg)(f2(func))" @@ -1649,20 +1655,20 @@ msgstr "" "def func(): pass\n" "func = f1(arg)(f2(func))" -#: ../../reference/compound_stmts.rst:1253 +#: ../../reference/compound_stmts.rst:1256 msgid "" "except that the original function is not temporarily bound to the name " "``func``." msgstr "" -#: ../../reference/compound_stmts.rst:1255 +#: ../../reference/compound_stmts.rst:1258 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." msgstr "" -#: ../../reference/compound_stmts.rst:1260 +#: ../../reference/compound_stmts.rst:1263 msgid "" "A list of :ref:`type parameters ` may be given in square " "brackets between the function's name and the opening parenthesis for its " @@ -1672,12 +1678,12 @@ msgid "" "functions` for more." msgstr "" -#: ../../reference/compound_stmts.rst:1267 -#: ../../reference/compound_stmts.rst:1462 +#: ../../reference/compound_stmts.rst:1270 +#: ../../reference/compound_stmts.rst:1465 msgid "Type parameter lists are new in Python 3.12." msgstr "" -#: ../../reference/compound_stmts.rst:1275 +#: ../../reference/compound_stmts.rst:1278 msgid "" "When one or more :term:`parameters ` have the form *parameter* " "``=`` *expression*, the function is said to have \"default parameter values." @@ -1688,7 +1694,7 @@ msgid "" "syntactic restriction that is not expressed by the grammar." msgstr "" -#: ../../reference/compound_stmts.rst:1283 +#: ../../reference/compound_stmts.rst:1286 msgid "" "**Default parameter values are evaluated from left to right when the " "function definition is executed.** This means that the expression is " @@ -1701,7 +1707,7 @@ msgid "" "the default, and explicitly test for it in the body of the function, e.g.::" msgstr "" -#: ../../reference/compound_stmts.rst:1293 +#: ../../reference/compound_stmts.rst:1296 msgid "" "def whats_on_the_telly(penguin=None):\n" " if penguin is None:\n" @@ -1710,7 +1716,7 @@ msgid "" " return penguin" msgstr "" -#: ../../reference/compound_stmts.rst:1304 +#: ../../reference/compound_stmts.rst:1307 msgid "" "Function call semantics are described in more detail in section :ref:" "`calls`. A function call always assigns values to all parameters mentioned " @@ -1726,13 +1732,13 @@ msgid "" "positional arguments." msgstr "" -#: ../../reference/compound_stmts.rst:1316 +#: ../../reference/compound_stmts.rst:1319 msgid "" "The ``/`` function parameter syntax may be used to indicate positional-only " "parameters. See :pep:`570` for details." msgstr "" -#: ../../reference/compound_stmts.rst:1325 +#: ../../reference/compound_stmts.rst:1328 msgid "" "Parameters may have an :term:`annotation ` of the form " "\"``: expression``\" following the parameter name. Any parameter may have " @@ -1751,13 +1757,13 @@ msgid "" "in the source code." msgstr "" -#: ../../reference/compound_stmts.rst:1339 +#: ../../reference/compound_stmts.rst:1342 msgid "" "Parameters of the form \"``*identifier``\" may have an annotation \"``: " "*expression``\". See :pep:`646`." msgstr "" -#: ../../reference/compound_stmts.rst:1345 +#: ../../reference/compound_stmts.rst:1348 msgid "" "It is also possible to create anonymous functions (functions not bound to a " "name), for immediate use in expressions. This uses lambda expressions, " @@ -1769,7 +1775,7 @@ msgid "" "execution of multiple statements and annotations." msgstr "" -#: ../../reference/compound_stmts.rst:1353 +#: ../../reference/compound_stmts.rst:1356 msgid "" "**Programmer's note:** Functions are first-class objects. A \"``def``\" " "statement executed inside a function definition defines a local function " @@ -1778,61 +1784,61 @@ msgid "" "See section :ref:`naming` for details." msgstr "" -#: ../../reference/compound_stmts.rst:1361 +#: ../../reference/compound_stmts.rst:1364 msgid ":pep:`3107` - Function Annotations" msgstr "" -#: ../../reference/compound_stmts.rst:1362 +#: ../../reference/compound_stmts.rst:1365 msgid "The original specification for function annotations." msgstr "" -#: ../../reference/compound_stmts.rst:1364 +#: ../../reference/compound_stmts.rst:1367 msgid ":pep:`484` - Type Hints" msgstr "" -#: ../../reference/compound_stmts.rst:1365 +#: ../../reference/compound_stmts.rst:1368 msgid "Definition of a standard meaning for annotations: type hints." msgstr "" -#: ../../reference/compound_stmts.rst:1367 +#: ../../reference/compound_stmts.rst:1370 msgid ":pep:`526` - Syntax for Variable Annotations" msgstr "" -#: ../../reference/compound_stmts.rst:1368 +#: ../../reference/compound_stmts.rst:1371 msgid "" "Ability to type hint variable declarations, including class variables and " "instance variables." msgstr "" -#: ../../reference/compound_stmts.rst:1371 +#: ../../reference/compound_stmts.rst:1374 msgid ":pep:`563` - Postponed Evaluation of Annotations" msgstr "" -#: ../../reference/compound_stmts.rst:1372 +#: ../../reference/compound_stmts.rst:1375 msgid "" "Support for forward references within annotations by preserving annotations " "in a string form at runtime instead of eager evaluation." msgstr "" -#: ../../reference/compound_stmts.rst:1375 +#: ../../reference/compound_stmts.rst:1378 msgid ":pep:`318` - Decorators for Functions and Methods" msgstr "" -#: ../../reference/compound_stmts.rst:1376 +#: ../../reference/compound_stmts.rst:1379 msgid "" "Function and method decorators were introduced. Class decorators were " "introduced in :pep:`3129`." msgstr "" -#: ../../reference/compound_stmts.rst:1382 +#: ../../reference/compound_stmts.rst:1385 msgid "Class definitions" msgstr "類別定義" -#: ../../reference/compound_stmts.rst:1397 +#: ../../reference/compound_stmts.rst:1400 msgid "A class definition defines a class object (see section :ref:`types`):" msgstr "" -#: ../../reference/compound_stmts.rst:1404 +#: ../../reference/compound_stmts.rst:1407 msgid "" "A class definition is an executable statement. The inheritance list usually " "gives a list of base classes (see :ref:`metaclasses` for more advanced " @@ -1841,7 +1847,7 @@ msgid "" "default, from the base class :class:`object`; hence, ::" msgstr "" -#: ../../reference/compound_stmts.rst:1410 +#: ../../reference/compound_stmts.rst:1413 msgid "" "class Foo:\n" " pass" @@ -1849,11 +1855,11 @@ msgstr "" "class Foo:\n" " pass" -#: ../../reference/compound_stmts.rst:1413 +#: ../../reference/compound_stmts.rst:1416 msgid "is equivalent to ::" msgstr "" -#: ../../reference/compound_stmts.rst:1415 +#: ../../reference/compound_stmts.rst:1418 msgid "" "class Foo(object):\n" " pass" @@ -1861,7 +1867,7 @@ msgstr "" "class Foo(object):\n" " pass" -#: ../../reference/compound_stmts.rst:1418 +#: ../../reference/compound_stmts.rst:1421 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 " @@ -1873,7 +1879,7 @@ msgid "" "original local namespace." msgstr "" -#: ../../reference/compound_stmts.rst:1427 +#: ../../reference/compound_stmts.rst:1430 msgid "" "The order in which attributes are defined in the class body is preserved in " "the new class's :attr:`~type.__dict__`. Note that this is reliable only " @@ -1881,17 +1887,17 @@ msgid "" "using the definition syntax." msgstr "" -#: ../../reference/compound_stmts.rst:1432 +#: ../../reference/compound_stmts.rst:1435 msgid "" "Class creation can be customized heavily using :ref:`metaclasses " "`." msgstr "" -#: ../../reference/compound_stmts.rst:1437 +#: ../../reference/compound_stmts.rst:1440 msgid "Classes can also be decorated: just like when decorating functions, ::" msgstr "" -#: ../../reference/compound_stmts.rst:1439 +#: ../../reference/compound_stmts.rst:1442 msgid "" "@f1(arg)\n" "@f2\n" @@ -1901,7 +1907,7 @@ msgstr "" "@f2\n" "class Foo: pass" -#: ../../reference/compound_stmts.rst:1445 +#: ../../reference/compound_stmts.rst:1448 msgid "" "class Foo: pass\n" "Foo = f1(arg)(f2(Foo))" @@ -1909,20 +1915,20 @@ msgstr "" "class Foo: pass\n" "Foo = f1(arg)(f2(Foo))" -#: ../../reference/compound_stmts.rst:1448 +#: ../../reference/compound_stmts.rst:1451 msgid "" "The evaluation rules for the decorator expressions are the same as for " "function decorators. The result is then bound to the class name." msgstr "" -#: ../../reference/compound_stmts.rst:1451 +#: ../../reference/compound_stmts.rst:1454 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." msgstr "" -#: ../../reference/compound_stmts.rst:1456 +#: ../../reference/compound_stmts.rst:1459 msgid "" "A list of :ref:`type parameters ` may be given in square " "brackets immediately after the class's name. This indicates to static type " @@ -1931,7 +1937,7 @@ msgid "" "`generic-classes` for more." msgstr "" -#: ../../reference/compound_stmts.rst:1465 +#: ../../reference/compound_stmts.rst:1468 msgid "" "**Programmer's note:** Variables defined in the class definition are class " "attributes; they are shared by instances. Instance attributes can be set in " @@ -1944,35 +1950,35 @@ msgid "" "implementation details." msgstr "" -#: ../../reference/compound_stmts.rst:1477 +#: ../../reference/compound_stmts.rst:1480 msgid ":pep:`3115` - Metaclasses in Python 3000" msgstr "" -#: ../../reference/compound_stmts.rst:1478 +#: ../../reference/compound_stmts.rst:1481 msgid "" "The proposal that changed the declaration of metaclasses to the current " "syntax, and the semantics for how classes with metaclasses are constructed." msgstr "" -#: ../../reference/compound_stmts.rst:1482 +#: ../../reference/compound_stmts.rst:1485 msgid ":pep:`3129` - Class Decorators" msgstr ":pep:`3129` - 類別裝飾器" -#: ../../reference/compound_stmts.rst:1483 +#: ../../reference/compound_stmts.rst:1486 msgid "" "The proposal that added class decorators. Function and method decorators " "were introduced in :pep:`318`." msgstr "" -#: ../../reference/compound_stmts.rst:1490 +#: ../../reference/compound_stmts.rst:1493 msgid "Coroutines" msgstr "協程" -#: ../../reference/compound_stmts.rst:1498 +#: ../../reference/compound_stmts.rst:1501 msgid "Coroutine function definition" msgstr "協程函式定義" -#: ../../reference/compound_stmts.rst:1508 +#: ../../reference/compound_stmts.rst:1511 msgid "" "Execution of Python coroutines can be suspended and resumed at many points " "(see :term:`coroutine`). :keyword:`await` expressions, :keyword:`async for` " @@ -1980,23 +1986,23 @@ msgid "" "function." msgstr "" -#: ../../reference/compound_stmts.rst:1512 +#: ../../reference/compound_stmts.rst:1515 msgid "" "Functions defined with ``async def`` syntax are always coroutine functions, " "even if they do not contain ``await`` or ``async`` keywords." msgstr "" -#: ../../reference/compound_stmts.rst:1515 +#: ../../reference/compound_stmts.rst:1518 msgid "" "It is a :exc:`SyntaxError` to use a ``yield from`` expression inside the " "body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1518 +#: ../../reference/compound_stmts.rst:1521 msgid "An example of a coroutine function::" msgstr "一個協程函式範例: ::" -#: ../../reference/compound_stmts.rst:1520 +#: ../../reference/compound_stmts.rst:1523 msgid "" "async def func(param1, param2):\n" " do_stuff()\n" @@ -2006,30 +2012,30 @@ msgstr "" " do_stuff()\n" " await some_coroutine()" -#: ../../reference/compound_stmts.rst:1524 +#: ../../reference/compound_stmts.rst:1527 msgid "" "``await`` and ``async`` are now keywords; previously they were only treated " "as such inside the body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1532 +#: ../../reference/compound_stmts.rst:1535 msgid "The :keyword:`!async for` statement" msgstr ":keyword:`!async for` 陳述式" -#: ../../reference/compound_stmts.rst:1537 +#: ../../reference/compound_stmts.rst:1540 msgid "" "An :term:`asynchronous iterable` provides an ``__aiter__`` method that " "directly returns an :term:`asynchronous iterator`, which can call " "asynchronous code in its ``__anext__`` method." msgstr "" -#: ../../reference/compound_stmts.rst:1541 +#: ../../reference/compound_stmts.rst:1544 msgid "" "The ``async for`` statement allows convenient iteration over asynchronous " "iterables." msgstr "" -#: ../../reference/compound_stmts.rst:1546 +#: ../../reference/compound_stmts.rst:1549 msgid "" "async for TARGET in ITER:\n" " SUITE\n" @@ -2041,11 +2047,11 @@ msgstr "" "else:\n" " SUITE2" -#: ../../reference/compound_stmts.rst:1551 +#: ../../reference/compound_stmts.rst:1554 msgid "Is semantically equivalent to::" msgstr "" -#: ../../reference/compound_stmts.rst:1553 +#: ../../reference/compound_stmts.rst:1556 msgid "" "iter = (ITER)\n" "iter = type(iter).__aiter__(iter)\n" @@ -2075,28 +2081,28 @@ msgstr "" "else:\n" " SUITE2" -#: ../../reference/compound_stmts.rst:1567 +#: ../../reference/compound_stmts.rst:1570 msgid "" "See also :meth:`~object.__aiter__` and :meth:`~object.__anext__` for details." msgstr "更多細節請見 :meth:`~object.__aiter__` 與 :meth:`~object.__anext__`。" -#: ../../reference/compound_stmts.rst:1569 +#: ../../reference/compound_stmts.rst:1572 msgid "" "It is a :exc:`SyntaxError` to use an ``async for`` statement outside the " "body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1577 +#: ../../reference/compound_stmts.rst:1580 msgid "The :keyword:`!async with` statement" msgstr ":keyword:`!async with` 陳述式" -#: ../../reference/compound_stmts.rst:1582 +#: ../../reference/compound_stmts.rst:1585 msgid "" "An :term:`asynchronous context manager` is a :term:`context manager` that is " "able to suspend execution in its *enter* and *exit* methods." msgstr "" -#: ../../reference/compound_stmts.rst:1587 +#: ../../reference/compound_stmts.rst:1590 msgid "" "async with EXPRESSION as TARGET:\n" " SUITE" @@ -2104,7 +2110,7 @@ msgstr "" "async with EXPRESSION as TARGET:\n" " SUITE" -#: ../../reference/compound_stmts.rst:1592 +#: ../../reference/compound_stmts.rst:1595 msgid "" "manager = (EXPRESSION)\n" "aenter = type(manager).__aenter__\n" @@ -2140,44 +2146,44 @@ msgstr "" " if not hit_except:\n" " await aexit(manager, None, None, None)" -#: ../../reference/compound_stmts.rst:1609 +#: ../../reference/compound_stmts.rst:1612 msgid "" "See also :meth:`~object.__aenter__` and :meth:`~object.__aexit__` for " "details." msgstr "更多細節請見 :meth:`~object.__aenter__` 與 :meth:`~object.__aexit__`。" -#: ../../reference/compound_stmts.rst:1611 +#: ../../reference/compound_stmts.rst:1614 msgid "" "It is a :exc:`SyntaxError` to use an ``async with`` statement outside the " "body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1616 +#: ../../reference/compound_stmts.rst:1619 msgid ":pep:`492` - Coroutines with async and await syntax" msgstr "" -#: ../../reference/compound_stmts.rst:1617 +#: ../../reference/compound_stmts.rst:1620 msgid "" "The proposal that made coroutines a proper standalone concept in Python, and " "added supporting syntax." msgstr "" -#: ../../reference/compound_stmts.rst:1623 +#: ../../reference/compound_stmts.rst:1626 msgid "Type parameter lists" msgstr "" -#: ../../reference/compound_stmts.rst:1627 +#: ../../reference/compound_stmts.rst:1630 msgid "Support for default values was added (see :pep:`696`)." msgstr "" -#: ../../reference/compound_stmts.rst:1640 +#: ../../reference/compound_stmts.rst:1643 msgid "" ":ref:`Functions ` (including :ref:`coroutines `), :ref:" "`classes ` and :ref:`type aliases ` may contain a type " "parameter list::" msgstr "" -#: ../../reference/compound_stmts.rst:1644 +#: ../../reference/compound_stmts.rst:1647 msgid "" "def max[T](args: list[T]) -> T:\n" " ...\n" @@ -2209,7 +2215,7 @@ msgstr "" "\n" "type ListOrSet[T] = list[T] | set[T]" -#: ../../reference/compound_stmts.rst:1659 +#: ../../reference/compound_stmts.rst:1662 msgid "" "Semantically, this indicates that the function, class, or type alias is " "generic over a type variable. This information is primarily used by static " @@ -2217,7 +2223,7 @@ msgid "" "generic counterparts." msgstr "" -#: ../../reference/compound_stmts.rst:1664 +#: ../../reference/compound_stmts.rst:1667 msgid "" "Type parameters are declared in square brackets (``[]``) immediately after " "the name of the function, class, or type alias. The type parameters are " @@ -2229,36 +2235,36 @@ msgid "" "wraps the creation of the generic object." msgstr "" -#: ../../reference/compound_stmts.rst:1673 +#: ../../reference/compound_stmts.rst:1676 msgid "" "Generic functions, classes, and type aliases have a :attr:`~definition." "__type_params__` attribute listing their type parameters." msgstr "" -#: ../../reference/compound_stmts.rst:1676 +#: ../../reference/compound_stmts.rst:1679 msgid "Type parameters come in three kinds:" msgstr "" -#: ../../reference/compound_stmts.rst:1678 +#: ../../reference/compound_stmts.rst:1681 msgid "" ":data:`typing.TypeVar`, introduced by a plain name (e.g., ``T``). " "Semantically, this represents a single type to a type checker." msgstr "" -#: ../../reference/compound_stmts.rst:1680 +#: ../../reference/compound_stmts.rst:1683 msgid "" ":data:`typing.TypeVarTuple`, introduced by a name prefixed with a single " "asterisk (e.g., ``*Ts``). Semantically, this stands for a tuple of any " "number of types." msgstr "" -#: ../../reference/compound_stmts.rst:1683 +#: ../../reference/compound_stmts.rst:1686 msgid "" ":data:`typing.ParamSpec`, introduced by a name prefixed with two asterisks " "(e.g., ``**P``). Semantically, this stands for the parameters of a callable." msgstr "" -#: ../../reference/compound_stmts.rst:1686 +#: ../../reference/compound_stmts.rst:1689 msgid "" ":data:`typing.TypeVar` declarations can define *bounds* and *constraints* " "with a colon (``:``) followed by an expression. A single expression after " @@ -2270,7 +2276,7 @@ msgid "" "variables can only take on one of the types in the list of constraints." msgstr "" -#: ../../reference/compound_stmts.rst:1695 +#: ../../reference/compound_stmts.rst:1698 msgid "" "For :data:`!typing.TypeVar`\\ s declared using the type parameter list " "syntax, the bound and constraints are not evaluated when the generic object " @@ -2280,13 +2286,13 @@ msgid "" "`." msgstr "" -#: ../../reference/compound_stmts.rst:1701 +#: ../../reference/compound_stmts.rst:1704 msgid "" ":data:`typing.TypeVarTuple`\\ s and :data:`typing.ParamSpec`\\ s cannot have " "bounds or constraints." msgstr "" -#: ../../reference/compound_stmts.rst:1704 +#: ../../reference/compound_stmts.rst:1707 msgid "" "All three flavors of type parameters can also have a *default value*, which " "is used when the type parameter is not explicitly provided. This is added by " @@ -2299,13 +2305,13 @@ msgid "" "attribute is set to the special sentinel object :data:`typing.NoDefault`." msgstr "" -#: ../../reference/compound_stmts.rst:1714 +#: ../../reference/compound_stmts.rst:1717 msgid "" "The following example indicates the full set of allowed type parameter " "declarations::" msgstr "" -#: ../../reference/compound_stmts.rst:1716 +#: ../../reference/compound_stmts.rst:1719 msgid "" "def overly_generic[\n" " SimpleTypeVar,\n" @@ -2337,24 +2343,24 @@ msgstr "" " *e: SimpleTypeVarTuple,\n" "): ..." -#: ../../reference/compound_stmts.rst:1734 +#: ../../reference/compound_stmts.rst:1737 msgid "Generic functions" msgstr "" -#: ../../reference/compound_stmts.rst:1736 +#: ../../reference/compound_stmts.rst:1739 msgid "Generic functions are declared as follows::" msgstr "" -#: ../../reference/compound_stmts.rst:1738 +#: ../../reference/compound_stmts.rst:1741 msgid "def func[T](arg: T): ..." msgstr "def func[T](arg: T): ..." -#: ../../reference/compound_stmts.rst:1740 -#: ../../reference/compound_stmts.rst:1800 +#: ../../reference/compound_stmts.rst:1743 +#: ../../reference/compound_stmts.rst:1803 msgid "This syntax is equivalent to::" msgstr "語法大致等價於: ::" -#: ../../reference/compound_stmts.rst:1742 +#: ../../reference/compound_stmts.rst:1745 msgid "" "annotation-def TYPE_PARAMS_OF_func():\n" " T = typing.TypeVar(\"T\")\n" @@ -2370,7 +2376,7 @@ msgstr "" " return func\n" "func = TYPE_PARAMS_OF_func()" -#: ../../reference/compound_stmts.rst:1749 +#: ../../reference/compound_stmts.rst:1752 msgid "" "Here ``annotation-def`` indicates an :ref:`annotation scope `, which is not actually bound to any name at runtime. (One other " @@ -2379,20 +2385,20 @@ msgid "" "data:`typing.TypeVar` directly.)" msgstr "" -#: ../../reference/compound_stmts.rst:1755 +#: ../../reference/compound_stmts.rst:1758 msgid "" "The annotations of generic functions are evaluated within the annotation " "scope used for declaring the type parameters, but the function's defaults " "and decorators are not." msgstr "" -#: ../../reference/compound_stmts.rst:1759 +#: ../../reference/compound_stmts.rst:1762 msgid "" "The following example illustrates the scoping rules for these cases, as well " "as for additional flavors of type parameters::" msgstr "" -#: ../../reference/compound_stmts.rst:1762 +#: ../../reference/compound_stmts.rst:1765 msgid "" "@decorator\n" "def func[T: int, *Ts, **P](*args: *Ts, arg: Callable[P, T] = some_default):\n" @@ -2402,13 +2408,13 @@ msgstr "" "def func[T: int, *Ts, **P](*args: *Ts, arg: Callable[P, T] = some_default):\n" " ..." -#: ../../reference/compound_stmts.rst:1766 +#: ../../reference/compound_stmts.rst:1769 msgid "" "Except for the :ref:`lazy evaluation ` of the :class:" "`~typing.TypeVar` bound, this is equivalent to::" msgstr "" -#: ../../reference/compound_stmts.rst:1769 +#: ../../reference/compound_stmts.rst:1772 msgid "" "DEFAULT_OF_arg = some_default\n" "\n" @@ -2430,25 +2436,25 @@ msgid "" "func = decorator(TYPE_PARAMS_OF_func())" msgstr "" -#: ../../reference/compound_stmts.rst:1788 +#: ../../reference/compound_stmts.rst:1791 msgid "" "The capitalized names like ``DEFAULT_OF_arg`` are not actually bound at " "runtime." msgstr "" -#: ../../reference/compound_stmts.rst:1794 +#: ../../reference/compound_stmts.rst:1797 msgid "Generic classes" msgstr "" -#: ../../reference/compound_stmts.rst:1796 +#: ../../reference/compound_stmts.rst:1799 msgid "Generic classes are declared as follows::" msgstr "" -#: ../../reference/compound_stmts.rst:1798 +#: ../../reference/compound_stmts.rst:1801 msgid "class Bag[T]: ..." msgstr "class Bag[T]: ..." -#: ../../reference/compound_stmts.rst:1802 +#: ../../reference/compound_stmts.rst:1805 msgid "" "annotation-def TYPE_PARAMS_OF_Bag():\n" " T = typing.TypeVar(\"T\")\n" @@ -2466,14 +2472,14 @@ msgstr "" " return Bag\n" "Bag = TYPE_PARAMS_OF_Bag()" -#: ../../reference/compound_stmts.rst:1810 +#: ../../reference/compound_stmts.rst:1813 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." msgstr "" -#: ../../reference/compound_stmts.rst:1814 +#: ../../reference/compound_stmts.rst:1817 msgid "" "Generic classes implicitly inherit from :data:`typing.Generic`. The base " "classes and keyword arguments of generic classes are evaluated within the " @@ -2481,7 +2487,7 @@ msgid "" "that scope. This is illustrated by this example::" msgstr "" -#: ../../reference/compound_stmts.rst:1820 +#: ../../reference/compound_stmts.rst:1823 msgid "" "@decorator\n" "class Bag(Base[T], arg=T): ..." @@ -2489,11 +2495,11 @@ msgstr "" "@decorator\n" "class Bag(Base[T], arg=T): ..." -#: ../../reference/compound_stmts.rst:1823 +#: ../../reference/compound_stmts.rst:1826 msgid "This is equivalent to::" msgstr "這等價於: ::" -#: ../../reference/compound_stmts.rst:1825 +#: ../../reference/compound_stmts.rst:1828 msgid "" "annotation-def TYPE_PARAMS_OF_Bag():\n" " T = typing.TypeVar(\"T\")\n" @@ -2511,27 +2517,27 @@ msgstr "" " return Bag\n" "Bag = decorator(TYPE_PARAMS_OF_Bag())" -#: ../../reference/compound_stmts.rst:1836 +#: ../../reference/compound_stmts.rst:1839 msgid "Generic type aliases" msgstr "" -#: ../../reference/compound_stmts.rst:1838 +#: ../../reference/compound_stmts.rst:1841 msgid "" "The :keyword:`type` statement can also be used to create a generic type " "alias::" msgstr "" -#: ../../reference/compound_stmts.rst:1840 +#: ../../reference/compound_stmts.rst:1843 msgid "type ListOrSet[T] = list[T] | set[T]" msgstr "type ListOrSet[T] = list[T] | set[T]" -#: ../../reference/compound_stmts.rst:1842 +#: ../../reference/compound_stmts.rst:1845 msgid "" "Except for the :ref:`lazy evaluation ` of the value, this " "is equivalent to::" msgstr "" -#: ../../reference/compound_stmts.rst:1845 +#: ../../reference/compound_stmts.rst:1848 msgid "" "annotation-def TYPE_PARAMS_OF_ListOrSet():\n" " T = typing.TypeVar(\"T\")\n" @@ -2544,105 +2550,105 @@ msgid "" "ListOrSet = TYPE_PARAMS_OF_ListOrSet()" msgstr "" -#: ../../reference/compound_stmts.rst:1854 +#: ../../reference/compound_stmts.rst:1857 msgid "" "Here, ``annotation-def`` (not a real keyword) indicates an :ref:`annotation " "scope `. The capitalized names like " "``TYPE_PARAMS_OF_ListOrSet`` are not actually bound at runtime." msgstr "" -#: ../../reference/compound_stmts.rst:1859 +#: ../../reference/compound_stmts.rst:1862 msgid "Footnotes" msgstr "註解" -#: ../../reference/compound_stmts.rst:1860 +#: ../../reference/compound_stmts.rst:1863 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." msgstr "" -#: ../../reference/compound_stmts.rst:1864 +#: ../../reference/compound_stmts.rst:1867 msgid "In pattern matching, a sequence is defined as one of the following:" msgstr "" -#: ../../reference/compound_stmts.rst:1866 +#: ../../reference/compound_stmts.rst:1869 msgid "a class that inherits from :class:`collections.abc.Sequence`" msgstr "" -#: ../../reference/compound_stmts.rst:1867 +#: ../../reference/compound_stmts.rst:1870 msgid "" "a Python class that has been registered as :class:`collections.abc.Sequence`" msgstr "" -#: ../../reference/compound_stmts.rst:1868 +#: ../../reference/compound_stmts.rst:1871 msgid "" "a builtin class that has its (CPython) :c:macro:`Py_TPFLAGS_SEQUENCE` bit set" msgstr "" -#: ../../reference/compound_stmts.rst:1869 -#: ../../reference/compound_stmts.rst:1888 +#: ../../reference/compound_stmts.rst:1872 +#: ../../reference/compound_stmts.rst:1891 msgid "a class that inherits from any of the above" msgstr "" -#: ../../reference/compound_stmts.rst:1871 +#: ../../reference/compound_stmts.rst:1874 msgid "The following standard library classes are sequences:" msgstr "" -#: ../../reference/compound_stmts.rst:1873 +#: ../../reference/compound_stmts.rst:1876 msgid ":class:`array.array`" msgstr ":class:`array.array`" -#: ../../reference/compound_stmts.rst:1874 +#: ../../reference/compound_stmts.rst:1877 msgid ":class:`collections.deque`" msgstr ":class:`collections.deque`" -#: ../../reference/compound_stmts.rst:1876 +#: ../../reference/compound_stmts.rst:1879 msgid ":class:`memoryview`" msgstr ":class:`memoryview`" -#: ../../reference/compound_stmts.rst:1877 +#: ../../reference/compound_stmts.rst:1880 msgid ":class:`range`" msgstr ":class:`range`" -#: ../../reference/compound_stmts.rst:1880 +#: ../../reference/compound_stmts.rst:1883 msgid "" "Subject values of type ``str``, ``bytes``, and ``bytearray`` do not match " "sequence patterns." msgstr "" -#: ../../reference/compound_stmts.rst:1883 +#: ../../reference/compound_stmts.rst:1886 msgid "In pattern matching, a mapping is defined as one of the following:" msgstr "" -#: ../../reference/compound_stmts.rst:1885 +#: ../../reference/compound_stmts.rst:1888 msgid "a class that inherits from :class:`collections.abc.Mapping`" msgstr "" -#: ../../reference/compound_stmts.rst:1886 +#: ../../reference/compound_stmts.rst:1889 msgid "" "a Python class that has been registered as :class:`collections.abc.Mapping`" msgstr "" -#: ../../reference/compound_stmts.rst:1887 +#: ../../reference/compound_stmts.rst:1890 msgid "" "a builtin class that has its (CPython) :c:macro:`Py_TPFLAGS_MAPPING` bit set" msgstr "" -#: ../../reference/compound_stmts.rst:1890 +#: ../../reference/compound_stmts.rst:1893 msgid "" "The standard library classes :class:`dict` and :class:`types." "MappingProxyType` are mappings." msgstr "" -#: ../../reference/compound_stmts.rst:1893 +#: ../../reference/compound_stmts.rst:1896 msgid "" "A string literal appearing as the first statement in the function body is " "transformed into the function's :attr:`~function.__doc__` attribute and " "therefore the function's :term:`docstring`." msgstr "" -#: ../../reference/compound_stmts.rst:1897 +#: ../../reference/compound_stmts.rst:1900 msgid "" "A string literal appearing as the first statement in the class body is " "transformed into the namespace's :attr:`~type.__doc__` item and therefore " @@ -2662,12 +2668,12 @@ msgstr "compound(複合)" #: ../../reference/compound_stmts.rst:390 #: ../../reference/compound_stmts.rst:437 #: ../../reference/compound_stmts.rst:471 -#: ../../reference/compound_stmts.rst:585 -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 -#: ../../reference/compound_stmts.rst:1494 -#: ../../reference/compound_stmts.rst:1528 -#: ../../reference/compound_stmts.rst:1573 +#: ../../reference/compound_stmts.rst:588 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 +#: ../../reference/compound_stmts.rst:1497 +#: ../../reference/compound_stmts.rst:1531 +#: ../../reference/compound_stmts.rst:1576 msgid "statement" msgstr "statement(陳述式)" @@ -2703,7 +2709,7 @@ msgstr "" msgid "else" msgstr "else" -#: ../../reference/compound_stmts.rst:86 ../../reference/compound_stmts.rst:585 +#: ../../reference/compound_stmts.rst:86 ../../reference/compound_stmts.rst:588 msgid "if" msgstr "if" @@ -2714,8 +2720,8 @@ msgstr "if" #: ../../reference/compound_stmts.rst:390 #: ../../reference/compound_stmts.rst:408 #: ../../reference/compound_stmts.rst:471 -#: ../../reference/compound_stmts.rst:585 -#: ../../reference/compound_stmts.rst:1504 +#: ../../reference/compound_stmts.rst:588 +#: ../../reference/compound_stmts.rst:1507 msgid "keyword" msgstr "keyword(關鍵字)" @@ -2727,10 +2733,10 @@ msgstr "elif" #: ../../reference/compound_stmts.rst:144 #: ../../reference/compound_stmts.rst:207 #: ../../reference/compound_stmts.rst:471 -#: ../../reference/compound_stmts.rst:585 -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1320 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:588 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1323 +#: ../../reference/compound_stmts.rst:1387 msgid ": (colon)" msgstr ": (冒號)" @@ -2738,9 +2744,9 @@ msgstr ": (冒號)" #: ../../reference/compound_stmts.rst:144 #: ../../reference/compound_stmts.rst:207 #: ../../reference/compound_stmts.rst:471 -#: ../../reference/compound_stmts.rst:585 -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:588 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 msgid "compound statement" msgstr "compound statement(複合陳述式)" @@ -2785,8 +2791,8 @@ msgstr "list(串列)" #: ../../reference/compound_stmts.rst:144 #: ../../reference/compound_stmts.rst:298 -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 msgid "object" msgstr "object(物件)" @@ -2818,7 +2824,7 @@ msgstr "finally" #: ../../reference/compound_stmts.rst:207 #: ../../reference/compound_stmts.rst:265 #: ../../reference/compound_stmts.rst:471 -#: ../../reference/compound_stmts.rst:585 +#: ../../reference/compound_stmts.rst:588 msgid "as" msgstr "as" @@ -2856,199 +2862,199 @@ msgid "with statement" msgstr "with statement(with 陳述式)" #: ../../reference/compound_stmts.rst:471 -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 msgid ", (comma)" msgstr ", (逗號)" -#: ../../reference/compound_stmts.rst:585 +#: ../../reference/compound_stmts.rst:588 msgid "match" msgstr "match" -#: ../../reference/compound_stmts.rst:585 +#: ../../reference/compound_stmts.rst:588 msgid "case" msgstr "case" -#: ../../reference/compound_stmts.rst:585 +#: ../../reference/compound_stmts.rst:588 msgid "pattern matching" msgstr "pattern matching(模式匹配)" -#: ../../reference/compound_stmts.rst:585 +#: ../../reference/compound_stmts.rst:588 msgid "match statement" msgstr "match statement(匹配陳述式)" -#: ../../reference/compound_stmts.rst:689 +#: ../../reference/compound_stmts.rst:692 msgid "guard" msgstr "guard" -#: ../../reference/compound_stmts.rst:728 +#: ../../reference/compound_stmts.rst:731 msgid "irrefutable case block" msgstr "" -#: ../../reference/compound_stmts.rst:728 +#: ../../reference/compound_stmts.rst:731 msgid "case block" msgstr "" -#: ../../reference/compound_stmts.rst:752 +#: ../../reference/compound_stmts.rst:755 msgid "! patterns" msgstr "" -#: ../../reference/compound_stmts.rst:752 +#: ../../reference/compound_stmts.rst:755 msgid "AS pattern, OR pattern, capture pattern, wildcard pattern" msgstr "" -#: ../../reference/compound_stmts.rst:1183 -#: ../../reference/compound_stmts.rst:1270 +#: ../../reference/compound_stmts.rst:1186 +#: ../../reference/compound_stmts.rst:1273 msgid "parameter" msgstr "parameter(參數)" -#: ../../reference/compound_stmts.rst:1183 -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1234 -#: ../../reference/compound_stmts.rst:1270 -#: ../../reference/compound_stmts.rst:1299 +#: ../../reference/compound_stmts.rst:1186 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1237 +#: ../../reference/compound_stmts.rst:1273 +#: ../../reference/compound_stmts.rst:1302 msgid "function definition" msgstr "function definition(函式定義)" -#: ../../reference/compound_stmts.rst:1192 +#: ../../reference/compound_stmts.rst:1195 msgid "def" msgstr "def" -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1320 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1323 msgid "function" msgstr "function (函式)" -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 msgid "definition" msgstr "definition(定義)" -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 msgid "name" msgstr "name(名稱)" -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 msgid "binding" msgstr "binding(綁定)" -#: ../../reference/compound_stmts.rst:1192 +#: ../../reference/compound_stmts.rst:1195 msgid "user-defined function" msgstr "user-defined function(使用者定義函式)" -#: ../../reference/compound_stmts.rst:1192 -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1387 msgid "() (parentheses)" msgstr "() (圓括號)" -#: ../../reference/compound_stmts.rst:1192 +#: ../../reference/compound_stmts.rst:1195 msgid "parameter list" msgstr "parameter list(參數列表)" -#: ../../reference/compound_stmts.rst:1234 -#: ../../reference/compound_stmts.rst:1434 +#: ../../reference/compound_stmts.rst:1237 +#: ../../reference/compound_stmts.rst:1437 msgid "@ (at)" msgstr "@ (在)" -#: ../../reference/compound_stmts.rst:1270 +#: ../../reference/compound_stmts.rst:1273 msgid "default" msgstr "default(預設)" -#: ../../reference/compound_stmts.rst:1270 +#: ../../reference/compound_stmts.rst:1273 msgid "value" msgstr "value(值)" -#: ../../reference/compound_stmts.rst:1270 +#: ../../reference/compound_stmts.rst:1273 msgid "argument" msgstr "argument(引數)" -#: ../../reference/compound_stmts.rst:1270 +#: ../../reference/compound_stmts.rst:1273 msgid "= (equals)" msgstr "= (等於)" -#: ../../reference/compound_stmts.rst:1299 +#: ../../reference/compound_stmts.rst:1302 msgid "/ (slash)" msgstr "/ (斜線)" -#: ../../reference/compound_stmts.rst:1299 +#: ../../reference/compound_stmts.rst:1302 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../reference/compound_stmts.rst:1299 +#: ../../reference/compound_stmts.rst:1302 msgid "**" msgstr "**" -#: ../../reference/compound_stmts.rst:1320 +#: ../../reference/compound_stmts.rst:1323 msgid "annotations" msgstr "annotations(註釋)" -#: ../../reference/compound_stmts.rst:1320 +#: ../../reference/compound_stmts.rst:1323 msgid "->" msgstr "->" -#: ../../reference/compound_stmts.rst:1320 +#: ../../reference/compound_stmts.rst:1323 msgid "function annotations" msgstr "function annotations(函式註釋)" -#: ../../reference/compound_stmts.rst:1343 +#: ../../reference/compound_stmts.rst:1346 msgid "lambda" msgstr "lambda" -#: ../../reference/compound_stmts.rst:1343 +#: ../../reference/compound_stmts.rst:1346 msgid "expression" msgstr "expression(運算式)" -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1387 msgid "class" msgstr "class(類別)" -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1387 msgid "execution" msgstr "execution(執行)" -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1387 msgid "frame" msgstr "frame" -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1387 msgid "inheritance" msgstr "inheritance(繼承)" -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1387 msgid "docstring" msgstr "docstring(說明字串)" -#: ../../reference/compound_stmts.rst:1384 -#: ../../reference/compound_stmts.rst:1434 +#: ../../reference/compound_stmts.rst:1387 +#: ../../reference/compound_stmts.rst:1437 msgid "class definition" msgstr "class definition(類別定義)" -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1387 msgid "expression list" msgstr "expression list(表達式列表)" -#: ../../reference/compound_stmts.rst:1494 +#: ../../reference/compound_stmts.rst:1497 msgid "async def" msgstr "async def" -#: ../../reference/compound_stmts.rst:1504 +#: ../../reference/compound_stmts.rst:1507 msgid "async" msgstr "async" -#: ../../reference/compound_stmts.rst:1504 +#: ../../reference/compound_stmts.rst:1507 msgid "await" msgstr "await" -#: ../../reference/compound_stmts.rst:1528 +#: ../../reference/compound_stmts.rst:1531 msgid "async for" msgstr "async for" -#: ../../reference/compound_stmts.rst:1573 +#: ../../reference/compound_stmts.rst:1576 msgid "async with" msgstr "async with" -#: ../../reference/compound_stmts.rst:1630 +#: ../../reference/compound_stmts.rst:1633 msgid "type parameters" msgstr "type parameter(型別參數)" diff --git a/tutorial/index.po b/tutorial/index.po index 47eb0a648b..1ed8787fa7 100644 --- a/tutorial/index.po +++ b/tutorial/index.po @@ -59,7 +59,7 @@ msgid "" msgstr "" "使用 C 或 C++(或其他可被 C 呼叫的程式語言),可以很容易在 Python 直譯器內新" "增功能函式及資料型別。同時,對可讓使用者自製功能的應用程式來說,Python 也適合" -"作為其擴充用界面語言 (extension language)。" +"作為其擴充用介面語言 (extension language)。" #: ../../tutorial/index.rst:23 msgid "" diff --git a/whatsnew/3.10.po b/whatsnew/3.10.po index ee2fe63fc7..44170c01ff 100644 --- a/whatsnew/3.10.po +++ b/whatsnew/3.10.po @@ -849,7 +849,7 @@ msgid "" "of the subject's type and shape." msgstr "" "雖然使用巢狀 \"if\" 陳述式的「命令式 (imperative)」指令系列可用於完成類似於結" -"構模式匹配的操作,但它不如「聲明式 (declarative)」方法清晰。相反地,「聲明" +"構模式匹配的操作,但它不如「宣告式 (declarative)」方法清晰。相反地,「聲明" "式」方法規定了匹配所需滿足的條件,並且因其明確表達模式而更具可讀性。雖然結構" "模式匹配可以用其最簡單的形式達成,將變數與 case 陳述式中的字面值進行比較,但" "它對 Python 的真正價值在於它對主語的型態和特徵的處理。" @@ -2486,7 +2486,7 @@ msgid "" "Add ``--quiet`` option to command-line interface of :mod:`py_compile`. " "(Contributed by Gregory Schevchenko in :issue:`38731`.)" msgstr "" -"將 ``--quiet`` 選項新增到 :mod:`py_compile` 的命令列界面。(由 Gregory " +"將 ``--quiet`` 選項新增到 :mod:`py_compile` 的命令列介面。(由 Gregory " "Schevchenko 在 :issue:`38731` 中貢獻。)" #: ../../whatsnew/3.10.rst:1316 diff --git a/whatsnew/3.12.po b/whatsnew/3.12.po index 3202bc30a7..8bddce6733 100644 --- a/whatsnew/3.12.po +++ b/whatsnew/3.12.po @@ -521,6 +521,16 @@ msgid "" "}\n" "/* The new interpreter is now active in the current thread. */" msgstr "" +"PyInterpreterConfig config = {\n" +" .check_multi_interp_extensions = 1,\n" +" .gil = PyInterpreterConfig_OWN_GIL,\n" +"};\n" +"PyThreadState *tstate = NULL;\n" +"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n" +"if (PyStatus_Exception(status)) {\n" +" return -1;\n" +"}\n" +"/* 新的直譯器現在會在當前執行緒中啟用。 */" #: ../../whatsnew/3.12.rst:361 msgid "" @@ -1021,12 +1031,16 @@ msgid "" ":func:`importlib.resources.as_file` now supports resource directories. " "(Contributed by Jason R. Coombs in :gh:`97930`.)" msgstr "" +":func:`importlib.resources.as_file` 現在支援資源目錄。(由 Jason R. Coombs " +"於 :gh:`97930` 中貢獻。)" #: ../../whatsnew/3.12.rst:721 msgid "" "Rename first parameter of :func:`importlib.resources.files` to *anchor*. " "(Contributed by Jason R. Coombs in :gh:`100598`.)" msgstr "" +"將 :func:`importlib.resources.files` 的第一個參數重新命名為 *anchor*。(由 " +"Jason R. Coombs 於 :gh:`100598` 中貢獻。)" #: ../../whatsnew/3.12.rst:725 msgid "inspect" @@ -1038,6 +1052,9 @@ msgid "" "a :term:`coroutine` for use with :func:`inspect.iscoroutinefunction`. " "(Contributed by Carlton Gibson in :gh:`99247`.)" msgstr "" +"新增 :func:`inspect.markcoroutinefunction` 以標記會回傳 :term:`coroutine` 的" +"同步函式,以供 :func:`inspect.iscoroutinefunction` 使用。(由 Carlton Gibson " +"於 :gh:`99247` 中貢獻。)" #: ../../whatsnew/3.12.rst:731 msgid "" @@ -1045,6 +1062,9 @@ msgid "" "for determining the current state of asynchronous generators. (Contributed " "by Thomas Krennwallner in :gh:`79940`.)" msgstr "" +"新增 :func:`inspect.getasyncgenstate` 和 :func:`inspect.getasyncgenlocals` 以" +"確定非同步產生器的當前狀態。(由 Thomas Krennwallner 於 :gh:`79940` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:735 msgid "" @@ -1052,6 +1072,8 @@ msgid "" "improved. Most calls to the function should be at least 2x faster than they " "were in Python 3.11. (Contributed by Alex Waygood in :gh:`103193`.)" msgstr "" +":func:`inspect.getattr_static` 的效能已大幅改善。大多數對該函式的呼叫應該比 " +"Python 3.11 中快至少 2 倍。(由 Alex Waygood 於 :gh:`103193` 中貢獻。)" #: ../../whatsnew/3.12.rst:740 msgid "itertools" @@ -1063,6 +1085,8 @@ msgid "" "the last batch may be shorter than the rest. (Contributed by Raymond " "Hettinger in :gh:`98363`.)" msgstr "" +"新增 :func:`itertools.batched` 以將元素收集到大小均等的元組中,其中最後一批次" +"可能比其他的少。(由 Raymond Hettinger 於 :gh:`98363` 中貢獻。)" #: ../../whatsnew/3.12.rst:747 msgid "math" @@ -1130,12 +1154,16 @@ msgid "" "Add :func:`os.path.isjunction` to check if a given path is a junction. " "(Contributed by Charles Machalow in :gh:`99547`.)" msgstr "" +"新增 :func:`os.path.isjunction` 以檢查給定路徑是否為連結點 (junction)。(由 " +"Charles Machalow 於 :gh:`99547` 中貢獻。)" #: ../../whatsnew/3.12.rst:787 msgid "" "Add :func:`os.path.splitroot` to split a path into a triad ``(drive, root, " "tail)``. (Contributed by Barney Gale in :gh:`101000`.)" msgstr "" +"新增 :func:`os.path.splitroot` 以將路徑分割為三元組 ``(drive, root, tail)``。" +"(由 Barney Gale 於 :gh:`101000` 中貢獻。)" #: ../../whatsnew/3.12.rst:791 msgid "pathlib" @@ -1455,6 +1483,22 @@ msgid "" "attribute\n" "True" msgstr "" +">>> from typing import Protocol, runtime_checkable\n" +">>> @runtime_checkable\n" +"... class HasX(Protocol):\n" +"... x = 1\n" +"...\n" +">>> class Foo: ...\n" +"...\n" +">>> f = Foo()\n" +">>> isinstance(f, HasX)\n" +"False\n" +">>> f.x = 1\n" +">>> isinstance(f, HasX)\n" +"True\n" +">>> HasX.y = 2\n" +">>> isinstance(f, HasX) # 沒有改變,即便 HasX 現在有 \"y\" 屬性\n" +"True" #: ../../whatsnew/3.12.rst:1001 msgid "" @@ -1584,6 +1628,8 @@ msgid "" "Speed up :class:`asyncio.Task` creation by deferring expensive string " "formatting. (Contributed by Itamar Oren in :gh:`103793`.)" msgstr "" +"透過延遲運算較繁重的字串格式化來加速 :class:`asyncio.Task` 的建立。(由 " +"Itamar Oren 於 :gh:`103793` 中貢獻。)" #: ../../whatsnew/3.12.rst:1072 msgid "" @@ -1611,6 +1657,9 @@ msgid "" "`!LOAD_METHOD` instruction if the low bit of its oparg is set. (Contributed " "by Ken Jin in :gh:`93429`.)" msgstr "" +"移除 :opcode:`!LOAD_METHOD` 指令。它已經合併至 :opcode:`LOAD_ATTR`。:opcode:" +"`LOAD_ATTR` 現在會像舊的 :opcode:`!LOAD_METHOD` 指令一樣行為,如果其 oparg 的" +"低位元 (low bit) 有被設定。(由 Ken Jin 於 :gh:`93429` 中貢獻。)" #: ../../whatsnew/3.12.rst:1090 msgid "" @@ -1618,54 +1667,70 @@ msgid "" "JUMP_IF_TRUE_OR_POP` instructions. (Contributed by Irit Katriel in :gh:" "`102859`.)" msgstr "" +"移除 :opcode:`!JUMP_IF_FALSE_OR_POP` 和 :opcode:`!JUMP_IF_TRUE_OR_POP` 指令。" +"(由 Irit Katriel 於 :gh:`102859` 中貢獻。)" #: ../../whatsnew/3.12.rst:1093 msgid "" "Remove the :opcode:`!PRECALL` instruction. (Contributed by Mark Shannon in :" "gh:`92925`.)" msgstr "" +"移除 :opcode:`!PRECALL` 指令。(由 Mark Shannon 於 :gh:`92925` 中貢獻。)" #: ../../whatsnew/3.12.rst:1096 msgid "" "Add the :opcode:`BINARY_SLICE` and :opcode:`STORE_SLICE` instructions. " "(Contributed by Mark Shannon in :gh:`94163`.)" msgstr "" +"新增 :opcode:`BINARY_SLICE` 和 :opcode:`STORE_SLICE` 指令。(由 Mark Shannon " +"於 :gh:`94163` 中貢獻。)" #: ../../whatsnew/3.12.rst:1099 msgid "" "Add the :opcode:`CALL_INTRINSIC_1` instructions. (Contributed by Mark " "Shannon in :gh:`99005`.)" msgstr "" +"新增 :opcode:`CALL_INTRINSIC_1` 指令。(由 Mark Shannon 於 :gh:`99005` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1102 msgid "" "Add the :opcode:`CALL_INTRINSIC_2` instruction. (Contributed by Irit Katriel " "in :gh:`101799`.)" msgstr "" +"新增 :opcode:`CALL_INTRINSIC_2` 指令。(由 Irit Katriel 於 :gh:`101799` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1105 msgid "" "Add the :opcode:`CLEANUP_THROW` instruction. (Contributed by Brandt Bucher " "in :gh:`90997`.)" msgstr "" +"新增 :opcode:`CLEANUP_THROW` 指令。(由 Brandt Bucher 於 :gh:`90997` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1108 msgid "" "Add the :opcode:`!END_SEND` instruction. (Contributed by Mark Shannon in :gh:" "`103082`.)" msgstr "" +"新增 :opcode:`!END_SEND` 指令。(由 Mark Shannon 於 :gh:`103082` 中貢獻。)" #: ../../whatsnew/3.12.rst:1111 msgid "" "Add the :opcode:`LOAD_FAST_AND_CLEAR` instruction as part of the " "implementation of :pep:`709`. (Contributed by Carl Meyer in :gh:`101441`.)" msgstr "" +"新增 :opcode:`LOAD_FAST_AND_CLEAR` 指令作為 :pep:`709` 實作的一部分。(由 " +"Carl Meyer 於 :gh:`101441` 中貢獻。)" #: ../../whatsnew/3.12.rst:1114 msgid "" "Add the :opcode:`LOAD_FAST_CHECK` instruction. (Contributed by Dennis " "Sweeney in :gh:`93143`.)" msgstr "" +"新增 :opcode:`LOAD_FAST_CHECK` 指令。(由 Dennis Sweeney 於 :gh:`93143` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1117 msgid "" @@ -1675,18 +1740,27 @@ msgid "" "opcode, which can be replaced with :opcode:`LOAD_LOCALS` plus :opcode:" "`LOAD_FROM_DICT_OR_DEREF`. (Contributed by Jelle Zijlstra in :gh:`103764`.)" msgstr "" +"新增 :opcode:`LOAD_FROM_DICT_OR_DEREF`、:opcode:`LOAD_FROM_DICT_OR_GLOBALS` " +"和 :opcode:`LOAD_LOCALS` 操作碼作為 :pep:`695` 實作的一部分。移除 :opcode:`!" +"LOAD_CLASSDEREF` 操作碼,可以用 :opcode:`LOAD_LOCALS` 加上 :opcode:" +"`LOAD_FROM_DICT_OR_DEREF` 來取代。(由 Jelle Zijlstra 於 :gh:`103764` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1123 msgid "" "Add the :opcode:`LOAD_SUPER_ATTR` instruction. (Contributed by Carl Meyer " "and Vladimir Matveev in :gh:`103497`.)" msgstr "" +"新增 :opcode:`LOAD_SUPER_ATTR` 指令。(由 Carl Meyer 和 Vladimir Matveev 於 :" +"gh:`103497` 中貢獻。)" #: ../../whatsnew/3.12.rst:1126 msgid "" "Add the :opcode:`RETURN_CONST` instruction. (Contributed by Wenyang Wang in :" "gh:`101632`.)" msgstr "" +"新增 :opcode:`RETURN_CONST` 指令。(由 Wenyang Wang 於 :gh:`101632` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1129 msgid "Demos and Tools" @@ -1728,6 +1802,9 @@ msgid "" "emitted at runtime when they are accessed or used, and will be removed in " "Python 3.14:" msgstr "" +":mod:`ast`:以下 :mod:`ast` 功能自 Python 3.8 起已在文件中被棄用,現在在存取" +"或使用時會在 runtime 發出 :exc:`DeprecationWarning`,並將在 Python 3.14 中移" +"除:" #: ../../whatsnew/3.12.rst:1154 #: ../../deprecations/pending-removal-in-3.14.rst:13 @@ -3096,6 +3173,7 @@ msgid "" "Several names deprecated in the :mod:`configparser` way back in 3.2 have " "been removed per :gh:`89336`:" msgstr "" +"根據 :gh:`89336`,已移除了在 3.2 中被 :mod:`configparser` 棄用的幾個名稱:" #: ../../whatsnew/3.12.rst:1364 msgid "" @@ -3110,12 +3188,16 @@ msgid "" ":mod:`configparser` no longer has a ``SafeConfigParser`` class. Use the " "shorter :class:`~configparser.ConfigParser` name instead." msgstr "" +":mod:`configparser` 不再具有 ``SafeConfigParser`` 類別。請改用較短的 :class:" +"`~configparser.ConfigParser` 名稱。" #: ../../whatsnew/3.12.rst:1368 msgid "" ":class:`configparser.ConfigParser` no longer has a ``readfp`` method. Use :" "meth:`~configparser.ConfigParser.read_file` instead." msgstr "" +":class:`configparser.ConfigParser` 不再具有 ``readfp`` 方法。請改用 :meth:" +"`~configparser.ConfigParser.read_file`。" #: ../../whatsnew/3.12.rst:1374 msgid "distutils" @@ -3171,6 +3253,8 @@ msgid "" "Remove :mod:`enum`'s ``EnumMeta.__getattr__``, which is no longer needed for " "enum attribute access. (Contributed by Ethan Furman in :gh:`95083`.)" msgstr "" +"移除 :mod:`enum` 的 ``EnumMeta.__getattr__``,對於列舉屬性的訪問不再會需要" +"它。" #: ../../whatsnew/3.12.rst:1411 msgid "ftplib" @@ -3255,11 +3339,11 @@ msgstr "imp" msgid "" "The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in :" "gh:`98040`.)" -msgstr "" +msgstr ":mod:`!imp` 模組已被移除。(由 Barry Warsaw 在 :gh:`98040` 中貢獻。)" #: ../../whatsnew/3.12.rst:1462 msgid "To migrate, consult the following correspondence table:" -msgstr "" +msgstr "要遷移的話請參考以下對應表:" #: ../../whatsnew/3.12.rst:1467 msgid "``imp.NullImporter``" @@ -3302,6 +3386,8 @@ msgid "" ":attr:`importlib.machinery.SOURCE_SUFFIXES`, :attr:`importlib.machinery." "EXTENSION_SUFFIXES`, and :attr:`importlib.machinery.BYTECODE_SUFFIXES`" msgstr "" +":attr:`importlib.machinery.SOURCE_SUFFIXES`、:attr:`importlib.machinery." +"EXTENSION_SUFFIXES` 和 :attr:`importlib.machinery.BYTECODE_SUFFIXES`" #: ../../whatsnew/3.12.rst:1472 msgid "``imp.get_tag()``" @@ -3371,6 +3457,19 @@ msgid "" " loader.exec_module(module)\n" " return module" msgstr "" +"import importlib.util\n" +"import importlib.machinery\n" +"\n" +"def load_source(modname, filename):\n" +" loader = importlib.machinery.SourceFileLoader(modname, filename)\n" +" spec = importlib.util.spec_from_file_location(modname, filename, " +"loader=loader)\n" +" module = importlib.util.module_from_spec(spec)\n" +" # 此模組都會被執行且不會被快取於 sys.modules。\n" +" # 要快取模組的話可以把下面一行取消註解\n" +" # sys.modules[module.__name__] = module\n" +" loader.exec_module(module)\n" +" return module" #: ../../whatsnew/3.12.rst:1495 msgid "Remove :mod:`!imp` functions and attributes with no replacements:" @@ -3672,6 +3771,8 @@ msgid "" "An alias of the :class:`~unittest.TextTestResult` class: ``_TextTestResult`` " "(deprecated in Python 3.2)." msgstr "" +"對 :class:`~unittest.TextTestResult` 類別的別名:``_TextTestResult``\\ (自 " +"Python 3.2 起已棄用)。" #: ../../whatsnew/3.12.rst:1617 msgid "(Contributed by Serhiy Storchaka in :gh:`89325`.)" @@ -4802,6 +4903,9 @@ msgid "" "func:`PyType_FromModuleAndSpec` to create a class whose metaclass overrides :" "c:member:`~PyTypeObject.tp_new` is deprecated. Call the metaclass instead." msgstr "" +"使用 :c:func:`PyType_FromSpec`、:c:func:`PyType_FromSpecWithBases` 或 :c:" +"func:`PyType_FromModuleAndSpec` 建立一個其元類別覆寫 :c:member:" +"`~PyTypeObject.tp_new` 的類別已被棄用。請改為呼叫元類別。" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:4 msgid "" diff --git a/whatsnew/3.13.po b/whatsnew/3.13.po index ea9bec402b..8515c9a886 100644 --- a/whatsnew/3.13.po +++ b/whatsnew/3.13.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-15 00:14+0000\n" +"POT-Creation-Date: 2024-12-29 11:18+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-" @@ -345,7 +345,7 @@ msgid "" "years of security fixes." msgstr "" -#: ../../whatsnew/3.13.rst:208 ../../whatsnew/3.13.rst:1970 +#: ../../whatsnew/3.13.rst:208 ../../whatsnew/3.13.rst:1985 msgid "New Features" msgstr "新增功能" @@ -1163,7 +1163,7 @@ msgid "compileall" msgstr "compileall" #: ../../whatsnew/3.13.rst:757 ../../whatsnew/3.13.rst:765 -#: ../../whatsnew/3.13.rst:1017 +#: ../../whatsnew/3.13.rst:1024 msgid "" "The default number of worker threads and processes is now selected using :" "func:`os.process_cpu_count` instead of :func:`os.cpu_count`. (Contributed by " @@ -1174,7 +1174,7 @@ msgstr "" msgid "concurrent.futures" msgstr "concurrent.futures" -#: ../../whatsnew/3.13.rst:771 ../../whatsnew/3.13.rst:1614 +#: ../../whatsnew/3.13.rst:771 ../../whatsnew/3.13.rst:1621 msgid "configparser" msgstr "configparser" @@ -1356,10 +1356,21 @@ msgid "" msgstr "" #: ../../whatsnew/3.13.rst:893 +msgid "enum" +msgstr "enum" + +#: ../../whatsnew/3.13.rst:895 +msgid "" +":class:`~enum.EnumDict` has been made public to better support subclassing :" +"class:`~enum.EnumType`." +msgstr "" +"公開 :class:`~enum.EnumDict` 以更好地支援 :class:`~enum.EnumType` 的子類別。" + +#: ../../whatsnew/3.13.rst:900 msgid "fractions" msgstr "fractions" -#: ../../whatsnew/3.13.rst:895 +#: ../../whatsnew/3.13.rst:902 msgid "" ":class:`~fractions.Fraction` objects now support the standard :ref:`format " "specification mini-language ` rules for fill, alignment, sign " @@ -1367,22 +1378,22 @@ msgid "" "`111320`.)" msgstr "" -#: ../../whatsnew/3.13.rst:902 +#: ../../whatsnew/3.13.rst:909 msgid "glob" msgstr "glob" -#: ../../whatsnew/3.13.rst:904 +#: ../../whatsnew/3.13.rst:911 msgid "" "Add :func:`~glob.translate`, a function to convert a path specification with " "shell-style wildcards to a regular expression. (Contributed by Barney Gale " "in :gh:`72904`.)" msgstr "" -#: ../../whatsnew/3.13.rst:910 +#: ../../whatsnew/3.13.rst:917 msgid "importlib" msgstr "importlib" -#: ../../whatsnew/3.13.rst:912 +#: ../../whatsnew/3.13.rst:919 msgid "" "The following functions in :mod:`importlib.resources` now allow accessing a " "directory (or tree) of resources, using multiple positional arguments (the " @@ -1390,37 +1401,37 @@ msgid "" "keyword-only):" msgstr "" -#: ../../whatsnew/3.13.rst:917 +#: ../../whatsnew/3.13.rst:924 msgid ":func:`~importlib.resources.is_resource`" msgstr ":func:`~importlib.resources.is_resource`" -#: ../../whatsnew/3.13.rst:918 +#: ../../whatsnew/3.13.rst:925 msgid ":func:`~importlib.resources.open_binary`" msgstr ":func:`~importlib.resources.open_binary`" -#: ../../whatsnew/3.13.rst:919 +#: ../../whatsnew/3.13.rst:926 msgid ":func:`~importlib.resources.open_text`" msgstr ":func:`~importlib.resources.open_text`" -#: ../../whatsnew/3.13.rst:920 +#: ../../whatsnew/3.13.rst:927 msgid ":func:`~importlib.resources.path`" msgstr ":func:`~importlib.resources.path`" -#: ../../whatsnew/3.13.rst:921 +#: ../../whatsnew/3.13.rst:928 msgid ":func:`~importlib.resources.read_binary`" msgstr ":func:`~importlib.resources.read_binary`" -#: ../../whatsnew/3.13.rst:922 +#: ../../whatsnew/3.13.rst:929 msgid ":func:`~importlib.resources.read_text`" msgstr ":func:`~importlib.resources.read_text`" -#: ../../whatsnew/3.13.rst:924 +#: ../../whatsnew/3.13.rst:931 msgid "" "These functions are no longer deprecated and are not scheduled for removal. " "(Contributed by Petr Viktorin in :gh:`116608`.)" msgstr "" -#: ../../whatsnew/3.13.rst:927 +#: ../../whatsnew/3.13.rst:934 msgid "" ":func:`~importlib.resources.contents` remains deprecated in favor of the " "fully-featured :class:`~importlib.resources.abc.Traversable` API. However, " @@ -1428,11 +1439,11 @@ msgid "" "`116608`.)" msgstr "" -#: ../../whatsnew/3.13.rst:934 +#: ../../whatsnew/3.13.rst:941 msgid "io" msgstr "io" -#: ../../whatsnew/3.13.rst:936 +#: ../../whatsnew/3.13.rst:943 msgid "" "The :class:`~io.IOBase` finalizer now logs any errors raised by the :meth:" "`~io.IOBase.close` method with :data:`sys.unraisablehook`. Previously, " @@ -1441,17 +1452,17 @@ msgid "" "build>`. (Contributed by Victor Stinner in :gh:`62948`.)" msgstr "" -#: ../../whatsnew/3.13.rst:945 +#: ../../whatsnew/3.13.rst:952 msgid "ipaddress" msgstr "ipaddress" -#: ../../whatsnew/3.13.rst:947 +#: ../../whatsnew/3.13.rst:954 msgid "" "Add the :attr:`.IPv4Address.ipv6_mapped` property, which returns the IPv4-" "mapped IPv6 address. (Contributed by Charles Machalow in :gh:`109466`.)" msgstr "" -#: ../../whatsnew/3.13.rst:951 +#: ../../whatsnew/3.13.rst:958 msgid "" "Fix ``is_global`` and ``is_private`` behavior in :class:`~ipaddress." "IPv4Address`, :class:`~ipaddress.IPv6Address`, :class:`~ipaddress." @@ -1459,22 +1470,22 @@ msgid "" "Stasiak in :gh:`113171`.)" msgstr "" -#: ../../whatsnew/3.13.rst:958 +#: ../../whatsnew/3.13.rst:965 msgid "itertools" msgstr "itertools" -#: ../../whatsnew/3.13.rst:960 +#: ../../whatsnew/3.13.rst:967 msgid "" ":func:`~itertools.batched` has a new *strict* parameter, which raises a :exc:" "`ValueError` if the final batch is shorter than the specified batch size. " "(Contributed by Raymond Hettinger in :gh:`113202`.)" msgstr "" -#: ../../whatsnew/3.13.rst:967 +#: ../../whatsnew/3.13.rst:974 msgid "marshal" msgstr "marshal" -#: ../../whatsnew/3.13.rst:969 +#: ../../whatsnew/3.13.rst:976 msgid "" "Add the *allow_code* parameter in module functions. Passing " "``allow_code=False`` prevents serialization and de-serialization of code " @@ -1482,11 +1493,11 @@ msgid "" "Serhiy Storchaka in :gh:`113626`.)" msgstr "" -#: ../../whatsnew/3.13.rst:976 +#: ../../whatsnew/3.13.rst:983 msgid "math" msgstr "math" -#: ../../whatsnew/3.13.rst:978 +#: ../../whatsnew/3.13.rst:985 msgid "" "The new function :func:`~math.fma` performs fused multiply-add operations. " "This computes ``x * y + z`` with only a single round, and so avoids any " @@ -1496,11 +1507,11 @@ msgid "" "Stinner in :gh:`73468`.)" msgstr "" -#: ../../whatsnew/3.13.rst:988 +#: ../../whatsnew/3.13.rst:995 msgid "mimetypes" msgstr "mimetypes" -#: ../../whatsnew/3.13.rst:990 +#: ../../whatsnew/3.13.rst:997 msgid "" "Add the :func:`~mimetypes.guess_file_type` function to guess a MIME type " "from a filesystem path. Using paths with :func:`~mimetypes.guess_type` is " @@ -1508,18 +1519,18 @@ msgid "" "`66543`.)" msgstr "" -#: ../../whatsnew/3.13.rst:997 +#: ../../whatsnew/3.13.rst:1004 msgid "mmap" msgstr "mmap" -#: ../../whatsnew/3.13.rst:999 +#: ../../whatsnew/3.13.rst:1006 msgid "" ":class:`~mmap.mmap` is now protected from crashing on Windows when the " "mapped memory is inaccessible due to file system errors or access " "violations. (Contributed by Jannis Weigend in :gh:`118209`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1003 +#: ../../whatsnew/3.13.rst:1010 msgid "" ":class:`~mmap.mmap` has a new :meth:`~mmap.mmap.seekable` method that can be " "used when a seekable file-like object is required. The :meth:`~mmap.mmap." @@ -1527,7 +1538,7 @@ msgid "" "Na and Sylvie Liberman in :gh:`111835`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1008 +#: ../../whatsnew/3.13.rst:1015 msgid "" "The new UNIX-only *trackfd* parameter for :class:`~mmap.mmap` controls file " "descriptor duplication; if false, the file descriptor specified by *fileno* " @@ -1535,22 +1546,22 @@ msgid "" "gh:`78502`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1015 +#: ../../whatsnew/3.13.rst:1022 msgid "multiprocessing" msgstr "multiprocessing" -#: ../../whatsnew/3.13.rst:1023 +#: ../../whatsnew/3.13.rst:1030 msgid "os" msgstr "os" -#: ../../whatsnew/3.13.rst:1025 +#: ../../whatsnew/3.13.rst:1032 msgid "" "Add :func:`~os.process_cpu_count` function to get the number of logical CPU " "cores usable by the calling thread of the current process. (Contributed by " "Victor Stinner in :gh:`109649`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1029 +#: ../../whatsnew/3.13.rst:1036 msgid "" ":func:`~os.cpu_count` and :func:`~os.process_cpu_count` can be overridden " "through the new environment variable :envvar:`PYTHON_CPU_COUNT` or the new " @@ -1560,7 +1571,7 @@ msgid "" "Na in :gh:`109595`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1037 +#: ../../whatsnew/3.13.rst:1044 msgid "" "Add a :ref:`low level interface ` to Linux's :manpage:`timer " "file descriptors ` via :func:`~os.timerfd_create`, :func:" @@ -1571,7 +1582,7 @@ msgid "" "in :gh:`108277`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1046 +#: ../../whatsnew/3.13.rst:1053 msgid "" ":func:`~os.lchmod` and the *follow_symlinks* argument of :func:`~os.chmod` " "are both now available on Windows. Note that the default value of " @@ -1579,14 +1590,14 @@ msgid "" "by Serhiy Storchaka in :gh:`59616`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1052 +#: ../../whatsnew/3.13.rst:1059 msgid "" ":func:`~os.fchmod` and support for file descriptors in :func:`~os.chmod` are " "both now available on Windows. (Contributed by Serhiy Storchaka in :gh:" "`113191`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1056 +#: ../../whatsnew/3.13.rst:1063 msgid "" "On Windows, :func:`~os.mkdir` and :func:`~os.makedirs` now support passing a " "*mode* value of ``0o700`` to apply access control to the new directory. This " @@ -1595,14 +1606,14 @@ msgid "" "Steve Dower in :gh:`118486`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1063 +#: ../../whatsnew/3.13.rst:1070 msgid "" ":func:`~os.posix_spawn` now accepts ``None`` for the *env* argument, which " "makes the newly spawned process use the current process environment. " "(Contributed by Jakub Kulik in :gh:`113119`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1067 +#: ../../whatsnew/3.13.rst:1074 msgid "" ":func:`~os.posix_spawn` can now use the :attr:`~os.POSIX_SPAWN_CLOSEFROM` " "attribute in the *file_actions* parameter on platforms that support :c:func:" @@ -1610,76 +1621,76 @@ msgid "" "gh:`113117`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1074 +#: ../../whatsnew/3.13.rst:1081 msgid "os.path" msgstr "os.path" -#: ../../whatsnew/3.13.rst:1076 +#: ../../whatsnew/3.13.rst:1083 msgid "" "Add :func:`~os.path.isreserved` to check if a path is reserved on the " "current system. This function is only available on Windows. (Contributed by " "Barney Gale in :gh:`88569`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1081 +#: ../../whatsnew/3.13.rst:1088 msgid "" "On Windows, :func:`~os.path.isabs` no longer considers paths starting with " "exactly one slash (``\\`` or ``/``) to be absolute. (Contributed by Barney " "Gale and Jon Foster in :gh:`44626`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1085 +#: ../../whatsnew/3.13.rst:1092 msgid "" ":func:`~os.path.realpath` now resolves MS-DOS style file names even if the " "file is not accessible. (Contributed by Moonsik Park in :gh:`82367`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1091 ../../whatsnew/3.13.rst:1654 +#: ../../whatsnew/3.13.rst:1098 ../../whatsnew/3.13.rst:1677 msgid "pathlib" msgstr "pathlib" -#: ../../whatsnew/3.13.rst:1093 +#: ../../whatsnew/3.13.rst:1100 msgid "" "Add :exc:`~pathlib.UnsupportedOperation`, which is raised instead of :exc:" "`NotImplementedError` when a path operation isn't supported. (Contributed by " "Barney Gale in :gh:`89812`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1097 +#: ../../whatsnew/3.13.rst:1104 msgid "" "Add a new constructor for creating :class:`~pathlib.Path` objects from " "'file' URIs (``file:///``), :meth:`.Path.from_uri`. (Contributed by Barney " "Gale in :gh:`107465`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1101 +#: ../../whatsnew/3.13.rst:1108 msgid "" "Add :meth:`.PurePath.full_match` for matching paths with shell-style " "wildcards, including the recursive wildcard \"``**``\". (Contributed by " "Barney Gale in :gh:`73435`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1105 +#: ../../whatsnew/3.13.rst:1112 msgid "" "Add the :attr:`.PurePath.parser` class attribute to store the implementation " "of :mod:`os.path` used for low-level path parsing and joining. This will be " "either :mod:`!posixpath` or :mod:`!ntpath`." msgstr "" -#: ../../whatsnew/3.13.rst:1110 +#: ../../whatsnew/3.13.rst:1117 msgid "" "Add *recurse_symlinks* keyword-only argument to :meth:`.Path.glob` and :meth:" "`~pathlib.Path.rglob`. (Contributed by Barney Gale in :gh:`77609`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1114 +#: ../../whatsnew/3.13.rst:1121 msgid "" ":meth:`.Path.glob` and :meth:`~pathlib.Path.rglob` now return files and " "directories when given a pattern that ends with \"``**``\". Previously, only " "directories were returned. (Contributed by Barney Gale in :gh:`70303`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1119 +#: ../../whatsnew/3.13.rst:1126 msgid "" "Add the *follow_symlinks* keyword-only argument to :meth:`Path.is_file " "`, :meth:`Path.is_dir `, :meth:`." @@ -1687,11 +1698,11 @@ msgid "" "`105793` and Kamil Turek in :gh:`107962`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1127 +#: ../../whatsnew/3.13.rst:1134 msgid "pdb" msgstr "pdb" -#: ../../whatsnew/3.13.rst:1129 +#: ../../whatsnew/3.13.rst:1136 msgid "" ":func:`breakpoint` and :func:`~pdb.set_trace` now enter the debugger " "immediately rather than on the next line of code to be executed. This change " @@ -1700,20 +1711,20 @@ msgid "" "Gao in :gh:`118579`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1135 +#: ../../whatsnew/3.13.rst:1142 msgid "" "``sys.path[0]`` is no longer replaced by the directory of the script being " "debugged when :attr:`sys.flags.safe_path` is set. (Contributed by Tian Gao " "and Christian Walther in :gh:`111762`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1139 +#: ../../whatsnew/3.13.rst:1146 msgid "" ":mod:`zipapp` is now supported as a debugging target. (Contributed by Tian " "Gao in :gh:`118501`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1142 +#: ../../whatsnew/3.13.rst:1149 msgid "" "Add ability to move between chained exceptions during post-mortem debugging " "in :func:`~pdb.pm` using the new :pdbcmd:`exceptions [exc_number] " @@ -1721,101 +1732,101 @@ msgid "" "`106676`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1147 +#: ../../whatsnew/3.13.rst:1154 msgid "" "Expressions and statements whose prefix is a pdb command are now correctly " "identified and executed. (Contributed by Tian Gao in :gh:`108464`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1153 +#: ../../whatsnew/3.13.rst:1160 msgid "queue" msgstr "queue" -#: ../../whatsnew/3.13.rst:1155 +#: ../../whatsnew/3.13.rst:1162 msgid "" "Add :meth:`Queue.shutdown ` and :exc:`~queue.ShutDown` " "to manage queue termination. (Contributed by Laurie Opperman and Yves Duprat " "in :gh:`104750`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1161 +#: ../../whatsnew/3.13.rst:1168 msgid "random" msgstr "random" -#: ../../whatsnew/3.13.rst:1163 +#: ../../whatsnew/3.13.rst:1170 msgid "" "Add a :ref:`command-line interface `. (Contributed by Hugo van " "Kemenade in :gh:`118131`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1168 ../../whatsnew/3.13.rst:1662 +#: ../../whatsnew/3.13.rst:1175 ../../whatsnew/3.13.rst:1685 msgid "re" msgstr "re" -#: ../../whatsnew/3.13.rst:1170 +#: ../../whatsnew/3.13.rst:1177 msgid "" "Rename :exc:`!re.error` to :exc:`~re.PatternError` for improved clarity. :" "exc:`!re.error` is kept for backward compatibility." msgstr "" -#: ../../whatsnew/3.13.rst:1175 +#: ../../whatsnew/3.13.rst:1182 msgid "shutil" msgstr "shutil" -#: ../../whatsnew/3.13.rst:1177 +#: ../../whatsnew/3.13.rst:1184 msgid "" "Support the *dir_fd* and *follow_symlinks* keyword arguments in :func:" "`~shutil.chown`. (Contributed by Berker Peksag and Tahia K in :gh:`62308`)" msgstr "" -#: ../../whatsnew/3.13.rst:1183 +#: ../../whatsnew/3.13.rst:1190 msgid "site" msgstr "site" -#: ../../whatsnew/3.13.rst:1185 +#: ../../whatsnew/3.13.rst:1192 msgid "" ":file:`.pth` files are now decoded using UTF-8 first, and then with the :" "term:`locale encoding` if UTF-8 decoding fails. (Contributed by Inada Naoki " "in :gh:`117802`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1191 +#: ../../whatsnew/3.13.rst:1198 msgid "sqlite3" msgstr "sqlite3" -#: ../../whatsnew/3.13.rst:1193 +#: ../../whatsnew/3.13.rst:1200 msgid "" "A :exc:`ResourceWarning` is now emitted if a :class:`~sqlite3.Connection` " "object is not :meth:`closed ` explicitly. " "(Contributed by Erlend E. Aasland in :gh:`105539`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1197 +#: ../../whatsnew/3.13.rst:1204 msgid "" "Add the *filter* keyword-only parameter to :meth:`.Connection.iterdump` for " "filtering database objects to dump. (Contributed by Mariusz Felisiak in :gh:" "`91602`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1203 +#: ../../whatsnew/3.13.rst:1210 msgid "ssl" msgstr "ssl" -#: ../../whatsnew/3.13.rst:1205 +#: ../../whatsnew/3.13.rst:1212 msgid "" "The :func:`~ssl.create_default_context` API now includes :data:`~ssl." "VERIFY_X509_PARTIAL_CHAIN` and :data:`~ssl.VERIFY_X509_STRICT` in its " "default flags." msgstr "" -#: ../../whatsnew/3.13.rst:1211 +#: ../../whatsnew/3.13.rst:1218 msgid "" ":data:`~ssl.VERIFY_X509_STRICT` may reject pre-:rfc:`5280` or malformed " "certificates that the underlying OpenSSL implementation might otherwise " "accept. Whilst disabling this is not recommended, you can do so using:" msgstr "" -#: ../../whatsnew/3.13.rst:1216 +#: ../../whatsnew/3.13.rst:1223 msgid "" "import ssl\n" "\n" @@ -1827,15 +1838,15 @@ msgstr "" "ctx = ssl.create_default_context()\n" "ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT" -#: ../../whatsnew/3.13.rst:1223 +#: ../../whatsnew/3.13.rst:1230 msgid "(Contributed by William Woodruff in :gh:`112389`.)" msgstr "(由 William Woodruff 在 :gh:`112389` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1227 +#: ../../whatsnew/3.13.rst:1234 msgid "statistics" msgstr "statistics" -#: ../../whatsnew/3.13.rst:1229 +#: ../../whatsnew/3.13.rst:1236 msgid "" "Add :func:`~statistics.kde` for kernel density estimation. This makes it " "possible to estimate a continuous probability density function from a fixed " @@ -1843,24 +1854,24 @@ msgid "" "`115863`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1234 +#: ../../whatsnew/3.13.rst:1241 msgid "" "Add :func:`~statistics.kde_random` for sampling from an estimated " "probability density function created by :func:`~statistics.kde`. " "(Contributed by Raymond Hettinger in :gh:`115863`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1242 +#: ../../whatsnew/3.13.rst:1249 msgid "subprocess" msgstr "subprocess" -#: ../../whatsnew/3.13.rst:1244 +#: ../../whatsnew/3.13.rst:1251 msgid "" "The :mod:`subprocess` module now uses the :func:`~os.posix_spawn` function " "in more situations." msgstr "" -#: ../../whatsnew/3.13.rst:1247 +#: ../../whatsnew/3.13.rst:1254 msgid "" "Notably, when *close_fds* is ``True`` (the default), :func:`~os.posix_spawn` " "will be used when the C library provides :c:func:`!" @@ -1869,7 +1880,7 @@ msgid "" "existing Linux :c:func:`!vfork` based code." msgstr "" -#: ../../whatsnew/3.13.rst:1254 +#: ../../whatsnew/3.13.rst:1261 msgid "" "A private control knob :attr:`!subprocess._USE_POSIX_SPAWN` can be set to " "``False`` if you need to force :mod:`subprocess` to never use :func:`~os." @@ -1879,22 +1890,22 @@ msgid "" "`113117`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1264 ../../whatsnew/3.13.rst:2717 +#: ../../whatsnew/3.13.rst:1271 ../../whatsnew/3.13.rst:2732 msgid "sys" msgstr "sys" -#: ../../whatsnew/3.13.rst:1266 +#: ../../whatsnew/3.13.rst:1273 msgid "" "Add the :func:`~sys._is_interned` function to test if a string was interned. " "This function is not guaranteed to exist in all implementations of Python. " "(Contributed by Serhiy Storchaka in :gh:`78573`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1272 +#: ../../whatsnew/3.13.rst:1279 msgid "tempfile" msgstr "tempfile" -#: ../../whatsnew/3.13.rst:1274 +#: ../../whatsnew/3.13.rst:1281 msgid "" "On Windows, the default mode ``0o700`` used by :func:`tempfile.mkdtemp` now " "limits access to the new directory due to changes to :func:`os.mkdir`. This " @@ -1902,11 +1913,11 @@ msgid "" "`118486`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1281 +#: ../../whatsnew/3.13.rst:1288 msgid "time" msgstr "time" -#: ../../whatsnew/3.13.rst:1283 +#: ../../whatsnew/3.13.rst:1290 msgid "" "On Windows, :func:`~time.monotonic` now uses the " "``QueryPerformanceCounter()`` clock for a resolution of 1 microsecond, " @@ -1914,7 +1925,7 @@ msgid "" "milliseconds. (Contributed by Victor Stinner in :gh:`88494`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1289 +#: ../../whatsnew/3.13.rst:1296 msgid "" "On Windows, :func:`~time.time` now uses the " "``GetSystemTimePreciseAsFileTime()`` clock for a resolution of 1 " @@ -1923,11 +1934,11 @@ msgid "" "`63207`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1297 +#: ../../whatsnew/3.13.rst:1304 msgid "tkinter" msgstr "tkinter" -#: ../../whatsnew/3.13.rst:1299 +#: ../../whatsnew/3.13.rst:1306 msgid "" "Add :mod:`tkinter` widget methods: :meth:`!tk_busy_hold`, :meth:`!" "tk_busy_configure`, :meth:`!tk_busy_cget`, :meth:`!tk_busy_forget`, :meth:`!" @@ -1935,7 +1946,7 @@ msgid "" "klappnase and Serhiy Storchaka in :gh:`72684`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1305 +#: ../../whatsnew/3.13.rst:1312 msgid "" "The :mod:`tkinter` widget method :meth:`!wm_attributes` now accepts the " "attribute name without the minus prefix to get window attributes, for " @@ -1944,14 +1955,14 @@ msgid "" "wm_attributes(alpha=0.5)``. (Contributed by Serhiy Storchaka in :gh:`43457`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1312 +#: ../../whatsnew/3.13.rst:1319 msgid "" ":meth:`!wm_attributes` can now return attributes as a :class:`dict`, by " "using the new optional keyword-only parameter *return_python_dict*. " "(Contributed by Serhiy Storchaka in :gh:`43457`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1316 +#: ../../whatsnew/3.13.rst:1323 msgid "" ":meth:`!Text.count` can now return a simple :class:`int` when the new " "optional keyword-only parameter *return_ints* is used. Otherwise, the single " @@ -1959,27 +1970,27 @@ msgid "" "in :gh:`97928`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1321 +#: ../../whatsnew/3.13.rst:1328 msgid "" "Support the \"vsapi\" element type in the :meth:`~tkinter.ttk.Style." "element_create` method of :class:`tkinter.ttk.Style`. (Contributed by Serhiy " "Storchaka in :gh:`68166`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1326 +#: ../../whatsnew/3.13.rst:1333 msgid "" "Add the :meth:`!after_info` method for Tkinter widgets. (Contributed by " "Cheryl Sabella in :gh:`77020`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1329 +#: ../../whatsnew/3.13.rst:1336 msgid "" "Add a new :meth:`!copy_replace` method to :class:`!PhotoImage` to copy a " "region from one image to another, possibly with pixel zooming, subsampling, " "or both. (Contributed by Serhiy Storchaka in :gh:`118225`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1334 +#: ../../whatsnew/3.13.rst:1341 msgid "" "Add *from_coords* parameter to the :class:`!PhotoImage` methods :meth:`!" "copy`, :meth:`!zoom` and :meth:`!subsample`. Add *zoom* and *subsample* " @@ -1987,7 +1998,7 @@ msgid "" "Serhiy Storchaka in :gh:`118225`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1340 +#: ../../whatsnew/3.13.rst:1347 msgid "" "Add the :class:`!PhotoImage` methods :meth:`!read` to read an image from a " "file and :meth:`!data` to get the image data. Add *background* and " @@ -1995,11 +2006,11 @@ msgid "" "Storchaka in :gh:`118271`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1348 +#: ../../whatsnew/3.13.rst:1355 msgid "traceback" msgstr "traceback" -#: ../../whatsnew/3.13.rst:1350 +#: ../../whatsnew/3.13.rst:1357 msgid "" "Add the :attr:`~traceback.TracebackException.exc_type_str` attribute to :" "class:`~traceback.TracebackException`, which holds a string display of the " @@ -2009,7 +2020,7 @@ msgid "" "(Contributed by Irit Katriel in :gh:`112332`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1359 +#: ../../whatsnew/3.13.rst:1366 msgid "" "Add a new *show_group* keyword-only parameter to :meth:`.TracebackException." "format_exception_only` to (recursively) format the nested exceptions of a :" @@ -2017,11 +2028,11 @@ msgid "" "`105292`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1366 +#: ../../whatsnew/3.13.rst:1373 msgid "types" msgstr "types" -#: ../../whatsnew/3.13.rst:1368 +#: ../../whatsnew/3.13.rst:1375 msgid "" ":class:`~types.SimpleNamespace` can now take a single positional argument to " "initialise the namespace's arguments. This argument must either be a mapping " @@ -2029,63 +2040,63 @@ msgid "" "`108191`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1375 ../../whatsnew/3.13.rst:1687 +#: ../../whatsnew/3.13.rst:1382 ../../whatsnew/3.13.rst:1710 msgid "typing" msgstr "typing" -#: ../../whatsnew/3.13.rst:1377 +#: ../../whatsnew/3.13.rst:1384 msgid "" ":pep:`705`: Add :data:`~typing.ReadOnly`, a special typing construct to mark " "a :class:`~typing.TypedDict` item as read-only for type checkers." msgstr "" -#: ../../whatsnew/3.13.rst:1380 +#: ../../whatsnew/3.13.rst:1387 msgid "" ":pep:`742`: Add :data:`~typing.TypeIs`, a typing construct that can be used " "to instruct a type checker how to narrow a type." msgstr "" -#: ../../whatsnew/3.13.rst:1383 +#: ../../whatsnew/3.13.rst:1390 msgid "" "Add :data:`~typing.NoDefault`, a sentinel object used to represent the " "defaults of some parameters in the :mod:`typing` module. (Contributed by " "Jelle Zijlstra in :gh:`116126`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1387 +#: ../../whatsnew/3.13.rst:1394 msgid "" "Add :func:`~typing.get_protocol_members` to return the set of members " "defining a :class:`typing.Protocol`. (Contributed by Jelle Zijlstra in :gh:" "`104873`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1391 +#: ../../whatsnew/3.13.rst:1398 msgid "" "Add :func:`~typing.is_protocol` to check whether a class is a :class:" "`~typing.Protocol`. (Contributed by Jelle Zijlstra in :gh:`104873`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1395 +#: ../../whatsnew/3.13.rst:1402 msgid "" ":data:`~typing.ClassVar` can now be nested in :data:`~typing.Final`, and " "vice versa. (Contributed by Mehdi Drissi in :gh:`89547`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1401 +#: ../../whatsnew/3.13.rst:1408 msgid "unicodedata" msgstr "unicodedata" -#: ../../whatsnew/3.13.rst:1403 +#: ../../whatsnew/3.13.rst:1410 msgid "" "Update the Unicode database to `version 15.1.0`__. (Contributed by James " "Gerity in :gh:`109559`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1410 +#: ../../whatsnew/3.13.rst:1417 msgid "venv" msgstr "venv" -#: ../../whatsnew/3.13.rst:1412 +#: ../../whatsnew/3.13.rst:1419 msgid "" "Add support for creating source control management (SCM) ignore files in a " "virtual environment's directory. By default, Git is supported. This is " @@ -2095,11 +2106,11 @@ msgid "" "Cannon in :gh:`108125`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1423 +#: ../../whatsnew/3.13.rst:1430 msgid "warnings" msgstr "warnings" -#: ../../whatsnew/3.13.rst:1425 +#: ../../whatsnew/3.13.rst:1432 msgid "" ":pep:`702`: The new :func:`warnings.deprecated` decorator provides a way to " "communicate deprecations to a :term:`static type checker` and to warn on " @@ -2108,62 +2119,62 @@ msgid "" "(Contributed by Jelle Zijlstra in :gh:`104003`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1434 +#: ../../whatsnew/3.13.rst:1441 msgid "xml" msgstr "xml" -#: ../../whatsnew/3.13.rst:1436 +#: ../../whatsnew/3.13.rst:1443 msgid "" "Allow controlling Expat >=2.6.0 reparse deferral (:cve:`2023-52425`) by " "adding five new methods:" msgstr "" -#: ../../whatsnew/3.13.rst:1439 +#: ../../whatsnew/3.13.rst:1446 msgid ":meth:`xml.etree.ElementTree.XMLParser.flush`" msgstr ":meth:`xml.etree.ElementTree.XMLParser.flush`" -#: ../../whatsnew/3.13.rst:1440 +#: ../../whatsnew/3.13.rst:1447 msgid ":meth:`xml.etree.ElementTree.XMLPullParser.flush`" msgstr ":meth:`xml.etree.ElementTree.XMLPullParser.flush`" -#: ../../whatsnew/3.13.rst:1441 +#: ../../whatsnew/3.13.rst:1448 msgid ":meth:`xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`" msgstr ":meth:`xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`" -#: ../../whatsnew/3.13.rst:1442 +#: ../../whatsnew/3.13.rst:1449 msgid ":meth:`xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`" msgstr ":meth:`xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`" -#: ../../whatsnew/3.13.rst:1443 +#: ../../whatsnew/3.13.rst:1450 msgid ":meth:`!xml.sax.expatreader.ExpatParser.flush`" msgstr ":meth:`!xml.sax.expatreader.ExpatParser.flush`" -#: ../../whatsnew/3.13.rst:1445 +#: ../../whatsnew/3.13.rst:1452 msgid "(Contributed by Sebastian Pipping in :gh:`115623`.)" msgstr "(由 Sebastian Pipping 在 :gh:`115623` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1447 +#: ../../whatsnew/3.13.rst:1454 msgid "" "Add the :meth:`!close` method for the iterator returned by :func:`~xml.etree." "ElementTree.iterparse` for explicit cleanup. (Contributed by Serhiy " "Storchaka in :gh:`69893`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1453 +#: ../../whatsnew/3.13.rst:1460 msgid "zipimport" msgstr "zipimport" -#: ../../whatsnew/3.13.rst:1455 +#: ../../whatsnew/3.13.rst:1462 msgid "" "Add support for ZIP64_ format files. Everybody loves huge data, right? " "(Contributed by Tim Hatch in :gh:`94146`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1463 +#: ../../whatsnew/3.13.rst:1470 msgid "Optimizations" msgstr "最佳化" -#: ../../whatsnew/3.13.rst:1465 +#: ../../whatsnew/3.13.rst:1472 msgid "" "Several standard library modules have had their import times significantly " "improved. For example, the import time of the :mod:`typing` module has been " @@ -2174,13 +2185,13 @@ msgid "" "Turner, Daniel Hollas, and others in :gh:`109653`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1476 +#: ../../whatsnew/3.13.rst:1483 msgid "" ":func:`textwrap.indent` is now around 30% faster than before for large " "input. (Contributed by Inada Naoki in :gh:`107369`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1479 +#: ../../whatsnew/3.13.rst:1486 msgid "" "The :mod:`subprocess` module now uses the :func:`~os.posix_spawn` function " "in more situations, including when *close_fds* is ``True`` (the default) on " @@ -2190,15 +2201,15 @@ msgid "" "Kulik in :gh:`113117`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1489 +#: ../../whatsnew/3.13.rst:1496 msgid "Removed Modules And APIs" msgstr "" -#: ../../whatsnew/3.13.rst:1495 +#: ../../whatsnew/3.13.rst:1502 msgid "PEP 594: Remove \"dead batteries\" from the standard library" msgstr "" -#: ../../whatsnew/3.13.rst:1497 +#: ../../whatsnew/3.13.rst:1504 msgid "" ":pep:`594` proposed removing 19 modules from the standard library, " "colloquially referred to as 'dead batteries' due to their historic, " @@ -2206,23 +2217,23 @@ msgid "" "in Python 3.11, and are now removed:" msgstr "" -#: ../../whatsnew/3.13.rst:1503 +#: ../../whatsnew/3.13.rst:1510 msgid ":mod:`!aifc`" msgstr ":mod:`!aifc`" -#: ../../whatsnew/3.13.rst:1504 +#: ../../whatsnew/3.13.rst:1511 msgid ":mod:`!audioop`" msgstr ":mod:`!audioop`" -#: ../../whatsnew/3.13.rst:1505 +#: ../../whatsnew/3.13.rst:1512 msgid ":mod:`!chunk`" msgstr ":mod:`!chunk`" -#: ../../whatsnew/3.13.rst:1506 +#: ../../whatsnew/3.13.rst:1513 msgid ":mod:`!cgi` and :mod:`!cgitb`" msgstr ":mod:`!cgi` 和 :mod:`!cgitb`" -#: ../../whatsnew/3.13.rst:1508 +#: ../../whatsnew/3.13.rst:1515 msgid "" ":class:`!cgi.FieldStorage` can typically be replaced with :func:`urllib." "parse.parse_qsl` for ``GET`` and ``HEAD`` requests, and the :mod:`email." @@ -2230,7 +2241,7 @@ msgid "" "requests." msgstr "" -#: ../../whatsnew/3.13.rst:1513 +#: ../../whatsnew/3.13.rst:1520 msgid "" ":func:`!cgi.parse` can be replaced by calling :func:`urllib.parse.parse_qs` " "directly on the desired query string, unless the input is ``multipart/form-" @@ -2238,14 +2249,14 @@ msgid "" "parse_multipart`." msgstr "" -#: ../../whatsnew/3.13.rst:1518 +#: ../../whatsnew/3.13.rst:1525 msgid "" ":func:`!cgi.parse_header` can be replaced with the functionality in the :mod:" "`email` package, which implements the same MIME RFCs. For example, with :" "class:`email.message.EmailMessage`:" msgstr "" -#: ../../whatsnew/3.13.rst:1522 +#: ../../whatsnew/3.13.rst:1529 msgid "" "from email.message import EmailMessage\n" "\n" @@ -2254,7 +2265,7 @@ msgid "" "main, params = msg.get_content_type(), msg['content-type'].params" msgstr "" -#: ../../whatsnew/3.13.rst:1530 +#: ../../whatsnew/3.13.rst:1537 msgid "" ":func:`!cgi.parse_multipart` can be replaced with the functionality in the :" "mod:`email` package, which implements the same MIME RFCs, or with the :pypi:" @@ -2262,41 +2273,41 @@ msgid "" "and :class:`email.message.Message` classes." msgstr "" -#: ../../whatsnew/3.13.rst:1536 +#: ../../whatsnew/3.13.rst:1543 msgid "" ":mod:`!crypt` and the private :mod:`!_crypt` extension. The :mod:`hashlib` " "module may be an appropriate replacement when simply hashing a value is " "required. Otherwise, various third-party libraries on PyPI are available:" msgstr "" -#: ../../whatsnew/3.13.rst:1541 +#: ../../whatsnew/3.13.rst:1548 msgid "" ":pypi:`bcrypt`: Modern password hashing for your software and your servers." msgstr "" -#: ../../whatsnew/3.13.rst:1543 +#: ../../whatsnew/3.13.rst:1550 msgid "" ":pypi:`passlib`: Comprehensive password hashing framework supporting over 30 " "schemes." msgstr "" -#: ../../whatsnew/3.13.rst:1545 +#: ../../whatsnew/3.13.rst:1552 msgid ":pypi:`argon2-cffi`: The secure Argon2 password hashing algorithm." msgstr "" -#: ../../whatsnew/3.13.rst:1547 +#: ../../whatsnew/3.13.rst:1554 msgid "" ":pypi:`legacycrypt`: :mod:`ctypes` wrapper to the POSIX crypt library call " "and associated functionality." msgstr "" -#: ../../whatsnew/3.13.rst:1550 +#: ../../whatsnew/3.13.rst:1557 msgid "" ":pypi:`crypt_r`: Fork of the :mod:`!crypt` module, wrapper to the :manpage:" "`crypt_r(3)` library call and associated functionality." msgstr "" -#: ../../whatsnew/3.13.rst:1555 +#: ../../whatsnew/3.13.rst:1562 msgid "" ":mod:`!imghdr`: The :pypi:`filetype`, :pypi:`puremagic`, or :pypi:`python-" "magic` libraries should be used as replacements. For example, the :func:`!" @@ -2304,85 +2315,87 @@ msgid "" "function for all file formats that were supported by :mod:`!imghdr`." msgstr "" -#: ../../whatsnew/3.13.rst:1561 +#: ../../whatsnew/3.13.rst:1568 msgid ":mod:`!mailcap`: Use the :mod:`mimetypes` module instead." msgstr "" -#: ../../whatsnew/3.13.rst:1563 +#: ../../whatsnew/3.13.rst:1570 msgid ":mod:`!msilib`" msgstr ":mod:`!msilib`" -#: ../../whatsnew/3.13.rst:1564 +#: ../../whatsnew/3.13.rst:1571 msgid ":mod:`!nis`" msgstr ":mod:`!nis`" -#: ../../whatsnew/3.13.rst:1565 +#: ../../whatsnew/3.13.rst:1572 msgid ":mod:`!nntplib`: Use the :pypi:`pynntp` library from PyPI instead." msgstr "" -#: ../../whatsnew/3.13.rst:1567 +#: ../../whatsnew/3.13.rst:1574 msgid "" ":mod:`!ossaudiodev`: For audio playback, use the :pypi:`pygame` library from " "PyPI instead." msgstr "" -#: ../../whatsnew/3.13.rst:1569 +#: ../../whatsnew/3.13.rst:1576 msgid "" ":mod:`!pipes`: Use the :mod:`subprocess` module instead. Use :func:`shlex." "quote` to replace the undocumented ``pipes.quote`` function." msgstr "" -#: ../../whatsnew/3.13.rst:1573 +#: ../../whatsnew/3.13.rst:1580 msgid "" ":mod:`!sndhdr`: The :pypi:`filetype`, :pypi:`puremagic`, or :pypi:`python-" "magic` libraries should be used as replacements." msgstr "" -#: ../../whatsnew/3.13.rst:1576 +#: ../../whatsnew/3.13.rst:1583 msgid ":mod:`!spwd`: Use the :pypi:`python-pam` library from PyPI instead." msgstr "" -#: ../../whatsnew/3.13.rst:1578 +#: ../../whatsnew/3.13.rst:1585 msgid ":mod:`!sunau`" msgstr ":mod:`!sunau`" -#: ../../whatsnew/3.13.rst:1579 +#: ../../whatsnew/3.13.rst:1586 msgid "" ":mod:`!telnetlib`, Use the :pypi:`telnetlib3` or :pypi:`Exscript` libraries " "from PyPI instead." msgstr "" -#: ../../whatsnew/3.13.rst:1581 +#: ../../whatsnew/3.13.rst:1588 msgid "" ":mod:`!uu`: Use the :mod:`base64` module instead, as a modern alternative." msgstr "" -#: ../../whatsnew/3.13.rst:1583 +#: ../../whatsnew/3.13.rst:1590 msgid ":mod:`!xdrlib`" msgstr ":mod:`!xdrlib`" -#: ../../whatsnew/3.13.rst:1585 +#: ../../whatsnew/3.13.rst:1592 msgid "" "(Contributed by Victor Stinner and Zachary Ware in :gh:`104773` and :gh:" "`104780`.)" msgstr "" +"(由 Victor Stinner 和 Zachary Ware 在 :gh:`104773` 和 :gh:`104780` 中貢" +"獻。)" -#: ../../whatsnew/3.13.rst:1589 +#: ../../whatsnew/3.13.rst:1596 msgid "2to3" msgstr "2to3" -#: ../../whatsnew/3.13.rst:1591 +#: ../../whatsnew/3.13.rst:1598 msgid "" "Remove the :program:`2to3` program and the :mod:`!lib2to3` module, " "previously deprecated in Python 3.11. (Contributed by Victor Stinner in :gh:" "`104780`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1597 +#: ../../whatsnew/3.13.rst:1604 msgid "builtins" msgstr "builtins" -#: ../../whatsnew/3.13.rst:1599 +#: ../../whatsnew/3.13.rst:1606 msgid "" "Remove support for chained :class:`classmethod` descriptors (introduced in :" "gh:`63272`). These can no longer be used to wrap other descriptors, such as :" @@ -2392,47 +2405,47 @@ msgid "" "(Contributed by Raymond Hettinger in :gh:`89519`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1608 +#: ../../whatsnew/3.13.rst:1615 msgid "" "Raise a :exc:`RuntimeError` when calling :meth:`frame.clear` on a suspended " "frame (as has always been the case for an executing frame). (Contributed by " "Irit Katriel in :gh:`79932`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1616 +#: ../../whatsnew/3.13.rst:1623 msgid "" "Remove the undocumented :class:`!LegacyInterpolation` class, deprecated in " "the docstring since Python 3.2, and at runtime since Python 3.11. " "(Contributed by Hugo van Kemenade in :gh:`104886`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1623 +#: ../../whatsnew/3.13.rst:1630 msgid "importlib.metadata" msgstr "importlib.metadata" -#: ../../whatsnew/3.13.rst:1625 +#: ../../whatsnew/3.13.rst:1632 msgid "" "Remove deprecated subscript (:meth:`~object.__getitem__`) access for :ref:" "`EntryPoint ` objects. (Contributed by Jason R. Coombs in :gh:" "`113175`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1631 +#: ../../whatsnew/3.13.rst:1638 msgid "locale" msgstr "locale" -#: ../../whatsnew/3.13.rst:1633 +#: ../../whatsnew/3.13.rst:1640 msgid "" "Remove the :func:`!locale.resetlocale` function, deprecated in Python 3.11. " "Use ``locale.setlocale(locale.LC_ALL, \"\")`` instead. (Contributed by " "Victor Stinner in :gh:`104783`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1639 +#: ../../whatsnew/3.13.rst:1646 msgid "opcode" msgstr "opcode" -#: ../../whatsnew/3.13.rst:1641 +#: ../../whatsnew/3.13.rst:1648 msgid "" "Move :attr:`!opcode.ENABLE_SPECIALIZATION` to :attr:`!_opcode." "ENABLE_SPECIALIZATION`. This field was added in 3.12, it was never " @@ -2440,7 +2453,7 @@ msgid "" "Katriel in :gh:`105481`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1646 +#: ../../whatsnew/3.13.rst:1653 msgid "" "Remove :func:`!opcode.is_pseudo`, :attr:`!opcode.MIN_PSEUDO_OPCODE`, and :" "attr:`!opcode.MAX_PSEUDO_OPCODE`, which were added in Python 3.12, but were " @@ -2448,43 +2461,60 @@ msgid "" "be used externally. (Contributed by Irit Katriel in :gh:`105481`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1656 +#: ../../whatsnew/3.13.rst:1661 +msgid "optparse" +msgstr "optparse" + +#: ../../whatsnew/3.13.rst:1663 +msgid "" +"This module is no longer considered :term:`soft deprecated`. While :mod:" +"`argparse` remains preferred for new projects that aren't using a third " +"party command line argument processing library, there are aspects of the way " +"``argparse`` works that mean the lower level ``optparse`` module may provide " +"a better foundation for *writing* argument processing libraries, and for " +"implementing command line applications which adhere more strictly than " +"``argparse`` does to various Unix command line processing conventions that " +"originate in the behaviour of the C :c:func:`!getopt` function . " +"(Contributed by Alyssa Coghlan and Serhiy Storchaka in :gh:`126180`.)" +msgstr "" + +#: ../../whatsnew/3.13.rst:1679 msgid "" "Remove the ability to use :class:`~pathlib.Path` objects as context " "managers. This functionality was deprecated and has had no effect since " "Python 3.9. (Contributed by Barney Gale in :gh:`83863`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1664 +#: ../../whatsnew/3.13.rst:1687 msgid "" "Remove the undocumented, deprecated, and broken :func:`!re.template` " "function and :attr:`!re.TEMPLATE` / :attr:`!re.T` flag. (Contributed by " "Serhiy Storchaka and Nikita Sobolev in :gh:`105687`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1670 +#: ../../whatsnew/3.13.rst:1693 msgid "tkinter.tix" msgstr "tkinter.tix" -#: ../../whatsnew/3.13.rst:1672 +#: ../../whatsnew/3.13.rst:1695 msgid "" "Remove the :mod:`!tkinter.tix` module, deprecated in Python 3.6. The third-" "party Tix library which the module wrapped is unmaintained. (Contributed by " "Zachary Ware in :gh:`75552`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1678 +#: ../../whatsnew/3.13.rst:1701 msgid "turtle" msgstr "turtle" -#: ../../whatsnew/3.13.rst:1680 +#: ../../whatsnew/3.13.rst:1703 msgid "" "Remove the :meth:`!RawTurtle.settiltangle` method, deprecated in the " "documentation since Python 3.1 and at runtime since Python 3.11. " "(Contributed by Hugo van Kemenade in :gh:`104876`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1689 +#: ../../whatsnew/3.13.rst:1712 msgid "" "Remove the :mod:`!typing.io` and :mod:`!typing.re` namespaces, deprecated " "since Python 3.8. The items in those namespaces can be imported directly " @@ -2492,66 +2522,66 @@ msgid "" "`92871`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1695 +#: ../../whatsnew/3.13.rst:1718 msgid "" "Remove the keyword-argument method of creating :class:`~typing.TypedDict` " "types, deprecated in Python 3.11. (Contributed by Tomas Roun in :gh:" "`104786`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1701 +#: ../../whatsnew/3.13.rst:1724 msgid "unittest" msgstr "unittest" -#: ../../whatsnew/3.13.rst:1703 +#: ../../whatsnew/3.13.rst:1726 msgid "" "Remove the following :mod:`unittest` functions, deprecated in Python 3.11:" -msgstr "" +msgstr "移除以下在 Python 3.11 中已被棄用的 :mod:`unittest` 函式:" -#: ../../whatsnew/3.13.rst:1705 +#: ../../whatsnew/3.13.rst:1728 msgid ":func:`!unittest.findTestCases`" msgstr ":func:`!unittest.findTestCases`" -#: ../../whatsnew/3.13.rst:1706 +#: ../../whatsnew/3.13.rst:1729 msgid ":func:`!unittest.makeSuite`" msgstr ":func:`!unittest.makeSuite`" -#: ../../whatsnew/3.13.rst:1707 +#: ../../whatsnew/3.13.rst:1730 msgid ":func:`!unittest.getTestCaseNames`" msgstr ":func:`!unittest.getTestCaseNames`" -#: ../../whatsnew/3.13.rst:1709 +#: ../../whatsnew/3.13.rst:1732 msgid "Use :class:`~unittest.TestLoader` methods instead:" msgstr "" -#: ../../whatsnew/3.13.rst:1711 +#: ../../whatsnew/3.13.rst:1734 msgid ":meth:`~unittest.TestLoader.loadTestsFromModule`" msgstr ":meth:`~unittest.TestLoader.loadTestsFromModule`" -#: ../../whatsnew/3.13.rst:1712 +#: ../../whatsnew/3.13.rst:1735 msgid ":meth:`~unittest.TestLoader.loadTestsFromTestCase`" msgstr ":meth:`~unittest.TestLoader.loadTestsFromTestCase`" -#: ../../whatsnew/3.13.rst:1713 +#: ../../whatsnew/3.13.rst:1736 msgid ":meth:`~unittest.TestLoader.getTestCaseNames`" msgstr ":meth:`~unittest.TestLoader.getTestCaseNames`" -#: ../../whatsnew/3.13.rst:1715 +#: ../../whatsnew/3.13.rst:1738 msgid "(Contributed by Hugo van Kemenade in :gh:`104835`.)" msgstr "(由 Hugo van Kemenade 在 :gh:`104835` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1717 +#: ../../whatsnew/3.13.rst:1740 msgid "" "Remove the untested and undocumented :meth:`!TestProgram.usageExit` method, " "deprecated in Python 3.11. (Contributed by Hugo van Kemenade in :gh:" "`104992`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1723 +#: ../../whatsnew/3.13.rst:1746 msgid "urllib" msgstr "urllib" -#: ../../whatsnew/3.13.rst:1725 +#: ../../whatsnew/3.13.rst:1748 msgid "" "Remove the *cafile*, *capath*, and *cadefault* parameters of the :func:" "`urllib.request.urlopen` function, deprecated in Python 3.6. Use the " @@ -2562,33 +2592,33 @@ msgid "" "Victor Stinner in :gh:`105382`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1736 +#: ../../whatsnew/3.13.rst:1759 msgid "webbrowser" msgstr "webbrowser" -#: ../../whatsnew/3.13.rst:1738 +#: ../../whatsnew/3.13.rst:1761 msgid "" "Remove the untested and undocumented :class:`!MacOSX` class, deprecated in " "Python 3.11. Use the :class:`!MacOSXOSAScript` class (introduced in Python " "3.2) instead. (Contributed by Hugo van Kemenade in :gh:`104804`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1743 +#: ../../whatsnew/3.13.rst:1766 msgid "" "Remove the deprecated :attr:`!MacOSXOSAScript._name` attribute. Use the :" "attr:`MacOSXOSAScript.name ` attribute instead. " "(Contributed by Nikita Sobolev in :gh:`105546`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1750 +#: ../../whatsnew/3.13.rst:1773 msgid "New Deprecations" msgstr "" -#: ../../whatsnew/3.13.rst:1752 +#: ../../whatsnew/3.13.rst:1775 msgid ":ref:`User-defined functions `:" msgstr "" -#: ../../whatsnew/3.13.rst:1754 +#: ../../whatsnew/3.13.rst:1777 msgid "" "Deprecate assignment to a function's :attr:`~function.__code__` attribute, " "where the new code object's type does not match the function's type. The " @@ -2596,12 +2626,12 @@ msgid "" "coroutine. (Contributed by Irit Katriel in :gh:`81137`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1760 +#: ../../whatsnew/3.13.rst:1783 #: ../../deprecations/pending-removal-in-3.16.rst:11 msgid ":mod:`array`:" msgstr ":mod:`array`:" -#: ../../whatsnew/3.13.rst:1762 +#: ../../whatsnew/3.13.rst:1785 msgid "" "Deprecate the ``'u'`` format code (:c:type:`wchar_t`) at runtime. This " "format code has been deprecated in documentation since Python 3.3, and will " @@ -2610,73 +2640,61 @@ msgid "" "`80480`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1769 +#: ../../whatsnew/3.13.rst:1792 #: ../../deprecations/pending-removal-in-3.15.rst:16 msgid ":mod:`ctypes`:" msgstr ":mod:`ctypes`:" -#: ../../whatsnew/3.13.rst:1771 +#: ../../whatsnew/3.13.rst:1794 msgid "" "Deprecate the undocumented :func:`!SetPointerType` function, to be removed " "in Python 3.15. (Contributed by Victor Stinner in :gh:`105733`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1775 +#: ../../whatsnew/3.13.rst:1798 msgid "" ":term:`Soft-deprecate ` the :func:`~ctypes.ARRAY` function " "in favour of ``type * length`` multiplication. (Contributed by Victor " "Stinner in :gh:`105733`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1779 +#: ../../whatsnew/3.13.rst:1802 msgid ":mod:`decimal`:" msgstr ":mod:`decimal`:" -#: ../../whatsnew/3.13.rst:1781 +#: ../../whatsnew/3.13.rst:1804 msgid "" "Deprecate the non-standard and undocumented :class:`~decimal.Decimal` format " "specifier ``'N'``, which is only supported in the :mod:`!decimal` module's C " "implementation. (Contributed by Serhiy Storchaka in :gh:`89902`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1786 +#: ../../whatsnew/3.13.rst:1809 msgid ":mod:`dis`:" msgstr ":mod:`dis`:" -#: ../../whatsnew/3.13.rst:1788 +#: ../../whatsnew/3.13.rst:1811 msgid "" "Deprecate the :attr:`!HAVE_ARGUMENT` separator. Check membership in :data:" "`~dis.hasarg` instead. (Contributed by Irit Katriel in :gh:`109319`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1792 -msgid ":mod:`getopt` and :mod:`optparse`:" -msgstr ":mod:`getopt` 和 :mod:`optparse`:" - -#: ../../whatsnew/3.13.rst:1794 -msgid "" -"Both modules are now :term:`soft deprecated`, with :mod:`argparse` preferred " -"for new projects. This is a new soft-deprecation for the :mod:`!getopt` " -"module, whereas the :mod:`!optparse` module was already *de facto* soft " -"deprecated. (Contributed by Victor Stinner in :gh:`106535`.)" -msgstr "" - -#: ../../whatsnew/3.13.rst:1800 +#: ../../whatsnew/3.13.rst:1815 msgid ":mod:`gettext`:" msgstr ":mod:`gettext`:" -#: ../../whatsnew/3.13.rst:1802 +#: ../../whatsnew/3.13.rst:1817 msgid "" "Deprecate non-integer numbers as arguments to functions and methods that " "consider plural forms in the :mod:`!gettext` module, even if no translation " "was found. (Contributed by Serhiy Storchaka in :gh:`88434`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1807 +#: ../../whatsnew/3.13.rst:1822 msgid ":mod:`glob`:" msgstr ":mod:`glob`:" -#: ../../whatsnew/3.13.rst:1809 +#: ../../whatsnew/3.13.rst:1824 msgid "" "Deprecate the undocumented :func:`!glob0` and :func:`!glob1` functions. Use :" "func:`~glob.glob` and pass a :term:`path-like object` specifying the root " @@ -2684,12 +2702,12 @@ msgid "" "in :gh:`117337`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1814 +#: ../../whatsnew/3.13.rst:1829 #: ../../deprecations/pending-removal-in-3.15.rst:21 msgid ":mod:`http.server`:" msgstr ":mod:`http.server`:" -#: ../../whatsnew/3.13.rst:1816 +#: ../../whatsnew/3.13.rst:1831 msgid "" "Deprecate :class:`~http.server.CGIHTTPRequestHandler`, to be removed in " "Python 3.15. Process-based CGI HTTP servers have been out of favor for a " @@ -2698,29 +2716,29 @@ msgid "" "by Gregory P. Smith in :gh:`109096`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1823 +#: ../../whatsnew/3.13.rst:1838 msgid "" "Deprecate the :option:`!--cgi` flag to the :program:`python -m http.server` " "command-line interface, to be removed in Python 3.15. (Contributed by " "Gregory P. Smith in :gh:`109096`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1828 +#: ../../whatsnew/3.13.rst:1843 msgid ":mod:`mimetypes`:" msgstr ":mod:`mimetypes`:" -#: ../../whatsnew/3.13.rst:1830 +#: ../../whatsnew/3.13.rst:1845 msgid "" ":term:`Soft-deprecate ` file path arguments to :func:" "`~mimetypes.guess_type`, use :func:`~mimetypes.guess_file_type` instead. " "(Contributed by Serhiy Storchaka in :gh:`66543`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1835 +#: ../../whatsnew/3.13.rst:1850 msgid ":mod:`re`:" msgstr ":mod:`re`:" -#: ../../whatsnew/3.13.rst:1837 +#: ../../whatsnew/3.13.rst:1852 msgid "" "Deprecate passing the optional *maxsplit*, *count*, or *flags* arguments as " "positional arguments to the module-level :func:`~re.split`, :func:`~re.sub`, " @@ -2729,46 +2747,46 @@ msgid "" "by Serhiy Storchaka in :gh:`56166`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1844 +#: ../../whatsnew/3.13.rst:1859 #: ../../deprecations/pending-removal-in-3.15.rst:42 msgid ":mod:`pathlib`:" msgstr ":mod:`pathlib`:" -#: ../../whatsnew/3.13.rst:1846 +#: ../../whatsnew/3.13.rst:1861 msgid "" "Deprecate :meth:`.PurePath.is_reserved`, to be removed in Python 3.15. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows. (Contributed " "by Barney Gale in :gh:`88569`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1851 +#: ../../whatsnew/3.13.rst:1866 #: ../../deprecations/pending-removal-in-3.15.rst:48 msgid ":mod:`platform`:" msgstr ":mod:`platform`:" -#: ../../whatsnew/3.13.rst:1853 +#: ../../whatsnew/3.13.rst:1868 msgid "" "Deprecate :func:`~platform.java_ver`, to be removed in Python 3.15. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested. (Contributed by Nikita Sobolev in :gh:`116349`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1859 +#: ../../whatsnew/3.13.rst:1874 msgid ":mod:`pydoc`:" msgstr ":mod:`pydoc`:" -#: ../../whatsnew/3.13.rst:1861 +#: ../../whatsnew/3.13.rst:1876 msgid "" "Deprecate the undocumented :func:`!ispackage` function. (Contributed by " "Zackery Spytz in :gh:`64020`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1864 +#: ../../whatsnew/3.13.rst:1879 #: ../../deprecations/pending-removal-in-3.14.rst:91 msgid ":mod:`sqlite3`:" msgstr ":mod:`sqlite3`:" -#: ../../whatsnew/3.13.rst:1866 +#: ../../whatsnew/3.13.rst:1881 msgid "" "Deprecate passing more than one positional argument to the :func:`~sqlite3." "connect` function and the :class:`~sqlite3.Connection` constructor. The " @@ -2776,7 +2794,7 @@ msgid "" "by Erlend E. Aasland in :gh:`107948`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1872 +#: ../../whatsnew/3.13.rst:1887 msgid "" "Deprecate passing name, number of arguments, and the callable as keyword " "arguments for :meth:`.Connection.create_function` and :meth:`.Connection." @@ -2784,7 +2802,7 @@ msgid "" "3.15. (Contributed by Erlend E. Aasland in :gh:`108278`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1878 +#: ../../whatsnew/3.13.rst:1893 msgid "" "Deprecate passing the callback callable by keyword for the :meth:`~sqlite3." "Connection.set_authorizer`, :meth:`~sqlite3.Connection." @@ -2794,46 +2812,46 @@ msgid "" "`108278`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1886 +#: ../../whatsnew/3.13.rst:1901 #: ../../deprecations/pending-removal-in-3.16.rst:47 msgid ":mod:`sys`:" msgstr ":mod:`sys`:" -#: ../../whatsnew/3.13.rst:1888 +#: ../../whatsnew/3.13.rst:1903 msgid "" "Deprecate the :func:`~sys._enablelegacywindowsfsencoding` function, to be " "removed in Python 3.16. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " "environment variable instead. (Contributed by Inada Naoki in :gh:`73427`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1893 +#: ../../whatsnew/3.13.rst:1908 #: ../../deprecations/pending-removal-in-3.16.rst:53 msgid ":mod:`tarfile`:" msgstr ":mod:`tarfile`:" -#: ../../whatsnew/3.13.rst:1895 +#: ../../whatsnew/3.13.rst:1910 msgid "" "Deprecate the undocumented and unused :attr:`!TarFile.tarfile` attribute, to " "be removed in Python 3.16. (Contributed in :gh:`115256`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1899 +#: ../../whatsnew/3.13.rst:1914 msgid ":mod:`traceback`:" msgstr ":mod:`traceback`:" -#: ../../whatsnew/3.13.rst:1901 +#: ../../whatsnew/3.13.rst:1916 msgid "" "Deprecate the :attr:`.TracebackException.exc_type` attribute. Use :attr:`." "TracebackException.exc_type_str` instead. (Contributed by Irit Katriel in :" "gh:`112332`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1905 +#: ../../whatsnew/3.13.rst:1920 #: ../../deprecations/pending-removal-in-3.15.rst:71 msgid ":mod:`typing`:" msgstr ":mod:`typing`:" -#: ../../whatsnew/3.13.rst:1907 +#: ../../whatsnew/3.13.rst:1922 msgid "" "Deprecate the undocumented keyword argument syntax for creating :class:" "`~typing.NamedTuple` classes (e.g. ``Point = NamedTuple(\"Point\", x=int, " @@ -2841,7 +2859,7 @@ msgid "" "functional syntax instead. (Contributed by Alex Waygood in :gh:`105566`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1914 +#: ../../whatsnew/3.13.rst:1929 msgid "" "Deprecate omitting the *fields* parameter when creating a :class:`~typing." "NamedTuple` or :class:`typing.TypedDict` class, and deprecate passing " @@ -2853,7 +2871,7 @@ msgid "" "Alex Waygood in :gh:`105566` and :gh:`105570`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1924 +#: ../../whatsnew/3.13.rst:1939 msgid "" "Deprecate the :func:`typing.no_type_check_decorator` decorator function, to " "be removed in in Python 3.15. After eight years in the :mod:`typing` module, " @@ -2861,7 +2879,7 @@ msgid "" "Waygood in :gh:`106309`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1930 +#: ../../whatsnew/3.13.rst:1945 msgid "" "Deprecate :data:`typing.AnyStr`. In Python 3.16, it will be removed from " "``typing.__all__``, and a :exc:`DeprecationWarning` will be emitted at " @@ -2870,12 +2888,12 @@ msgid "" "(Contributed by Michael The in :gh:`107116`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1938 +#: ../../whatsnew/3.13.rst:1953 #: ../../deprecations/pending-removal-in-3.15.rst:84 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../whatsnew/3.13.rst:1940 +#: ../../whatsnew/3.13.rst:1955 msgid "" "Deprecate the :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:" "`~wave.Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :" @@ -3780,11 +3798,11 @@ msgstr "" ":meth:`zipimport.zipimporter.load_module` 已被棄用:請改用 :meth:`~zipimport." "zipimporter.exec_module`。" -#: ../../whatsnew/3.13.rst:1957 +#: ../../whatsnew/3.13.rst:1972 msgid "CPython Bytecode Changes" msgstr "" -#: ../../whatsnew/3.13.rst:1959 +#: ../../whatsnew/3.13.rst:1974 msgid "" "The oparg of :opcode:`YIELD_VALUE` is now ``1`` if the yield is part of a " "yield-from or await, and ``0`` otherwise. The oparg of :opcode:`RESUME` was " @@ -3793,97 +3811,97 @@ msgid "" "`111354`.)" msgstr "" -#: ../../whatsnew/3.13.rst:1967 +#: ../../whatsnew/3.13.rst:1982 msgid "C API Changes" msgstr "C API 變更" -#: ../../whatsnew/3.13.rst:1972 +#: ../../whatsnew/3.13.rst:1987 msgid "" "Add the :ref:`PyMonitoring C API ` for generating :pep:" "`669` monitoring events:" msgstr "" -#: ../../whatsnew/3.13.rst:1975 +#: ../../whatsnew/3.13.rst:1990 msgid ":c:type:`PyMonitoringState`" msgstr ":c:type:`PyMonitoringState`" -#: ../../whatsnew/3.13.rst:1976 +#: ../../whatsnew/3.13.rst:1991 msgid ":c:func:`PyMonitoring_FirePyStartEvent`" msgstr ":c:func:`PyMonitoring_FirePyStartEvent`" -#: ../../whatsnew/3.13.rst:1977 +#: ../../whatsnew/3.13.rst:1992 msgid ":c:func:`PyMonitoring_FirePyResumeEvent`" msgstr ":c:func:`PyMonitoring_FirePyResumeEvent`" -#: ../../whatsnew/3.13.rst:1978 +#: ../../whatsnew/3.13.rst:1993 msgid ":c:func:`PyMonitoring_FirePyReturnEvent`" msgstr ":c:func:`PyMonitoring_FirePyReturnEvent`" -#: ../../whatsnew/3.13.rst:1979 +#: ../../whatsnew/3.13.rst:1994 msgid ":c:func:`PyMonitoring_FirePyYieldEvent`" msgstr ":c:func:`PyMonitoring_FirePyYieldEvent`" -#: ../../whatsnew/3.13.rst:1980 +#: ../../whatsnew/3.13.rst:1995 msgid ":c:func:`PyMonitoring_FireCallEvent`" msgstr ":c:func:`PyMonitoring_FireCallEvent`" -#: ../../whatsnew/3.13.rst:1981 +#: ../../whatsnew/3.13.rst:1996 msgid ":c:func:`PyMonitoring_FireLineEvent`" msgstr ":c:func:`PyMonitoring_FireLineEvent`" -#: ../../whatsnew/3.13.rst:1982 +#: ../../whatsnew/3.13.rst:1997 msgid ":c:func:`PyMonitoring_FireJumpEvent`" msgstr ":c:func:`PyMonitoring_FireJumpEvent`" -#: ../../whatsnew/3.13.rst:1983 +#: ../../whatsnew/3.13.rst:1998 msgid ":c:func:`PyMonitoring_FireBranchEvent`" msgstr ":c:func:`PyMonitoring_FireBranchEvent`" -#: ../../whatsnew/3.13.rst:1984 +#: ../../whatsnew/3.13.rst:1999 msgid ":c:func:`PyMonitoring_FireCReturnEvent`" msgstr ":c:func:`PyMonitoring_FireCReturnEvent`" -#: ../../whatsnew/3.13.rst:1985 +#: ../../whatsnew/3.13.rst:2000 msgid ":c:func:`PyMonitoring_FirePyThrowEvent`" msgstr ":c:func:`PyMonitoring_FirePyThrowEvent`" -#: ../../whatsnew/3.13.rst:1986 +#: ../../whatsnew/3.13.rst:2001 msgid ":c:func:`PyMonitoring_FireRaiseEvent`" msgstr ":c:func:`PyMonitoring_FireRaiseEvent`" -#: ../../whatsnew/3.13.rst:1987 +#: ../../whatsnew/3.13.rst:2002 msgid ":c:func:`PyMonitoring_FireCRaiseEvent`" msgstr ":c:func:`PyMonitoring_FireCRaiseEvent`" -#: ../../whatsnew/3.13.rst:1988 +#: ../../whatsnew/3.13.rst:2003 msgid ":c:func:`PyMonitoring_FireReraiseEvent`" msgstr ":c:func:`PyMonitoring_FireReraiseEvent`" -#: ../../whatsnew/3.13.rst:1989 +#: ../../whatsnew/3.13.rst:2004 msgid ":c:func:`PyMonitoring_FireExceptionHandledEvent`" msgstr ":c:func:`PyMonitoring_FireExceptionHandledEvent`" -#: ../../whatsnew/3.13.rst:1990 +#: ../../whatsnew/3.13.rst:2005 msgid ":c:func:`PyMonitoring_FirePyUnwindEvent`" msgstr ":c:func:`PyMonitoring_FirePyUnwindEvent`" -#: ../../whatsnew/3.13.rst:1991 +#: ../../whatsnew/3.13.rst:2006 msgid ":c:func:`PyMonitoring_FireStopIterationEvent`" msgstr ":c:func:`PyMonitoring_FireStopIterationEvent`" -#: ../../whatsnew/3.13.rst:1992 +#: ../../whatsnew/3.13.rst:2007 msgid ":c:func:`PyMonitoring_EnterScope`" msgstr ":c:func:`PyMonitoring_EnterScope`" -#: ../../whatsnew/3.13.rst:1993 +#: ../../whatsnew/3.13.rst:2008 msgid ":c:func:`PyMonitoring_ExitScope`" msgstr ":c:func:`PyMonitoring_ExitScope`" -#: ../../whatsnew/3.13.rst:1995 +#: ../../whatsnew/3.13.rst:2010 msgid "(Contributed by Irit Katriel in :gh:`111997`)." -msgstr "" +msgstr "(由 Irit Katriel 在 :gh:`111997` 中貢獻。)" -#: ../../whatsnew/3.13.rst:1997 +#: ../../whatsnew/3.13.rst:2012 msgid "" "Add :c:type:`PyMutex`, a lightweight mutex that occupies a single byte, and " "the new :c:func:`PyMutex_Lock` and :c:func:`PyMutex_Unlock` functions. :c:" @@ -3891,52 +3909,52 @@ msgid "" "operation needs to block. (Contributed by Sam Gross in :gh:`108724`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2003 +#: ../../whatsnew/3.13.rst:2018 msgid "" "Add the :ref:`PyTime C API ` to provide access to system clocks:" msgstr "" -#: ../../whatsnew/3.13.rst:2005 +#: ../../whatsnew/3.13.rst:2020 msgid ":c:type:`PyTime_t`." msgstr ":c:type:`PyTime_t`。" -#: ../../whatsnew/3.13.rst:2006 +#: ../../whatsnew/3.13.rst:2021 msgid ":c:var:`PyTime_MIN` and :c:var:`PyTime_MAX`." msgstr "" -#: ../../whatsnew/3.13.rst:2007 +#: ../../whatsnew/3.13.rst:2022 msgid ":c:func:`PyTime_AsSecondsDouble`." msgstr ":c:func:`PyTime_AsSecondsDouble`。" -#: ../../whatsnew/3.13.rst:2008 +#: ../../whatsnew/3.13.rst:2023 msgid ":c:func:`PyTime_Monotonic`." msgstr ":c:func:`PyTime_Monotonic`。" -#: ../../whatsnew/3.13.rst:2009 +#: ../../whatsnew/3.13.rst:2024 msgid ":c:func:`PyTime_MonotonicRaw`." msgstr ":c:func:`PyTime_MonotonicRaw`。" -#: ../../whatsnew/3.13.rst:2010 +#: ../../whatsnew/3.13.rst:2025 msgid ":c:func:`PyTime_PerfCounter`." msgstr ":c:func:`PyTime_PerfCounter`。" -#: ../../whatsnew/3.13.rst:2011 +#: ../../whatsnew/3.13.rst:2026 msgid ":c:func:`PyTime_PerfCounterRaw`." msgstr ":c:func:`PyTime_PerfCounterRaw`。" -#: ../../whatsnew/3.13.rst:2012 +#: ../../whatsnew/3.13.rst:2027 msgid ":c:func:`PyTime_Time`." msgstr ":c:func:`PyTime_Time`。" -#: ../../whatsnew/3.13.rst:2013 +#: ../../whatsnew/3.13.rst:2028 msgid ":c:func:`PyTime_TimeRaw`." msgstr ":c:func:`PyTime_TimeRaw`。" -#: ../../whatsnew/3.13.rst:2015 +#: ../../whatsnew/3.13.rst:2030 msgid "(Contributed by Victor Stinner and Petr Viktorin in :gh:`110850`.)" msgstr "(由 Victor Stinner 和 Petr Viktorin 在 :gh:`110850` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2017 +#: ../../whatsnew/3.13.rst:2032 msgid "" "Add the :c:func:`PyDict_ContainsString` function with the same behavior as :" "c:func:`PyDict_Contains`, but *key* is specified as a :c:expr:`const char*` " @@ -3944,7 +3962,7 @@ msgid "" "by Victor Stinner in :gh:`108314`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2023 +#: ../../whatsnew/3.13.rst:2038 msgid "" "Add the :c:func:`PyDict_GetItemRef` and :c:func:`PyDict_GetItemStringRef` " "functions, which behave similarly to :c:func:`PyDict_GetItemWithError`, but " @@ -3954,7 +3972,7 @@ msgid "" "`106004`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2031 +#: ../../whatsnew/3.13.rst:2046 msgid "" "Add the :c:func:`PyDict_SetDefaultRef` function, which behaves similarly to :" "c:func:`PyDict_SetDefault`, but returns a :term:`strong reference` instead " @@ -3963,7 +3981,7 @@ msgid "" "dictionary. (Contributed by Sam Gross in :gh:`112066`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2039 +#: ../../whatsnew/3.13.rst:2054 msgid "" "Add the :c:func:`PyDict_Pop` and :c:func:`PyDict_PopString` functions to " "remove a key from a dictionary and optionally return the removed value. This " @@ -3972,7 +3990,7 @@ msgid "" "Victor Stinner in :gh:`111262`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2046 +#: ../../whatsnew/3.13.rst:2061 msgid "" "Add the :c:func:`PyMapping_GetOptionalItem` and :c:func:" "`PyMapping_GetOptionalItemString` functions as alternatives to :c:func:" @@ -3983,7 +4001,7 @@ msgid "" "gh:`106307`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2056 +#: ../../whatsnew/3.13.rst:2071 msgid "" "Add the :c:func:`PyObject_GetOptionalAttr` and :c:func:" "`PyObject_GetOptionalAttrString` functions as alternatives to :c:func:" @@ -3994,37 +4012,37 @@ msgid "" "Serhiy Storchaka in :gh:`106521`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2066 +#: ../../whatsnew/3.13.rst:2081 msgid "" "Add the :c:func:`PyErr_FormatUnraisable` function as an extension to :c:func:" "`PyErr_WriteUnraisable` that allows customizing the warning message. " "(Contributed by Serhiy Storchaka in :gh:`108082`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2071 +#: ../../whatsnew/3.13.rst:2086 msgid "" "Add new functions that return a :term:`strong reference` instead of a :term:" "`borrowed reference` for frame locals, globals, and builtins, as part of :" "ref:`PEP 667 `:" msgstr "" -#: ../../whatsnew/3.13.rst:2075 +#: ../../whatsnew/3.13.rst:2090 msgid ":c:func:`PyEval_GetFrameBuiltins` replaces :c:func:`PyEval_GetBuiltins`" msgstr ":c:func:`PyEval_GetFrameBuiltins` 取代 :c:func:`PyEval_GetBuiltins`" -#: ../../whatsnew/3.13.rst:2076 +#: ../../whatsnew/3.13.rst:2091 msgid ":c:func:`PyEval_GetFrameGlobals` replaces :c:func:`PyEval_GetGlobals`" msgstr ":c:func:`PyEval_GetFrameGlobals` 取代 :c:func:`PyEval_GetGlobals`" -#: ../../whatsnew/3.13.rst:2077 +#: ../../whatsnew/3.13.rst:2092 msgid ":c:func:`PyEval_GetFrameLocals` replaces :c:func:`PyEval_GetLocals`" msgstr ":c:func:`PyEval_GetFrameLocals` 取代 :c:func:`PyEval_GetLocals`" -#: ../../whatsnew/3.13.rst:2079 +#: ../../whatsnew/3.13.rst:2094 msgid "(Contributed by Mark Shannon and Tian Gao in :gh:`74929`.)" msgstr "(由 Mark Shannon 和 Tian Gao 在 :gh:`74929` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2081 +#: ../../whatsnew/3.13.rst:2096 msgid "" "Add the :c:func:`Py_GetConstant` and :c:func:`Py_GetConstantBorrowed` " "functions to get :term:`strong ` or :term:`borrowed " @@ -4033,7 +4051,7 @@ msgid "" "constant zero. (Contributed by Victor Stinner in :gh:`115754`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2088 +#: ../../whatsnew/3.13.rst:2103 msgid "" "Add the :c:func:`PyImport_AddModuleRef` function as a replacement for :c:" "func:`PyImport_AddModule` that returns a :term:`strong reference` instead of " @@ -4041,35 +4059,35 @@ msgid "" "`105922`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2093 +#: ../../whatsnew/3.13.rst:2108 msgid "" "Add the :c:func:`Py_IsFinalizing` function to check whether the main Python " "interpreter is :term:`shutting down `. (Contributed by " "Victor Stinner in :gh:`108014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2098 +#: ../../whatsnew/3.13.rst:2113 msgid "" "Add the :c:func:`PyList_GetItemRef` function as a replacement for :c:func:" "`PyList_GetItem` that returns a :term:`strong reference` instead of a :term:" "`borrowed reference`. (Contributed by Sam Gross in :gh:`114329`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2103 +#: ../../whatsnew/3.13.rst:2118 msgid "" "Add the :c:func:`PyList_Extend` and :c:func:`PyList_Clear` functions, " "mirroring the Python :meth:`!list.extend` and :meth:`!list.clear` methods. " "(Contributed by Victor Stinner in :gh:`111138`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2107 +#: ../../whatsnew/3.13.rst:2122 msgid "" "Add the :c:func:`PyLong_AsInt` function. It behaves similarly to :c:func:" "`PyLong_AsLong`, but stores the result in a C :c:expr:`int` instead of a C :" "c:expr:`long`. (Contributed by Victor Stinner in :gh:`108014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2112 +#: ../../whatsnew/3.13.rst:2127 msgid "" "Add the :c:func:`PyLong_AsNativeBytes`, :c:func:`PyLong_FromNativeBytes`, " "and :c:func:`PyLong_FromUnsignedNativeBytes` functions to simplify " @@ -4077,27 +4095,27 @@ msgid "" "(Contributed by Steve Dower in :gh:`111140`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2118 +#: ../../whatsnew/3.13.rst:2133 msgid "" "Add :c:func:`PyModule_Add` function, which is similar to :c:func:" "`PyModule_AddObjectRef` and :c:func:`PyModule_AddObject`, but always steals " "a reference to the value. (Contributed by Serhiy Storchaka in :gh:`86493`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2123 +#: ../../whatsnew/3.13.rst:2138 msgid "" "Add the :c:func:`PyObject_GenericHash` function that implements the default " "hashing function of a Python object. (Contributed by Serhiy Storchaka in :gh:" "`113024`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2127 +#: ../../whatsnew/3.13.rst:2142 msgid "" "Add the :c:func:`Py_HashPointer` function to hash a raw pointer. " "(Contributed by Victor Stinner in :gh:`111545`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2130 +#: ../../whatsnew/3.13.rst:2145 msgid "" "Add the :c:func:`PyObject_VisitManagedDict` and :c:func:" "`PyObject_ClearManagedDict` functions. which must be called by the traverse " @@ -4106,7 +4124,7 @@ msgid "" "with Python 3.11 and 3.12. (Contributed by Victor Stinner in :gh:`107073`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2138 +#: ../../whatsnew/3.13.rst:2153 msgid "" "Add the :c:func:`PyRefTracer_SetTracer` and :c:func:`PyRefTracer_GetTracer` " "functions, which enable tracking object creation and destruction in the same " @@ -4114,14 +4132,14 @@ msgid "" "in :gh:`93502`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2144 +#: ../../whatsnew/3.13.rst:2159 msgid "" "Add the :c:func:`PySys_AuditTuple` function as an alternative to :c:func:" "`PySys_Audit` that takes event arguments as a Python :class:`tuple` object. " "(Contributed by Victor Stinner in :gh:`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2149 +#: ../../whatsnew/3.13.rst:2164 msgid "" "Add the :c:func:`PyThreadState_GetUnchecked()` function as an alternative " "to :c:func:`PyThreadState_Get()` that doesn't kill the process with a fatal " @@ -4129,7 +4147,7 @@ msgid "" "result is ``NULL``. (Contributed by Victor Stinner in :gh:`108867`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2155 +#: ../../whatsnew/3.13.rst:2170 msgid "" "Add the :c:func:`PyType_GetFullyQualifiedName` function to get the type's " "fully qualified name. The module name is prepended if :attr:`type." @@ -4137,14 +4155,14 @@ msgid "" "``'__main__'``. (Contributed by Victor Stinner in :gh:`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2161 +#: ../../whatsnew/3.13.rst:2176 msgid "" "Add the :c:func:`PyType_GetModuleName` function to get the type's module " "name. This is equivalent to getting the :attr:`type.__module__` attribute. " "(Contributed by Eric Snow and Victor Stinner in :gh:`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2166 +#: ../../whatsnew/3.13.rst:2181 msgid "" "Add the :c:func:`PyUnicode_EqualToUTF8AndSize` and :c:func:" "`PyUnicode_EqualToUTF8` functions to compare a Unicode object with a :c:expr:" @@ -4153,7 +4171,7 @@ msgid "" "Storchaka in :gh:`110289`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2173 +#: ../../whatsnew/3.13.rst:2188 msgid "" "Add the :c:func:`PyWeakref_GetRef` function as an alternative to :c:func:" "`PyWeakref_GetObject` that returns a :term:`strong reference` or ``NULL`` if " @@ -4161,47 +4179,51 @@ msgid "" "`105927`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2179 +#: ../../whatsnew/3.13.rst:2194 msgid "Add fixed variants of functions which silently ignore errors:" msgstr "" -#: ../../whatsnew/3.13.rst:2181 +#: ../../whatsnew/3.13.rst:2196 msgid "" ":c:func:`PyObject_HasAttrWithError` replaces :c:func:`PyObject_HasAttr`." -msgstr "" +msgstr ":c:func:`PyObject_HasAttrWithError` 取代 :c:func:`PyObject_HasAttr`。" -#: ../../whatsnew/3.13.rst:2182 +#: ../../whatsnew/3.13.rst:2197 msgid "" ":c:func:`PyObject_HasAttrStringWithError` replaces :c:func:" "`PyObject_HasAttrString`." msgstr "" +":c:func:`PyObject_HasAttrStringWithError` 取代 :c:func:" +"`PyObject_HasAttrString`。" -#: ../../whatsnew/3.13.rst:2184 +#: ../../whatsnew/3.13.rst:2199 msgid "" ":c:func:`PyMapping_HasKeyWithError` replaces :c:func:`PyMapping_HasKey`." -msgstr "" +msgstr ":c:func:`PyMapping_HasKeyWithError` 取代 :c:func:`PyMapping_HasKey`。" -#: ../../whatsnew/3.13.rst:2185 +#: ../../whatsnew/3.13.rst:2200 msgid "" ":c:func:`PyMapping_HasKeyStringWithError` replaces :c:func:" "`PyMapping_HasKeyString`." msgstr "" +":c:func:`PyMapping_HasKeyStringWithError` 取代 :c:func:" +"`PyMapping_HasKeyString`。" -#: ../../whatsnew/3.13.rst:2188 +#: ../../whatsnew/3.13.rst:2203 msgid "" "The new functions return ``-1`` for errors and the standard ``1`` for true " "and ``0`` for false." msgstr "" -#: ../../whatsnew/3.13.rst:2191 +#: ../../whatsnew/3.13.rst:2206 msgid "(Contributed by Serhiy Storchaka in :gh:`108511`.)" msgstr "(由 Serhiy Storchaka 在 :gh:`108511` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2195 +#: ../../whatsnew/3.13.rst:2210 msgid "Changed C APIs" msgstr "" -#: ../../whatsnew/3.13.rst:2197 +#: ../../whatsnew/3.13.rst:2212 msgid "" "The *keywords* parameter of :c:func:`PyArg_ParseTupleAndKeywords` and :c:" "func:`PyArg_VaParseTupleAndKeywords` now has type :c:expr:`char * const *` " @@ -4214,20 +4236,20 @@ msgid "" "`65210`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2209 +#: ../../whatsnew/3.13.rst:2224 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` now supports non-ASCII keyword " "parameter names. (Contributed by Serhiy Storchaka in :gh:`110815`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2213 +#: ../../whatsnew/3.13.rst:2228 msgid "" "The :c:func:`!PyCode_GetFirstFree` function is now unstable API and is now " "named :c:func:`PyUnstable_Code_GetFirstFree`. (Contributed by Bogdan " "Romanyuk in :gh:`115781`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2217 +#: ../../whatsnew/3.13.rst:2232 msgid "" "The :c:func:`PyDict_GetItem`, :c:func:`PyDict_GetItemString`, :c:func:" "`PyMapping_HasKey`, :c:func:`PyMapping_HasKeyString`, :c:func:" @@ -4238,35 +4260,35 @@ msgid "" "documentation. (Contributed by Serhiy Storchaka in :gh:`106672`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2226 +#: ../../whatsnew/3.13.rst:2241 msgid "" "Add support for the ``%T``, ``%#T``, ``%N`` and ``%#N`` formats to :c:func:" "`PyUnicode_FromFormat`:" msgstr "" -#: ../../whatsnew/3.13.rst:2229 +#: ../../whatsnew/3.13.rst:2244 msgid "``%T``: Get the fully qualified name of an object type" msgstr "" -#: ../../whatsnew/3.13.rst:2230 +#: ../../whatsnew/3.13.rst:2245 msgid "``%#T``: As above, but use a colon as the separator" msgstr "" -#: ../../whatsnew/3.13.rst:2231 +#: ../../whatsnew/3.13.rst:2246 msgid "``%N``: Get the fully qualified name of a type" msgstr "" -#: ../../whatsnew/3.13.rst:2232 +#: ../../whatsnew/3.13.rst:2247 msgid "``%#N``: As above, but use a colon as the separator" msgstr "" -#: ../../whatsnew/3.13.rst:2234 +#: ../../whatsnew/3.13.rst:2249 msgid "" "See :pep:`737` for more information. (Contributed by Victor Stinner in :gh:" "`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2237 +#: ../../whatsnew/3.13.rst:2252 msgid "" "You no longer have to define the ``PY_SSIZE_T_CLEAN`` macro before " "including :file:`Python.h` when using ``#`` formats in :ref:`format codes " @@ -4275,7 +4297,7 @@ msgid "" "`104922`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2243 +#: ../../whatsnew/3.13.rst:2258 msgid "" "If Python is built in :ref:`debug mode ` or :option:`with " "assertions <--with-assertions>`, :c:func:`PyTuple_SET_ITEM` and :c:func:" @@ -4283,61 +4305,61 @@ msgid "" "(Contributed by Victor Stinner in :gh:`106168`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2251 +#: ../../whatsnew/3.13.rst:2266 msgid "Limited C API Changes" msgstr "" -#: ../../whatsnew/3.13.rst:2253 +#: ../../whatsnew/3.13.rst:2268 msgid "The following functions are now included in the Limited C API:" msgstr "" -#: ../../whatsnew/3.13.rst:2255 +#: ../../whatsnew/3.13.rst:2270 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../whatsnew/3.13.rst:2256 +#: ../../whatsnew/3.13.rst:2271 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../whatsnew/3.13.rst:2257 +#: ../../whatsnew/3.13.rst:2272 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../whatsnew/3.13.rst:2258 +#: ../../whatsnew/3.13.rst:2273 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../whatsnew/3.13.rst:2259 +#: ../../whatsnew/3.13.rst:2274 msgid ":c:func:`PySys_Audit`" msgstr ":c:func:`PySys_Audit`" -#: ../../whatsnew/3.13.rst:2260 +#: ../../whatsnew/3.13.rst:2275 msgid ":c:func:`PySys_AuditTuple`" msgstr ":c:func:`PySys_AuditTuple`" -#: ../../whatsnew/3.13.rst:2261 +#: ../../whatsnew/3.13.rst:2276 msgid ":c:func:`PyType_GetModuleByDef`" msgstr ":c:func:`PyType_GetModuleByDef`" -#: ../../whatsnew/3.13.rst:2263 +#: ../../whatsnew/3.13.rst:2278 msgid "" "(Contributed by Victor Stinner in :gh:`85283`, :gh:`85283`, and :gh:" "`116936`.)" msgstr "" "(由 Victor Stinner 貢獻於 :gh:`85283`、:gh:`85283` 和 :gh:`116936`。)" -#: ../../whatsnew/3.13.rst:2265 +#: ../../whatsnew/3.13.rst:2280 msgid "" "Python built with :option:`--with-trace-refs` (tracing references) now " "supports the :ref:`Limited API `. (Contributed by Victor " "Stinner in :gh:`108634`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2271 +#: ../../whatsnew/3.13.rst:2286 msgid "Removed C APIs" msgstr "移除的 C API" -#: ../../whatsnew/3.13.rst:2273 +#: ../../whatsnew/3.13.rst:2288 msgid "" "Remove several functions, macros, variables, etc with names prefixed by " "``_Py`` or ``_PY`` (which are considered private). If your project is " @@ -4347,13 +4369,13 @@ msgid "" "Victor Stinner. (Contributed by Victor Stinner in :gh:`106320`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2281 +#: ../../whatsnew/3.13.rst:2296 msgid "" "Remove old buffer protocols deprecated in Python 3.0. Use :ref:" "`bufferobjects` instead." msgstr "" -#: ../../whatsnew/3.13.rst:2284 +#: ../../whatsnew/3.13.rst:2299 msgid "" ":c:func:`!PyObject_CheckReadBuffer`: Use :c:func:`PyObject_CheckBuffer` to " "test whether the object supports the buffer protocol. Note that :c:func:" @@ -4362,7 +4384,7 @@ msgid "" "example of :c:func:`PyObject_GetBuffer`." msgstr "" -#: ../../whatsnew/3.13.rst:2292 +#: ../../whatsnew/3.13.rst:2307 msgid "" ":c:func:`!PyObject_AsCharBuffer`, :c:func:`!PyObject_AsReadBuffer`: Use :c:" "func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release` instead:" @@ -4370,7 +4392,7 @@ msgstr "" ":c:func:`!PyObject_AsCharBuffer`、:c:func:`!PyObject_AsReadBuffer`:請改用 :" "c:func:`PyObject_GetBuffer` 和 :c:func:`PyBuffer_Release`。" -#: ../../whatsnew/3.13.rst:2295 +#: ../../whatsnew/3.13.rst:2310 msgid "" "Py_buffer view;\n" "if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) < 0) {\n" @@ -4381,7 +4403,7 @@ msgid "" "PyBuffer_Release(&view);" msgstr "" -#: ../../whatsnew/3.13.rst:2305 +#: ../../whatsnew/3.13.rst:2320 msgid "" ":c:func:`!PyObject_AsWriteBuffer`: Use :c:func:`PyObject_GetBuffer` and :c:" "func:`PyBuffer_Release` instead:" @@ -4389,7 +4411,7 @@ msgstr "" ":c:func:`!PyObject_AsWriteBuffer`:請改用 :c:func:`PyObject_GetBuffer` 和 :c:" "func:`PyBuffer_Release`。" -#: ../../whatsnew/3.13.rst:2308 +#: ../../whatsnew/3.13.rst:2323 msgid "" "Py_buffer view;\n" "if (PyObject_GetBuffer(obj, &view, PyBUF_WRITABLE) < 0) {\n" @@ -4399,15 +4421,15 @@ msgid "" "PyBuffer_Release(&view);" msgstr "" -#: ../../whatsnew/3.13.rst:2317 +#: ../../whatsnew/3.13.rst:2332 msgid "(Contributed by Inada Naoki in :gh:`85275`.)" msgstr "(由 Inada Naoki 貢獻於 :gh:`85275`。)" -#: ../../whatsnew/3.13.rst:2319 +#: ../../whatsnew/3.13.rst:2334 msgid "Remove various functions deprecated in Python 3.9:" msgstr "" -#: ../../whatsnew/3.13.rst:2321 +#: ../../whatsnew/3.13.rst:2336 msgid "" ":c:func:`!PyEval_CallObject`, :c:func:`!PyEval_CallObjectWithKeywords`: Use :" "c:func:`PyObject_CallNoArgs` or :c:func:`PyObject_Call` instead." @@ -4415,7 +4437,7 @@ msgstr "" ":c:func:`!PyEval_CallObject`、:c:func:`!PyEval_CallObjectWithKeywords`:請改" "用 :c:func:`PyObject_CallNoArgs` 或 :c:func:`PyObject_Call`。" -#: ../../whatsnew/3.13.rst:2326 +#: ../../whatsnew/3.13.rst:2341 msgid "" "In :c:func:`PyObject_Call`, positional arguments must be a :class:`tuple` " "and must not be ``NULL``, and keyword arguments must be a :class:`dict` or " @@ -4426,32 +4448,32 @@ msgid "" "`PyTuple_New(0) `." msgstr "" -#: ../../whatsnew/3.13.rst:2336 +#: ../../whatsnew/3.13.rst:2351 msgid "" ":c:func:`!PyEval_CallFunction`: Use :c:func:`PyObject_CallFunction` instead." msgstr "" ":c:func:`!PyEval_CallFunction`:請改用 :c:func:`PyObject_CallFunction`。" -#: ../../whatsnew/3.13.rst:2338 +#: ../../whatsnew/3.13.rst:2353 msgid "" ":c:func:`!PyEval_CallMethod`: Use :c:func:`PyObject_CallMethod` instead." msgstr ":c:func:`!PyEval_CallMethod`:請改用 :c:func:`PyObject_CallMethod`。" -#: ../../whatsnew/3.13.rst:2340 +#: ../../whatsnew/3.13.rst:2355 msgid ":c:func:`!PyCFunction_Call`: Use :c:func:`PyObject_Call` instead." msgstr ":c:func:`!PyCFunction_Call`:請改用 :c:func:`PyCFunction_Call`。" -#: ../../whatsnew/3.13.rst:2343 +#: ../../whatsnew/3.13.rst:2358 msgid "(Contributed by Victor Stinner in :gh:`105107`.)" msgstr "(由 Victor Stinner 貢獻於 :gh:`105107`。)" -#: ../../whatsnew/3.13.rst:2345 +#: ../../whatsnew/3.13.rst:2360 msgid "" "Remove the following old functions to configure the Python initialization, " "deprecated in Python 3.11:" msgstr "" -#: ../../whatsnew/3.13.rst:2348 +#: ../../whatsnew/3.13.rst:2363 msgid "" ":c:func:`!PySys_AddWarnOptionUnicode`: Use :c:member:`PyConfig.warnoptions` " "instead." @@ -4459,36 +4481,36 @@ msgstr "" ":c:func:`!PySys_AddWarnOptionUnicode`:請改用 :c:member:`PyConfig." "warnoptions`。" -#: ../../whatsnew/3.13.rst:2350 +#: ../../whatsnew/3.13.rst:2365 msgid "" ":c:func:`!PySys_AddWarnOption`: Use :c:member:`PyConfig.warnoptions` instead." msgstr "" ":c:func:`!PySys_AddWarnOption`:請改用 :c:member:`PyConfig.warnoptions`。" -#: ../../whatsnew/3.13.rst:2352 +#: ../../whatsnew/3.13.rst:2367 msgid ":c:func:`!PySys_AddXOption`: Use :c:member:`PyConfig.xoptions` instead." msgstr ":c:func:`!PySys_AddXOption`:請改用 :c:member:`PyConfig.xoptions`。" -#: ../../whatsnew/3.13.rst:2354 +#: ../../whatsnew/3.13.rst:2369 msgid "" ":c:func:`!PySys_HasWarnOptions`: Use :c:member:`PyConfig.xoptions` instead." msgstr "" ":c:func:`!PySys_HasWarnOptions`:請改用 :c:member:`PyConfig.xoptions`。" -#: ../../whatsnew/3.13.rst:2356 +#: ../../whatsnew/3.13.rst:2371 msgid "" ":c:func:`!PySys_SetPath`: Set :c:member:`PyConfig.module_search_paths` " "instead." msgstr "" ":c:func:`!PySys_SetPath`:請改用 :c:member:`PyConfig.module_search_paths`。" -#: ../../whatsnew/3.13.rst:2358 +#: ../../whatsnew/3.13.rst:2373 msgid "" ":c:func:`!Py_SetPath`: Set :c:member:`PyConfig.module_search_paths` instead." msgstr "" ":c:func:`!Py_SetPath`:請改用 :c:member:`PyConfig.module_search_paths`。" -#: ../../whatsnew/3.13.rst:2360 +#: ../../whatsnew/3.13.rst:2375 msgid "" ":c:func:`!Py_SetStandardStreamEncoding`: Set :c:member:`PyConfig." "stdio_encoding` instead, and set also maybe :c:member:`PyConfig." @@ -4498,14 +4520,14 @@ msgstr "" "stdio_encoding` 並設定可能的 :c:member:`PyConfig.legacy_windows_stdio`\\ " "(在 Windows 上)。" -#: ../../whatsnew/3.13.rst:2363 +#: ../../whatsnew/3.13.rst:2378 msgid "" ":c:func:`!_Py_SetProgramFullPath`: Set :c:member:`PyConfig.executable` " "instead." msgstr "" ":c:func:`!_Py_SetProgramFullPath`:請改用 :c:member:`PyConfig.executable`。" -#: ../../whatsnew/3.13.rst:2366 +#: ../../whatsnew/3.13.rst:2381 msgid "" "Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization " "Configuration ` instead (:pep:`587`), added to Python 3.8. " @@ -4515,7 +4537,7 @@ msgstr "" "(:pep:`587`),這是在 Python 3.8 中新增的。(由 Victor Stinner 於 :gh:" "`105145` 貢獻。)" -#: ../../whatsnew/3.13.rst:2370 +#: ../../whatsnew/3.13.rst:2385 msgid "" "Remove :c:func:`!PyEval_AcquireLock` and :c:func:`!PyEval_ReleaseLock` " "functions, deprecated in Python 3.2. They didn't update the current thread " @@ -4525,25 +4547,25 @@ msgstr "" "些函式在 Python 3.2 中已被廢棄。它們不會更新目前的執行緒狀態。可以用以下函式" "取代:" -#: ../../whatsnew/3.13.rst:2375 +#: ../../whatsnew/3.13.rst:2390 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`;" msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`;" -#: ../../whatsnew/3.13.rst:2376 +#: ../../whatsnew/3.13.rst:2391 msgid "" "low-level :c:func:`PyEval_AcquireThread` and :c:func:`PyEval_RestoreThread`;" msgstr "" "低階的 :c:func:`PyEval_AcquireThread` 和 :c:func:`PyEval_RestoreThread`;" -#: ../../whatsnew/3.13.rst:2377 +#: ../../whatsnew/3.13.rst:2392 msgid "or :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`." msgstr "或 :c:func:`PyGILState_Ensure` 與 :c:func:`PyGILState_Release`。" -#: ../../whatsnew/3.13.rst:2379 +#: ../../whatsnew/3.13.rst:2394 msgid "(Contributed by Victor Stinner in :gh:`105182`.)" msgstr "(由 Victor Stinner 貢獻於 :gh:`105182`。)" -#: ../../whatsnew/3.13.rst:2381 +#: ../../whatsnew/3.13.rst:2396 msgid "" "Remove the :c:func:`!PyEval_ThreadsInitialized` function, deprecated in " "Python 3.9. Since Python 3.7, :c:func:`!Py_Initialize` always creates the " @@ -4552,7 +4574,7 @@ msgid "" "Stinner in :gh:`105182`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2388 +#: ../../whatsnew/3.13.rst:2403 msgid "" "Remove the :c:func:`!_PyInterpreterState_Get` alias to :c:func:" "`PyInterpreterState_Get()` which was kept for backward compatibility with " @@ -4561,14 +4583,14 @@ msgid "" "Stinner in :gh:`106320`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2395 +#: ../../whatsnew/3.13.rst:2410 msgid "" "Remove the private :c:func:`!_PyObject_FastCall` function: use :c:func:`!" "PyObject_Vectorcall` which is available since Python 3.8 (:pep:`590`). " "(Contributed by Victor Stinner in :gh:`106023`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2400 +#: ../../whatsnew/3.13.rst:2415 msgid "" "Remove the ``cpython/pytime.h`` header file, which only contained private " "functions. (Contributed by Victor Stinner in :gh:`106316`.)" @@ -4576,13 +4598,13 @@ msgstr "" "移除只包含私有函式的 ``cpython/pytime.h`` 標頭檔。(由 Victor Stinner 於 :gh:" "`106316` 貢獻。)" -#: ../../whatsnew/3.13.rst:2404 +#: ../../whatsnew/3.13.rst:2419 msgid "" "Remove the undocumented ``PY_TIMEOUT_MAX`` constant from the limited C API. " "(Contributed by Victor Stinner in :gh:`110014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2407 +#: ../../whatsnew/3.13.rst:2422 msgid "" "Remove the old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and " "``Py_TRASHCAN_SAFE_END``. Replace both with the new macros " @@ -4590,15 +4612,15 @@ msgid "" "in :gh:`105111`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2414 +#: ../../whatsnew/3.13.rst:2429 msgid "Deprecated C APIs" msgstr "器用的 C API" -#: ../../whatsnew/3.13.rst:2416 +#: ../../whatsnew/3.13.rst:2431 msgid "Deprecate old Python initialization functions:" msgstr "" -#: ../../whatsnew/3.13.rst:2418 +#: ../../whatsnew/3.13.rst:2433 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:13 msgid "" ":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" @@ -4607,30 +4629,30 @@ msgstr "" ":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" "data:`!warnings.filters`。" -#: ../../whatsnew/3.13.rst:2420 +#: ../../whatsnew/3.13.rst:2435 msgid ":c:func:`Py_GetExecPrefix`: Get :data:`sys.exec_prefix` instead." msgstr ":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" -#: ../../whatsnew/3.13.rst:2422 +#: ../../whatsnew/3.13.rst:2437 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." msgstr ":c:func:`Py_GetPath`:請改用 :data:`sys.path`。" -#: ../../whatsnew/3.13.rst:2424 +#: ../../whatsnew/3.13.rst:2439 msgid ":c:func:`Py_GetPrefix`: Get :data:`sys.prefix` instead." msgstr ":c:func:`Py_GetPrefix`:請改用 :data:`sys.prefix`。" -#: ../../whatsnew/3.13.rst:2426 +#: ../../whatsnew/3.13.rst:2441 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:21 msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" -#: ../../whatsnew/3.13.rst:2428 +#: ../../whatsnew/3.13.rst:2443 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:23 msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" -#: ../../whatsnew/3.13.rst:2430 +#: ../../whatsnew/3.13.rst:2445 #: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" ":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" @@ -4639,32 +4661,32 @@ msgstr "" ":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" "`PYTHONHOME` 環境變數。" -#: ../../whatsnew/3.13.rst:2434 +#: ../../whatsnew/3.13.rst:2449 msgid "(Contributed by Victor Stinner in :gh:`105145`.)" msgstr "(由 Victor Stinner 在 :gh:`105145` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2436 +#: ../../whatsnew/3.13.rst:2451 msgid "" ":term:`Soft deprecate ` the :c:func:`PyEval_GetBuiltins`, :" "c:func:`PyEval_GetGlobals`, and :c:func:`PyEval_GetLocals` functions, which " "return a :term:`borrowed reference`. (Soft deprecated as part of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2442 +#: ../../whatsnew/3.13.rst:2457 msgid "" "Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function, which is just " "an alias to :c:func:`PyImport_ImportModule` since Python 3.3. (Contributed " "by Victor Stinner in :gh:`105396`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2446 +#: ../../whatsnew/3.13.rst:2461 msgid "" ":term:`Soft deprecate ` the :c:func:`PyModule_AddObject` " "function. It should be replaced with :c:func:`PyModule_Add` or :c:func:" "`PyModule_AddObjectRef`. (Contributed by Serhiy Storchaka in :gh:`86493`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2452 +#: ../../whatsnew/3.13.rst:2467 msgid "" "Deprecate the old ``Py_UNICODE`` and ``PY_UNICODE_TYPE`` types and the :c:" "macro:`!Py_UNICODE_WIDE` define. Use the :c:type:`wchar_t` type directly " @@ -4673,7 +4695,7 @@ msgid "" "`105156`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2459 +#: ../../whatsnew/3.13.rst:2474 msgid "" "Deprecate the :c:func:`PyWeakref_GetObject` and :c:func:" "`PyWeakref_GET_OBJECT` functions, which return a :term:`borrowed reference`. " @@ -5050,56 +5072,56 @@ msgstr "" msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" -#: ../../whatsnew/3.13.rst:2479 +#: ../../whatsnew/3.13.rst:2494 msgid "Build Changes" msgstr "建置變更" -#: ../../whatsnew/3.13.rst:2481 +#: ../../whatsnew/3.13.rst:2496 msgid "" "``arm64-apple-ios`` and ``arm64-apple-ios-simulator`` are both now :pep:`11` " "tier 3 platforms. (:ref:`PEP 730 ` written and " "implementation contributed by Russell Keith-Magee in :gh:`114099`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2486 +#: ../../whatsnew/3.13.rst:2501 msgid "" "``aarch64-linux-android`` and ``x86_64-linux-android`` are both now :pep:" "`11` tier 3 platforms. (:ref:`PEP 738 ` " "written and implementation contributed by Malcolm Smith in :gh:`116622`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2491 +#: ../../whatsnew/3.13.rst:2506 msgid "" "``wasm32-wasi`` is now a :pep:`11` tier 2 platform. (Contributed by Brett " "Cannon in :gh:`115192`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2494 +#: ../../whatsnew/3.13.rst:2509 msgid "" "``wasm32-emscripten`` is no longer a :pep:`11` supported platform. " "(Contributed by Brett Cannon in :gh:`115192`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2497 +#: ../../whatsnew/3.13.rst:2512 msgid "" "Building CPython now requires a compiler with support for the C11 atomic " "library, GCC built-in atomic functions, or MSVC interlocked intrinsics." msgstr "" -#: ../../whatsnew/3.13.rst:2500 +#: ../../whatsnew/3.13.rst:2515 msgid "" "Autoconf 2.71 and aclocal 1.16.5 are now required to regenerate the :file:" "`configure` script. (Contributed by Christian Heimes in :gh:`89886` and by " "Victor Stinner in :gh:`112090`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2504 +#: ../../whatsnew/3.13.rst:2519 msgid "" "SQLite 3.15.2 or newer is required to build the :mod:`sqlite3` extension " "module. (Contributed by Erlend Aasland in :gh:`105875`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2508 +#: ../../whatsnew/3.13.rst:2523 msgid "" "CPython now bundles the `mimalloc library`_ by default. It is licensed under " "the MIT license; see :ref:`mimalloc license `. The bundled " @@ -5107,28 +5129,28 @@ msgid "" "Dino Viehland in :gh:`109914`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2516 +#: ../../whatsnew/3.13.rst:2531 msgid "" "The :file:`configure` option :option:`--with-system-libmpdec` now defaults " "to ``yes``. The bundled copy of ``libmpdecimal`` will be removed in Python " "3.15." msgstr "" -#: ../../whatsnew/3.13.rst:2520 +#: ../../whatsnew/3.13.rst:2535 msgid "" "Python built with :file:`configure` :option:`--with-trace-refs` (tracing " "references) is now ABI compatible with the Python release build and :ref:" "`debug build `. (Contributed by Victor Stinner in :gh:`108634`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2525 +#: ../../whatsnew/3.13.rst:2540 msgid "" "On POSIX systems, the pkg-config (``.pc``) filenames now include the ABI " "flags. For example, the free-threaded build generates ``python-3.13t.pc`` " "and the debug build generates ``python-3.13d.pc``." msgstr "" -#: ../../whatsnew/3.13.rst:2529 +#: ../../whatsnew/3.13.rst:2544 msgid "" "The ``errno``, ``fcntl``, ``grp``, ``md5``, ``pwd``, ``resource``, " "``termios``, ``winsound``, ``_ctypes_test``, ``_multiprocessing." @@ -5138,27 +5160,27 @@ msgid "" "`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2538 +#: ../../whatsnew/3.13.rst:2553 msgid "Porting to Python 3.13" msgstr "移植至 Python 3.13" -#: ../../whatsnew/3.13.rst:2540 +#: ../../whatsnew/3.13.rst:2555 msgid "" "This section lists previously described changes and other bugfixes that may " "require changes to your code." msgstr "" -#: ../../whatsnew/3.13.rst:2544 +#: ../../whatsnew/3.13.rst:2559 msgid "Changes in the Python API" msgstr "Python API 的變更" -#: ../../whatsnew/3.13.rst:2548 +#: ../../whatsnew/3.13.rst:2563 msgid "" ":ref:`PEP 667 ` introduces several changes to " "the semantics of :func:`locals` and :attr:`f_locals `:" msgstr "" -#: ../../whatsnew/3.13.rst:2551 +#: ../../whatsnew/3.13.rst:2566 msgid "" "Calling :func:`locals` in an :term:`optimized scope` now produces an " "independent snapshot on each call, and hence no longer implicitly updates " @@ -5170,7 +5192,7 @@ msgid "" "scope. (Changed as part of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2560 +#: ../../whatsnew/3.13.rst:2575 msgid "" "Calling :func:`locals` from a comprehension at module or class scope " "(including via ``exec`` or ``eval``) once more behaves as if the " @@ -5180,7 +5202,7 @@ msgid "" "implementing :pep:`709`. (Changed as part of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2567 +#: ../../whatsnew/3.13.rst:2582 msgid "" "Accessing :attr:`FrameType.f_locals ` in an :term:`optimized " "scope` now returns a write-through proxy rather than a snapshot that gets " @@ -5189,7 +5211,7 @@ msgid "" "of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2573 +#: ../../whatsnew/3.13.rst:2588 msgid "" ":class:`functools.partial` now emits a :exc:`FutureWarning` when used as a " "method. The behavior will change in future Python versions. Wrap it in :func:" @@ -5197,14 +5219,14 @@ msgid "" "Serhiy Storchaka in :gh:`121027`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2579 +#: ../../whatsnew/3.13.rst:2594 msgid "" "An :exc:`OSError` is now raised by :func:`getpass.getuser` for any failure " "to retrieve a username, instead of :exc:`ImportError` on non-Unix platforms " "or :exc:`KeyError` on Unix platforms where the password database is empty." msgstr "" -#: ../../whatsnew/3.13.rst:2584 +#: ../../whatsnew/3.13.rst:2599 msgid "" "The value of the :attr:`!mode` attribute of :class:`gzip.GzipFile` is now a " "string (``'rb'`` or ``'wb'``) instead of an integer (``1`` or ``2``). The " @@ -5213,13 +5235,13 @@ msgid "" "(Contributed by Serhiy Storchaka in :gh:`115961`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2590 +#: ../../whatsnew/3.13.rst:2605 msgid "" ":class:`mailbox.Maildir` now ignores files with a leading dot (``.``). " "(Contributed by Zackery Spytz in :gh:`65559`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2593 +#: ../../whatsnew/3.13.rst:2608 msgid "" ":meth:`pathlib.Path.glob` and :meth:`~pathlib.Path.rglob` now return both " "files and directories if a pattern that ends with \"``**``\" is given, " @@ -5227,25 +5249,25 @@ msgid "" "behavior and only match directories." msgstr "" -#: ../../whatsnew/3.13.rst:2598 +#: ../../whatsnew/3.13.rst:2613 msgid "" "The :mod:`threading` module now expects the :mod:`!_thread` module to have " "an :func:`!_is_main_interpreter` function. This function takes no arguments " "and returns ``True`` if the current interpreter is the main interpreter." msgstr "" -#: ../../whatsnew/3.13.rst:2603 +#: ../../whatsnew/3.13.rst:2618 msgid "" "Any library or application that provides a custom :mod:`!_thread` module " "must provide :func:`!_is_main_interpreter`, just like the module's other " "\"private\" attributes. (:gh:`112826`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2610 +#: ../../whatsnew/3.13.rst:2625 msgid "Changes in the C API" msgstr "C API 中的改動" -#: ../../whatsnew/3.13.rst:2612 +#: ../../whatsnew/3.13.rst:2627 msgid "" "``Python.h`` no longer includes the ```` standard header. It was " "included for the :c:func:`!finite` function which is now provided by the " @@ -5254,7 +5276,7 @@ msgid "" "`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2618 +#: ../../whatsnew/3.13.rst:2633 msgid "" "``Python.h`` no longer includes these standard header files: ````, " "```` and ````. If needed, they should now be " @@ -5265,7 +5287,7 @@ msgid "" "Victor Stinner in :gh:`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2626 +#: ../../whatsnew/3.13.rst:2641 msgid "" "On Windows, ``Python.h`` no longer includes the ```` standard " "header file. If needed, it should now be included explicitly. For example, " @@ -5275,7 +5297,7 @@ msgid "" "(Contributed by Victor Stinner in :gh:`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2633 +#: ../../whatsnew/3.13.rst:2648 msgid "" "If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`!" "Py_BUILD_CORE`, :c:macro:`!Py_BUILD_CORE_BUILTIN` and :c:macro:`!" @@ -5283,18 +5305,18 @@ msgid "" "(Contributed by Victor Stinner in :gh:`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2638 +#: ../../whatsnew/3.13.rst:2653 msgid "" "The old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and " "``Py_TRASHCAN_SAFE_END`` were removed. They should be replaced by the new " "macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``." msgstr "" -#: ../../whatsnew/3.13.rst:2642 +#: ../../whatsnew/3.13.rst:2657 msgid "A ``tp_dealloc`` function that has the old macros, such as::" msgstr "有舊巨集的 ``tp_dealloc`` 函式,例如: ::" -#: ../../whatsnew/3.13.rst:2644 +#: ../../whatsnew/3.13.rst:2659 msgid "" "static void\n" "mytype_dealloc(mytype *p)\n" @@ -5314,11 +5336,11 @@ msgstr "" " Py_TRASHCAN_SAFE_END\n" "}" -#: ../../whatsnew/3.13.rst:2653 +#: ../../whatsnew/3.13.rst:2668 msgid "should migrate to the new macros as follows::" msgstr "應該改為使用新的巨集,如下所示: ::" -#: ../../whatsnew/3.13.rst:2655 +#: ../../whatsnew/3.13.rst:2670 msgid "" "static void\n" "mytype_dealloc(mytype *p)\n" @@ -5338,7 +5360,7 @@ msgstr "" " Py_TRASHCAN_END\n" "}" -#: ../../whatsnew/3.13.rst:2664 +#: ../../whatsnew/3.13.rst:2679 msgid "" "Note that ``Py_TRASHCAN_BEGIN`` has a second argument which should be the " "deallocation function it is in. The new macros were added in Python 3.8 and " @@ -5346,13 +5368,13 @@ msgid "" "in :gh:`105111`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2671 +#: ../../whatsnew/3.13.rst:2686 msgid "" ":ref:`PEP 667 ` introduces several changes to " "frame-related functions:" msgstr "" -#: ../../whatsnew/3.13.rst:2674 +#: ../../whatsnew/3.13.rst:2689 msgid "" "The effects of mutating the dictionary returned from :c:func:" "`PyEval_GetLocals` in an :term:`optimized scope` have changed. New dict " @@ -5366,7 +5388,7 @@ msgid "" "being used, so refer to the deprecation notice on the function for details." msgstr "" -#: ../../whatsnew/3.13.rst:2687 +#: ../../whatsnew/3.13.rst:2702 msgid "" "Calling :c:func:`PyFrame_GetLocals` in an :term:`optimized scope` now " "returns a write-through proxy rather than a snapshot that gets updated at " @@ -5375,25 +5397,25 @@ msgid "" "`PyEval_GetFrameLocals` API." msgstr "" -#: ../../whatsnew/3.13.rst:2694 +#: ../../whatsnew/3.13.rst:2709 msgid "" ":c:func:`!PyFrame_FastToLocals` and :c:func:`!PyFrame_FastToLocalsWithError` " "no longer have any effect. Calling these functions has been redundant since " "Python 3.11, when :c:func:`PyFrame_GetLocals` was first introduced." msgstr "" -#: ../../whatsnew/3.13.rst:2699 +#: ../../whatsnew/3.13.rst:2714 msgid "" ":c:func:`!PyFrame_LocalsToFast` no longer has any effect. Calling this " "function is redundant now that :c:func:`PyFrame_GetLocals` returns a write-" "through proxy for :term:`optimized scopes `." msgstr "" -#: ../../whatsnew/3.13.rst:2704 +#: ../../whatsnew/3.13.rst:2719 msgid "Regression Test Changes" msgstr "" -#: ../../whatsnew/3.13.rst:2706 +#: ../../whatsnew/3.13.rst:2721 msgid "" "Python built with :file:`configure` :option:`--with-pydebug` now supports a :" "option:`-X presite=package.module <-X>` command-line option. If used, it " @@ -5402,11 +5424,11 @@ msgid "" "in :gh:`110769`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2714 +#: ../../whatsnew/3.13.rst:2729 msgid "Notable changes in 3.13.1" msgstr "Python 3.13.1 中顯著的變更" -#: ../../whatsnew/3.13.rst:2719 +#: ../../whatsnew/3.13.rst:2734 msgid "" "The previously undocumented special function :func:`sys.getobjects`, which " "only exists in specialized builds of Python, may now return objects from " diff --git a/whatsnew/3.4.po b/whatsnew/3.4.po index d928fca84e..8bdcc0eaaf 100644 --- a/whatsnew/3.4.po +++ b/whatsnew/3.4.po @@ -95,7 +95,7 @@ msgstr "" #: ../../whatsnew/3.4.rst:98 msgid "New library modules:" -msgstr "" +msgstr "新的函式庫模組:" #: ../../whatsnew/3.4.rst:100 msgid "" diff --git a/whatsnew/3.5.po b/whatsnew/3.5.po index 9de8d2caae..36ad7689e8 100644 --- a/whatsnew/3.5.po +++ b/whatsnew/3.5.po @@ -71,7 +71,7 @@ msgstr "" #: ../../whatsnew/3.5.rst:67 msgid "New library modules:" -msgstr "" +msgstr "新的函式庫模組:" #: ../../whatsnew/3.5.rst:69 msgid ":mod:`typing`: :ref:`PEP 484 -- Type Hints `." diff --git a/whatsnew/3.6.po b/whatsnew/3.6.po index d4e6ccd8c2..2b7dfedd6b 100644 --- a/whatsnew/3.6.po +++ b/whatsnew/3.6.po @@ -70,7 +70,7 @@ msgstr "" #: ../../whatsnew/3.6.rst:73 msgid "New library modules:" -msgstr "" +msgstr "新的函式庫模組:" #: ../../whatsnew/3.6.rst:75 msgid "" diff --git a/whatsnew/3.7.po b/whatsnew/3.7.po index b2c04d4e21..9416588394 100644 --- a/whatsnew/3.7.po +++ b/whatsnew/3.7.po @@ -58,7 +58,7 @@ msgstr ":keyword:`async` 和 :keyword:`await` 現為保留關鍵字。" #: ../../whatsnew/3.7.rst:66 msgid "New library modules:" -msgstr "" +msgstr "新的函式庫模組:" #: ../../whatsnew/3.7.rst:68 msgid "" diff --git a/whatsnew/3.9.po b/whatsnew/3.9.po index 4c88343623..c85271fcb3 100644 --- a/whatsnew/3.9.po +++ b/whatsnew/3.9.po @@ -126,7 +126,7 @@ msgstr "" #: ../../whatsnew/3.9.rst:94 msgid "New library modules:" -msgstr "" +msgstr "新的函式庫模組:" #: ../../whatsnew/3.9.rst:96 msgid ""