From a902e487357bad1bdb6f0d36f37e60b877458402 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 21 Dec 2022 00:18:12 +0000 Subject: [PATCH 1/3] sync with cpython 73d2b15b --- library/contextvars.po | 38 +++-- library/re.po | 380 ++++++++++++++++++++--------------------- 2 files changed, 213 insertions(+), 205 deletions(-) diff --git a/library/contextvars.po b/library/contextvars.po index 8296de9035..bb1fd8ba3d 100644 --- a/library/contextvars.po +++ b/library/contextvars.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-31 08:13+0000\n" +"POT-Creation-Date: 2022-12-21 00:15+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -180,77 +180,85 @@ msgid "" msgstr "" #: ../../library/contextvars.rst:147 +msgid "" +"Every thread will have a different top-level :class:`~contextvars.Context` " +"object. This means that a :class:`ContextVar` object behaves in a similar " +"fashion to :func:`threading.local()` when values are assigned in different " +"threads." +msgstr "" + +#: ../../library/contextvars.rst:152 msgid "Context implements the :class:`collections.abc.Mapping` interface." msgstr "" -#: ../../library/contextvars.rst:151 +#: ../../library/contextvars.rst:156 msgid "" "Execute ``callable(*args, **kwargs)`` code in the context object the *run* " "method is called on. Return the result of the execution or propagate an " "exception if one occurred." msgstr "" -#: ../../library/contextvars.rst:155 +#: ../../library/contextvars.rst:160 msgid "" "Any changes to any context variables that *callable* makes will be contained " "in the context object::" msgstr "" -#: ../../library/contextvars.rst:184 +#: ../../library/contextvars.rst:189 msgid "" "The method raises a :exc:`RuntimeError` when called on the same context " "object from more than one OS thread, or when called recursively." msgstr "" -#: ../../library/contextvars.rst:190 +#: ../../library/contextvars.rst:195 msgid "Return a shallow copy of the context object." msgstr "" -#: ../../library/contextvars.rst:194 +#: ../../library/contextvars.rst:199 msgid "" "Return ``True`` if the *context* has a value for *var* set; return ``False`` " "otherwise." msgstr "" -#: ../../library/contextvars.rst:199 +#: ../../library/contextvars.rst:204 msgid "" "Return the value of the *var* :class:`ContextVar` variable. If the variable " "is not set in the context object, a :exc:`KeyError` is raised." msgstr "" -#: ../../library/contextvars.rst:205 +#: ../../library/contextvars.rst:210 msgid "" "Return the value for *var* if *var* has the value in the context object. " "Return *default* otherwise. If *default* is not given, return ``None``." msgstr "" -#: ../../library/contextvars.rst:211 +#: ../../library/contextvars.rst:216 msgid "Return an iterator over the variables stored in the context object." msgstr "" -#: ../../library/contextvars.rst:216 +#: ../../library/contextvars.rst:221 msgid "Return the number of variables set in the context object." msgstr "" -#: ../../library/contextvars.rst:220 +#: ../../library/contextvars.rst:225 msgid "Return a list of all variables in the context object." msgstr "" -#: ../../library/contextvars.rst:224 +#: ../../library/contextvars.rst:229 msgid "Return a list of all variables' values in the context object." msgstr "" -#: ../../library/contextvars.rst:229 +#: ../../library/contextvars.rst:234 msgid "" "Return a list of 2-tuples containing all variables and their values in the " "context object." msgstr "" -#: ../../library/contextvars.rst:234 +#: ../../library/contextvars.rst:239 msgid "asyncio support" msgstr "" -#: ../../library/contextvars.rst:236 +#: ../../library/contextvars.rst:241 msgid "" "Context variables are natively supported in :mod:`asyncio` and are ready to " "be used without any extra configuration. For example, here is a simple echo " diff --git a/library/re.po b/library/re.po index 73a0cb845a..c662d1f822 100644 --- a/library/re.po +++ b/library/re.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-01 00:20+0000\n" +"POT-Creation-Date: 2022-12-21 00:15+0000\n" "PO-Revision-Date: 2018-05-23 16:09+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -146,7 +146,7 @@ msgstr "" msgid "The special characters are:" msgstr "" -#: ../../library/re.rst:104 ../../library/re.rst:1526 +#: ../../library/re.rst:104 ../../library/re.rst:1525 msgid "``.``" msgstr "``.``" @@ -769,7 +769,7 @@ msgstr "" msgid "``\\d``" msgstr "``\\d``" -#: ../../library/re.rst:555 ../../library/re.rst:575 ../../library/re.rst:595 +#: ../../library/re.rst:555 ../../library/re.rst:575 ../../library/re.rst:594 msgid "For Unicode (str) patterns:" msgstr "" @@ -781,7 +781,7 @@ msgid "" "matched." msgstr "" -#: ../../library/re.rst:558 ../../library/re.rst:579 ../../library/re.rst:601 +#: ../../library/re.rst:558 ../../library/re.rst:579 ../../library/re.rst:600 msgid "For 8-bit (bytes) patterns:" msgstr "" @@ -829,18 +829,18 @@ msgid "" "equivalent of ``[^ \\t\\n\\r\\f\\v]``." msgstr "" -#: ../../library/re.rst:601 +#: ../../library/re.rst:600 msgid "``\\w``" msgstr "``\\w``" #: ../../library/re.rst:592 msgid "" -"Matches Unicode word characters; this includes most characters that can be " -"part of a word in any language, as well as numbers and the underscore. If " -"the :const:`ASCII` flag is used, only ``[a-zA-Z0-9_]`` is matched." +"Matches Unicode word characters; this includes alphanumeric characters (as " +"defined by :meth:`str.isalnum`) as well as the underscore (``_``). If the :" +"const:`ASCII` flag is used, only ``[a-zA-Z0-9_]`` is matched." msgstr "" -#: ../../library/re.rst:598 +#: ../../library/re.rst:597 msgid "" "Matches characters considered alphanumeric in the ASCII character set; this " "is equivalent to ``[a-zA-Z0-9_]``. If the :const:`LOCALE` flag is used, " @@ -848,11 +848,11 @@ msgid "" "underscore." msgstr "" -#: ../../library/re.rst:610 +#: ../../library/re.rst:609 msgid "``\\W``" msgstr "``\\W``" -#: ../../library/re.rst:606 +#: ../../library/re.rst:605 msgid "" "Matches any character which is not a word character. This is the opposite of " "``\\w``. If the :const:`ASCII` flag is used this becomes the equivalent of " @@ -860,34 +860,34 @@ msgid "" "which are neither alphanumeric in the current locale nor the underscore." msgstr "" -#: ../../library/re.rst:615 +#: ../../library/re.rst:614 msgid "``\\Z``" msgstr "``\\Z``" -#: ../../library/re.rst:615 +#: ../../library/re.rst:614 msgid "Matches only at the end of the string." msgstr "" -#: ../../library/re.rst:631 +#: ../../library/re.rst:630 msgid "" "Most of the standard escapes supported by Python string literals are also " "accepted by the regular expression parser::" msgstr "" -#: ../../library/re.rst:638 +#: ../../library/re.rst:637 msgid "" "(Note that ``\\b`` is used to represent word boundaries, and means " "\"backspace\" only inside character classes.)" msgstr "" -#: ../../library/re.rst:641 +#: ../../library/re.rst:640 msgid "" "``'\\u'``, ``'\\U'``, and ``'\\N'`` escape sequences are only recognized in " "Unicode patterns. In bytes patterns they are errors. Unknown escapes of " "ASCII letters are reserved for future use and treated as errors." msgstr "" -#: ../../library/re.rst:645 +#: ../../library/re.rst:644 msgid "" "Octal escapes are included in a limited form. If the first digit is a 0, or " "if there are three octal digits, it is considered an octal escape. " @@ -895,26 +895,26 @@ msgid "" "are always at most three digits in length." msgstr "" -#: ../../library/re.rst:650 +#: ../../library/re.rst:649 msgid "The ``'\\u'`` and ``'\\U'`` escape sequences have been added." msgstr "" -#: ../../library/re.rst:653 +#: ../../library/re.rst:652 msgid "" "Unknown escapes consisting of ``'\\'`` and an ASCII letter now are errors." msgstr "" -#: ../../library/re.rst:656 +#: ../../library/re.rst:655 msgid "" "The ``'\\N{name}'`` escape sequence has been added. As in string literals, " "it expands to the named Unicode character (e.g. ``'\\N{EM DASH}'``)." msgstr "" -#: ../../library/re.rst:664 +#: ../../library/re.rst:663 msgid "Module Contents" msgstr "模組內容" -#: ../../library/re.rst:666 +#: ../../library/re.rst:665 msgid "" "The module defines several functions, constants, and an exception. Some of " "the functions are simplified versions of the full featured methods for " @@ -922,26 +922,26 @@ msgid "" "compiled form." msgstr "" -#: ../../library/re.rst:673 +#: ../../library/re.rst:672 msgid "Flags" msgstr "" -#: ../../library/re.rst:675 +#: ../../library/re.rst:674 msgid "" "Flag constants are now instances of :class:`RegexFlag`, which is a subclass " "of :class:`enum.IntFlag`." msgstr "" -#: ../../library/re.rst:682 +#: ../../library/re.rst:681 msgid "" "An :class:`enum.IntFlag` class containing the regex options listed below." msgstr "" -#: ../../library/re.rst:684 +#: ../../library/re.rst:683 msgid "- added to ``__all__``" msgstr "" -#: ../../library/re.rst:689 +#: ../../library/re.rst:688 msgid "" "Make ``\\w``, ``\\W``, ``\\b``, ``\\B``, ``\\d``, ``\\D``, ``\\s`` and " "``\\S`` perform ASCII-only matching instead of full Unicode matching. This " @@ -949,7 +949,7 @@ msgid "" "Corresponds to the inline flag ``(?a)``." msgstr "" -#: ../../library/re.rst:694 +#: ../../library/re.rst:693 msgid "" "Note that for backward compatibility, the :const:`re.U` flag still exists " "(as well as its synonym :const:`re.UNICODE` and its embedded counterpart ``(?" @@ -957,13 +957,13 @@ msgid "" "default for strings (and Unicode matching isn't allowed for bytes)." msgstr "" -#: ../../library/re.rst:703 +#: ../../library/re.rst:702 msgid "" "Display debug information about compiled expression. No corresponding inline " "flag." msgstr "" -#: ../../library/re.rst:710 +#: ../../library/re.rst:709 msgid "" "Perform case-insensitive matching; expressions like ``[A-Z]`` will also " "match lowercase letters. Full Unicode matching (such as ``Ü`` matching " @@ -973,7 +973,7 @@ msgid "" "flag ``(?i)``." msgstr "" -#: ../../library/re.rst:717 +#: ../../library/re.rst:716 msgid "" "Note that when the Unicode patterns ``[a-z]`` or ``[A-Z]`` are used in " "combination with the :const:`IGNORECASE` flag, they will match the 52 ASCII " @@ -984,7 +984,7 @@ msgid "" "matched." msgstr "" -#: ../../library/re.rst:728 +#: ../../library/re.rst:727 msgid "" "Make ``\\w``, ``\\W``, ``\\b``, ``\\B`` and case-insensitive matching " "dependent on the current locale. This flag can be used only with bytes " @@ -995,20 +995,20 @@ msgid "" "locales/languages. Corresponds to the inline flag ``(?L)``." msgstr "" -#: ../../library/re.rst:737 +#: ../../library/re.rst:736 msgid "" ":const:`re.LOCALE` can be used only with bytes patterns and is not " "compatible with :const:`re.ASCII`." msgstr "" -#: ../../library/re.rst:741 +#: ../../library/re.rst:740 msgid "" "Compiled regular expression objects with the :const:`re.LOCALE` flag no " "longer depend on the locale at compile time. Only the locale at matching " "time affects the result of matching." msgstr "" -#: ../../library/re.rst:750 +#: ../../library/re.rst:749 msgid "" "When specified, the pattern character ``'^'`` matches at the beginning of " "the string and at the beginning of each line (immediately following each " @@ -1019,7 +1019,7 @@ msgid "" "the end of the string. Corresponds to the inline flag ``(?m)``." msgstr "" -#: ../../library/re.rst:760 +#: ../../library/re.rst:759 msgid "" "Indicates no flag being applied, the value is ``0``. This flag may be used " "as a default value for a function keyword argument or as a base value that " @@ -1027,14 +1027,14 @@ msgid "" "value::" msgstr "" -#: ../../library/re.rst:773 +#: ../../library/re.rst:772 msgid "" "Make the ``'.'`` special character match any character at all, including a " "newline; without this flag, ``'.'`` will match anything *except* a newline. " "Corresponds to the inline flag ``(?s)``." msgstr "" -#: ../../library/re.rst:783 +#: ../../library/re.rst:782 msgid "" "This flag allows you to write regular expressions that look nicer and are " "more readable by allowing you to visually separate logical sections of the " @@ -1047,53 +1047,53 @@ msgid "" "ignored." msgstr "" -#: ../../library/re.rst:793 +#: ../../library/re.rst:792 msgid "" "This means that the two following regular expression objects that match a " "decimal number are functionally equal::" msgstr "" -#: ../../library/re.rst:801 +#: ../../library/re.rst:800 msgid "Corresponds to the inline flag ``(?x)``." msgstr "" -#: ../../library/re.rst:805 +#: ../../library/re.rst:804 msgid "Functions" msgstr "" -#: ../../library/re.rst:809 +#: ../../library/re.rst:808 msgid "" "Compile a regular expression pattern into a :ref:`regular expression object " "`, which can be used for matching using its :func:`~Pattern." "match`, :func:`~Pattern.search` and other methods, described below." msgstr "" -#: ../../library/re.rst:814 +#: ../../library/re.rst:813 msgid "" "The expression's behaviour can be modified by specifying a *flags* value. " "Values can be any of the following variables, combined using bitwise OR (the " "``|`` operator)." msgstr "" -#: ../../library/re.rst:818 +#: ../../library/re.rst:817 msgid "The sequence ::" msgstr "" -#: ../../library/re.rst:823 +#: ../../library/re.rst:822 msgid "is equivalent to ::" msgstr "" "等價於:\n" "\n" "::" -#: ../../library/re.rst:827 +#: ../../library/re.rst:826 msgid "" "but using :func:`re.compile` and saving the resulting regular expression " "object for reuse is more efficient when the expression will be used several " "times in a single program." msgstr "" -#: ../../library/re.rst:833 +#: ../../library/re.rst:832 msgid "" "The compiled versions of the most recent patterns passed to :func:`re." "compile` and the module-level matching functions are cached, so programs " @@ -1101,7 +1101,7 @@ msgid "" "compiling regular expressions." msgstr "" -#: ../../library/re.rst:841 +#: ../../library/re.rst:840 msgid "" "Scan through *string* looking for the first location where the regular " "expression *pattern* produces a match, and return a corresponding :ref:" @@ -1110,7 +1110,7 @@ msgid "" "length match at some point in the string." msgstr "" -#: ../../library/re.rst:850 +#: ../../library/re.rst:849 msgid "" "If zero or more characters at the beginning of *string* match the regular " "expression *pattern*, return a corresponding :ref:`match object `. Return ``None`` if the " @@ -1138,7 +1138,7 @@ msgid "" "length match." msgstr "" -#: ../../library/re.rst:874 +#: ../../library/re.rst:873 msgid "" "Split *string* by the occurrences of *pattern*. If capturing parentheses " "are used in *pattern*, then the text of all groups in the pattern are also " @@ -1147,42 +1147,42 @@ msgid "" "final element of the list. ::" msgstr "" -#: ../../library/re.rst:889 +#: ../../library/re.rst:888 msgid "" "If there are capturing groups in the separator and it matches at the start " "of the string, the result will start with an empty string. The same holds " "for the end of the string::" msgstr "" -#: ../../library/re.rst:896 +#: ../../library/re.rst:895 msgid "" "That way, separator components are always found at the same relative indices " "within the result list." msgstr "" -#: ../../library/re.rst:899 +#: ../../library/re.rst:898 msgid "" "Empty matches for the pattern split the string only when not adjacent to a " "previous empty match." msgstr "" -#: ../../library/re.rst:909 ../../library/re.rst:999 ../../library/re.rst:1027 +#: ../../library/re.rst:908 ../../library/re.rst:998 ../../library/re.rst:1026 msgid "Added the optional flags argument." msgstr "" -#: ../../library/re.rst:912 +#: ../../library/re.rst:911 msgid "" "Added support of splitting on a pattern that could match an empty string." msgstr "" -#: ../../library/re.rst:918 +#: ../../library/re.rst:917 msgid "" "Return all non-overlapping matches of *pattern* in *string*, as a list of " "strings or tuples. The *string* is scanned left-to-right, and matches are " "returned in the order found. Empty matches are included in the result." msgstr "" -#: ../../library/re.rst:922 +#: ../../library/re.rst:921 msgid "" "The result depends on the number of capturing groups in the pattern. If " "there are no groups, return a list of strings matching the whole pattern. " @@ -1192,11 +1192,11 @@ msgid "" "result." msgstr "" -#: ../../library/re.rst:934 ../../library/re.rst:945 +#: ../../library/re.rst:933 ../../library/re.rst:944 msgid "Non-empty matches can now start just after a previous empty match." msgstr "" -#: ../../library/re.rst:940 +#: ../../library/re.rst:939 msgid "" "Return an :term:`iterator` yielding :ref:`match objects ` " "over all non-overlapping matches for the RE *pattern* in *string*. The " @@ -1204,7 +1204,7 @@ msgid "" "found. Empty matches are included in the result." msgstr "" -#: ../../library/re.rst:951 +#: ../../library/re.rst:950 msgid "" "Return the string obtained by replacing the leftmost non-overlapping " "occurrences of *pattern* in *string* by the replacement *repl*. If the " @@ -1218,18 +1218,18 @@ msgid "" "For example::" msgstr "" -#: ../../library/re.rst:967 +#: ../../library/re.rst:966 msgid "" "If *repl* is a function, it is called for every non-overlapping occurrence " "of *pattern*. The function takes a single :ref:`match object ` argument, and returns the replacement string. For example::" msgstr "" -#: ../../library/re.rst:979 +#: ../../library/re.rst:978 msgid "The pattern may be a string or a :ref:`pattern object `." msgstr "" -#: ../../library/re.rst:981 +#: ../../library/re.rst:980 msgid "" "The optional argument *count* is the maximum number of pattern occurrences " "to be replaced; *count* must be a non-negative integer. If omitted or zero, " @@ -1238,7 +1238,7 @@ msgid "" "'abxd')`` returns ``'-a-b--d-'``." msgstr "" -#: ../../library/re.rst:989 +#: ../../library/re.rst:988 msgid "" "In string-type *repl* arguments, in addition to the character escapes and " "backreferences described above, ``\\g`` will use the substring matched " @@ -1251,59 +1251,59 @@ msgid "" "RE." msgstr "" -#: ../../library/re.rst:1002 ../../library/re.rst:1030 -#: ../../library/re.rst:1264 +#: ../../library/re.rst:1001 ../../library/re.rst:1029 +#: ../../library/re.rst:1263 msgid "Unmatched groups are replaced with an empty string." msgstr "" -#: ../../library/re.rst:1005 +#: ../../library/re.rst:1004 msgid "" "Unknown escapes in *pattern* consisting of ``'\\'`` and an ASCII letter now " "are errors." msgstr "" -#: ../../library/re.rst:1009 +#: ../../library/re.rst:1008 msgid "" "Unknown escapes in *repl* consisting of ``'\\'`` and an ASCII letter now are " "errors." msgstr "" -#: ../../library/re.rst:1013 +#: ../../library/re.rst:1012 msgid "" "Empty matches for the pattern are replaced when adjacent to a previous non-" "empty match." msgstr "" -#: ../../library/re.rst:1017 +#: ../../library/re.rst:1016 msgid "" "Group *id* containing anything except ASCII digits. Group names containing " "non-ASCII characters in bytes replacement strings." msgstr "" -#: ../../library/re.rst:1024 +#: ../../library/re.rst:1023 msgid "" "Perform the same operation as :func:`sub`, but return a tuple ``(new_string, " "number_of_subs_made)``." msgstr "" -#: ../../library/re.rst:1036 +#: ../../library/re.rst:1035 msgid "" "Escape special characters in *pattern*. This is useful if you want to match " "an arbitrary literal string that may have regular expression metacharacters " "in it. For example::" msgstr "" -#: ../../library/re.rst:1051 +#: ../../library/re.rst:1050 msgid "" "This function must not be used for the replacement string in :func:`sub` " "and :func:`subn`, only backslashes should be escaped. For example::" msgstr "" -#: ../../library/re.rst:1059 +#: ../../library/re.rst:1058 msgid "The ``'_'`` character is no longer escaped." msgstr "" -#: ../../library/re.rst:1062 +#: ../../library/re.rst:1061 msgid "" "Only characters that can have special meaning in a regular expression are " "escaped. As a result, ``'!'``, ``'\"'``, ``'%'``, ``\"'\"``, ``','``, " @@ -1311,15 +1311,15 @@ msgid "" "are no longer escaped." msgstr "" -#: ../../library/re.rst:1071 +#: ../../library/re.rst:1070 msgid "Clear the regular expression cache." msgstr "" -#: ../../library/re.rst:1075 +#: ../../library/re.rst:1074 msgid "Exceptions" msgstr "" -#: ../../library/re.rst:1079 +#: ../../library/re.rst:1078 msgid "" "Exception raised when a string passed to one of the functions here is not a " "valid regular expression (for example, it might contain unmatched " @@ -1328,41 +1328,41 @@ msgid "" "pattern. The error instance has the following additional attributes:" msgstr "" -#: ../../library/re.rst:1087 +#: ../../library/re.rst:1086 msgid "The unformatted error message." msgstr "" -#: ../../library/re.rst:1091 +#: ../../library/re.rst:1090 msgid "The regular expression pattern." msgstr "" -#: ../../library/re.rst:1095 +#: ../../library/re.rst:1094 msgid "The index in *pattern* where compilation failed (may be ``None``)." msgstr "" -#: ../../library/re.rst:1099 +#: ../../library/re.rst:1098 msgid "The line corresponding to *pos* (may be ``None``)." msgstr "" -#: ../../library/re.rst:1103 +#: ../../library/re.rst:1102 msgid "The column corresponding to *pos* (may be ``None``)." msgstr "" -#: ../../library/re.rst:1105 +#: ../../library/re.rst:1104 msgid "Added additional attributes." msgstr "新增額外屬性。" -#: ../../library/re.rst:1111 +#: ../../library/re.rst:1110 msgid "Regular Expression Objects" msgstr "" -#: ../../library/re.rst:1113 +#: ../../library/re.rst:1112 msgid "" "Compiled regular expression objects support the following methods and " "attributes:" msgstr "" -#: ../../library/re.rst:1118 +#: ../../library/re.rst:1117 msgid "" "Scan through *string* looking for the first location where this regular " "expression produces a match, and return a corresponding :ref:`match object " @@ -1371,7 +1371,7 @@ msgid "" "some point in the string." msgstr "" -#: ../../library/re.rst:1124 +#: ../../library/re.rst:1123 msgid "" "The optional second parameter *pos* gives an index in the string where the " "search is to start; it defaults to ``0``. This is not completely equivalent " @@ -1380,7 +1380,7 @@ msgid "" "necessarily at the index where the search is to start." msgstr "" -#: ../../library/re.rst:1130 +#: ../../library/re.rst:1129 msgid "" "The optional parameter *endpos* limits how far the string will be searched; " "it will be as if the string is *endpos* characters long, so only the " @@ -1390,7 +1390,7 @@ msgid "" "equivalent to ``rx.search(string[:50], 0)``. ::" msgstr "" -#: ../../library/re.rst:1145 +#: ../../library/re.rst:1144 msgid "" "If zero or more characters at the *beginning* of *string* match this regular " "expression, return a corresponding :ref:`match object `. " @@ -1398,19 +1398,19 @@ msgid "" "different from a zero-length match." msgstr "" -#: ../../library/re.rst:1150 ../../library/re.rst:1168 +#: ../../library/re.rst:1149 ../../library/re.rst:1167 msgid "" "The optional *pos* and *endpos* parameters have the same meaning as for the :" "meth:`~Pattern.search` method. ::" msgstr "" -#: ../../library/re.rst:1158 +#: ../../library/re.rst:1157 msgid "" "If you want to locate a match anywhere in *string*, use :meth:`~Pattern." "search` instead (see also :ref:`search-vs-match`)." msgstr "" -#: ../../library/re.rst:1164 +#: ../../library/re.rst:1163 msgid "" "If the whole *string* matches this regular expression, return a " "corresponding :ref:`match object `. Return ``None`` if the " @@ -1418,76 +1418,76 @@ msgid "" "length match." msgstr "" -#: ../../library/re.rst:1182 +#: ../../library/re.rst:1181 msgid "Identical to the :func:`split` function, using the compiled pattern." msgstr "" -#: ../../library/re.rst:1187 +#: ../../library/re.rst:1186 msgid "" "Similar to the :func:`findall` function, using the compiled pattern, but " "also accepts optional *pos* and *endpos* parameters that limit the search " "region like for :meth:`search`." msgstr "" -#: ../../library/re.rst:1194 +#: ../../library/re.rst:1193 msgid "" "Similar to the :func:`finditer` function, using the compiled pattern, but " "also accepts optional *pos* and *endpos* parameters that limit the search " "region like for :meth:`search`." msgstr "" -#: ../../library/re.rst:1201 +#: ../../library/re.rst:1200 msgid "Identical to the :func:`sub` function, using the compiled pattern." msgstr "" -#: ../../library/re.rst:1206 +#: ../../library/re.rst:1205 msgid "Identical to the :func:`subn` function, using the compiled pattern." msgstr "" -#: ../../library/re.rst:1211 +#: ../../library/re.rst:1210 msgid "" "The regex matching flags. This is a combination of the flags given to :func:" "`.compile`, any ``(?...)`` inline flags in the pattern, and implicit flags " "such as :data:`UNICODE` if the pattern is a Unicode string." msgstr "" -#: ../../library/re.rst:1218 +#: ../../library/re.rst:1217 msgid "The number of capturing groups in the pattern." msgstr "" -#: ../../library/re.rst:1223 +#: ../../library/re.rst:1222 msgid "" "A dictionary mapping any symbolic group names defined by ``(?P)`` to " "group numbers. The dictionary is empty if no symbolic groups were used in " "the pattern." msgstr "" -#: ../../library/re.rst:1230 +#: ../../library/re.rst:1229 msgid "The pattern string from which the pattern object was compiled." msgstr "" -#: ../../library/re.rst:1233 +#: ../../library/re.rst:1232 msgid "" "Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Compiled " "regular expression objects are considered atomic." msgstr "" -#: ../../library/re.rst:1241 +#: ../../library/re.rst:1240 msgid "Match Objects" msgstr "" -#: ../../library/re.rst:1243 +#: ../../library/re.rst:1242 msgid "" "Match objects always have a boolean value of ``True``. Since :meth:`~Pattern." "match` and :meth:`~Pattern.search` return ``None`` when there is no match, " "you can test whether there was a match with a simple ``if`` statement::" msgstr "" -#: ../../library/re.rst:1252 +#: ../../library/re.rst:1251 msgid "Match objects support the following methods and attributes:" msgstr "" -#: ../../library/re.rst:1257 +#: ../../library/re.rst:1256 msgid "" "Return the string obtained by doing backslash substitution on the template " "string *template*, as done by the :meth:`~Pattern.sub` method. Escapes such " @@ -1496,7 +1496,7 @@ msgid "" "``\\g``) are replaced by the contents of the corresponding group." msgstr "" -#: ../../library/re.rst:1269 +#: ../../library/re.rst:1268 msgid "" "Returns one or more subgroups of the match. If there is a single argument, " "the result is a single string; if there are multiple arguments, the result " @@ -1511,7 +1511,7 @@ msgid "" "the pattern that matched multiple times, the last match is returned. ::" msgstr "" -#: ../../library/re.rst:1291 +#: ../../library/re.rst:1290 msgid "" "If the regular expression uses the ``(?P...)`` syntax, the *groupN* " "arguments may also be strings identifying groups by their group name. If a " @@ -1519,57 +1519,57 @@ msgid "" "`IndexError` exception is raised." msgstr "" -#: ../../library/re.rst:1296 +#: ../../library/re.rst:1295 msgid "A moderately complicated example::" msgstr "" -#: ../../library/re.rst:1304 +#: ../../library/re.rst:1303 msgid "Named groups can also be referred to by their index::" msgstr "" -#: ../../library/re.rst:1311 +#: ../../library/re.rst:1310 msgid "If a group matches multiple times, only the last match is accessible::" msgstr "" -#: ../../library/re.rst:1320 +#: ../../library/re.rst:1319 msgid "" "This is identical to ``m.group(g)``. This allows easier access to an " "individual group from a match::" msgstr "" -#: ../../library/re.rst:1331 +#: ../../library/re.rst:1330 msgid "Named groups are supported as well::" msgstr "" -#: ../../library/re.rst:1344 +#: ../../library/re.rst:1343 msgid "" "Return a tuple containing all the subgroups of the match, from 1 up to " "however many groups are in the pattern. The *default* argument is used for " "groups that did not participate in the match; it defaults to ``None``." msgstr "" -#: ../../library/re.rst:1348 ../../library/re.rst:1573 +#: ../../library/re.rst:1347 ../../library/re.rst:1572 msgid "For example::" msgstr "" "舉例來說:\n" "\n" "::" -#: ../../library/re.rst:1354 +#: ../../library/re.rst:1353 msgid "" "If we make the decimal place and everything after it optional, not all " "groups might participate in the match. These groups will default to " "``None`` unless the *default* argument is given::" msgstr "" -#: ../../library/re.rst:1367 +#: ../../library/re.rst:1366 msgid "" "Return a dictionary containing all the *named* subgroups of the match, keyed " "by the subgroup name. The *default* argument is used for groups that did " "not participate in the match; it defaults to ``None``. For example::" msgstr "" -#: ../../library/re.rst:1379 +#: ../../library/re.rst:1378 msgid "" "Return the indices of the start and end of the substring matched by *group*; " "*group* defaults to zero (meaning the whole matched substring). Return " @@ -1578,7 +1578,7 @@ msgid "" "matched by group *g* (equivalent to ``m.group(g)``) is ::" msgstr "" -#: ../../library/re.rst:1387 +#: ../../library/re.rst:1386 msgid "" "Note that ``m.start(group)`` will equal ``m.end(group)`` if *group* matched " "a null string. For example, after ``m = re.search('b(c?)', 'cba')``, ``m." @@ -1586,32 +1586,32 @@ msgid "" "2, and ``m.start(2)`` raises an :exc:`IndexError` exception." msgstr "" -#: ../../library/re.rst:1392 +#: ../../library/re.rst:1391 msgid "An example that will remove *remove_this* from email addresses::" msgstr "" -#: ../../library/re.rst:1402 +#: ../../library/re.rst:1401 msgid "" "For a match *m*, return the 2-tuple ``(m.start(group), m.end(group))``. Note " "that if *group* did not contribute to the match, this is ``(-1, -1)``. " "*group* defaults to zero, the entire match." msgstr "" -#: ../../library/re.rst:1409 +#: ../../library/re.rst:1408 msgid "" "The value of *pos* which was passed to the :meth:`~Pattern.search` or :meth:" "`~Pattern.match` method of a :ref:`regex object `. This is the " "index into the string at which the RE engine started looking for a match." msgstr "" -#: ../../library/re.rst:1416 +#: ../../library/re.rst:1415 msgid "" "The value of *endpos* which was passed to the :meth:`~Pattern.search` or :" "meth:`~Pattern.match` method of a :ref:`regex object `. This is " "the index into the string beyond which the RE engine will not go." msgstr "" -#: ../../library/re.rst:1423 +#: ../../library/re.rst:1422 msgid "" "The integer index of the last matched capturing group, or ``None`` if no " "group was matched at all. For example, the expressions ``(a)b``, ``((a)" @@ -1620,43 +1620,43 @@ msgid "" "applied to the same string." msgstr "" -#: ../../library/re.rst:1432 +#: ../../library/re.rst:1431 msgid "" "The name of the last matched capturing group, or ``None`` if the group " "didn't have a name, or if no group was matched at all." msgstr "" -#: ../../library/re.rst:1438 +#: ../../library/re.rst:1437 msgid "" "The :ref:`regular expression object ` whose :meth:`~Pattern." "match` or :meth:`~Pattern.search` method produced this match instance." msgstr "" -#: ../../library/re.rst:1444 +#: ../../library/re.rst:1443 msgid "The string passed to :meth:`~Pattern.match` or :meth:`~Pattern.search`." msgstr "" -#: ../../library/re.rst:1447 +#: ../../library/re.rst:1446 msgid "" "Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Match objects " "are considered atomic." msgstr "" -#: ../../library/re.rst:1455 +#: ../../library/re.rst:1454 msgid "Regular Expression Examples" msgstr "" -#: ../../library/re.rst:1459 +#: ../../library/re.rst:1458 msgid "Checking for a Pair" msgstr "" -#: ../../library/re.rst:1461 +#: ../../library/re.rst:1460 msgid "" "In this example, we'll use the following helper function to display match " "objects a little more gracefully::" msgstr "" -#: ../../library/re.rst:1469 +#: ../../library/re.rst:1468 msgid "" "Suppose you are writing a poker program where a player's hand is represented " "as a 5-character string with each character representing a card, \"a\" for " @@ -1664,28 +1664,28 @@ msgid "" "\"2\" through \"9\" representing the card with that value." msgstr "" -#: ../../library/re.rst:1474 +#: ../../library/re.rst:1473 msgid "To see if a given string is a valid hand, one could do the following::" msgstr "" -#: ../../library/re.rst:1484 +#: ../../library/re.rst:1483 msgid "" "That last hand, ``\"727ak\"``, contained a pair, or two of the same valued " "cards. To match this with a regular expression, one could use backreferences " "as such::" msgstr "" -#: ../../library/re.rst:1494 +#: ../../library/re.rst:1493 msgid "" "To find out what card the pair consists of, one could use the :meth:`~Match." "group` method of the match object in the following manner::" msgstr "" -#: ../../library/re.rst:1513 +#: ../../library/re.rst:1512 msgid "Simulating scanf()" msgstr "" -#: ../../library/re.rst:1517 +#: ../../library/re.rst:1516 msgid "" "Python does not currently have an equivalent to :c:func:`scanf`. Regular " "expressions are generally more powerful, though also more verbose, than :c:" @@ -1694,124 +1694,124 @@ msgid "" "expressions." msgstr "" -#: ../../library/re.rst:1524 +#: ../../library/re.rst:1523 msgid ":c:func:`scanf` Token" msgstr "" -#: ../../library/re.rst:1524 +#: ../../library/re.rst:1523 msgid "Regular Expression" msgstr "" -#: ../../library/re.rst:1526 +#: ../../library/re.rst:1525 msgid "``%c``" msgstr "``%c``" -#: ../../library/re.rst:1528 +#: ../../library/re.rst:1527 msgid "``%5c``" msgstr "``%5c``" -#: ../../library/re.rst:1528 +#: ../../library/re.rst:1527 msgid "``.{5}``" msgstr "``.{5}``" -#: ../../library/re.rst:1530 +#: ../../library/re.rst:1529 msgid "``%d``" msgstr "``%d``" -#: ../../library/re.rst:1530 +#: ../../library/re.rst:1529 msgid "``[-+]?\\d+``" msgstr "``[-+]?\\d+``" -#: ../../library/re.rst:1532 +#: ../../library/re.rst:1531 msgid "``%e``, ``%E``, ``%f``, ``%g``" msgstr "``%e``, ``%E``, ``%f``, ``%g``" -#: ../../library/re.rst:1532 +#: ../../library/re.rst:1531 msgid "``[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?``" msgstr "``[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?``" -#: ../../library/re.rst:1534 +#: ../../library/re.rst:1533 msgid "``%i``" msgstr "``%i``" -#: ../../library/re.rst:1534 +#: ../../library/re.rst:1533 msgid "``[-+]?(0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)``" msgstr "``[-+]?(0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)``" -#: ../../library/re.rst:1536 +#: ../../library/re.rst:1535 msgid "``%o``" msgstr "``%o``" -#: ../../library/re.rst:1536 +#: ../../library/re.rst:1535 msgid "``[-+]?[0-7]+``" msgstr "``[-+]?[0-7]+``" -#: ../../library/re.rst:1538 +#: ../../library/re.rst:1537 msgid "``%s``" msgstr "``%s``" -#: ../../library/re.rst:1538 +#: ../../library/re.rst:1537 msgid "``\\S+``" msgstr "``\\S+``" -#: ../../library/re.rst:1540 +#: ../../library/re.rst:1539 msgid "``%u``" msgstr "``%u``" -#: ../../library/re.rst:1540 +#: ../../library/re.rst:1539 msgid "``\\d+``" msgstr "``\\d+``" -#: ../../library/re.rst:1542 +#: ../../library/re.rst:1541 msgid "``%x``, ``%X``" msgstr "``%x``\\ 、\\ ``%X``" -#: ../../library/re.rst:1542 +#: ../../library/re.rst:1541 msgid "``[-+]?(0[xX])?[\\dA-Fa-f]+``" msgstr "``[-+]?(0[xX])?[\\dA-Fa-f]+``" -#: ../../library/re.rst:1545 +#: ../../library/re.rst:1544 msgid "To extract the filename and numbers from a string like ::" msgstr "" -#: ../../library/re.rst:1549 +#: ../../library/re.rst:1548 msgid "you would use a :c:func:`scanf` format like ::" msgstr "" -#: ../../library/re.rst:1553 +#: ../../library/re.rst:1552 msgid "The equivalent regular expression would be ::" msgstr "" -#: ../../library/re.rst:1561 +#: ../../library/re.rst:1560 msgid "search() vs. match()" msgstr "" -#: ../../library/re.rst:1565 +#: ../../library/re.rst:1564 msgid "" "Python offers different primitive operations based on regular expressions:" msgstr "" -#: ../../library/re.rst:1567 +#: ../../library/re.rst:1566 msgid ":func:`re.match` checks for a match only at the beginning of the string" msgstr "" -#: ../../library/re.rst:1568 +#: ../../library/re.rst:1567 msgid "" ":func:`re.search` checks for a match anywhere in the string (this is what " "Perl does by default)" msgstr "" -#: ../../library/re.rst:1570 +#: ../../library/re.rst:1569 msgid ":func:`re.fullmatch` checks for entire string to be a match" msgstr "" -#: ../../library/re.rst:1582 +#: ../../library/re.rst:1581 msgid "" "Regular expressions beginning with ``'^'`` can be used with :func:`search` " "to restrict the match at the beginning of the string::" msgstr "" -#: ../../library/re.rst:1590 +#: ../../library/re.rst:1589 msgid "" "Note however that in :const:`MULTILINE` mode :func:`match` only matches at " "the beginning of the string, whereas using :func:`search` with a regular " @@ -1819,11 +1819,11 @@ msgid "" "line. ::" msgstr "" -#: ../../library/re.rst:1600 +#: ../../library/re.rst:1599 msgid "Making a Phonebook" msgstr "" -#: ../../library/re.rst:1602 +#: ../../library/re.rst:1601 msgid "" ":func:`split` splits a string into a list delimited by the passed pattern. " "The method is invaluable for converting textual data into data structures " @@ -1831,37 +1831,37 @@ msgid "" "following example that creates a phonebook." msgstr "" -#: ../../library/re.rst:1607 +#: ../../library/re.rst:1606 msgid "" "First, here is the input. Normally it may come from a file, here we are " "using triple-quoted string syntax" msgstr "" -#: ../../library/re.rst:1620 +#: ../../library/re.rst:1619 msgid "" "The entries are separated by one or more newlines. Now we convert the string " "into a list with each nonempty line having its own entry:" msgstr "" -#: ../../library/re.rst:1633 +#: ../../library/re.rst:1632 msgid "" "Finally, split each entry into a list with first name, last name, telephone " "number, and address. We use the ``maxsplit`` parameter of :func:`split` " "because the address has spaces, our splitting pattern, in it:" msgstr "" -#: ../../library/re.rst:1646 +#: ../../library/re.rst:1645 msgid "" "The ``:?`` pattern matches the colon after the last name, so that it does " "not occur in the result list. With a ``maxsplit`` of ``4``, we could " "separate the house number from the street name:" msgstr "" -#: ../../library/re.rst:1661 +#: ../../library/re.rst:1660 msgid "Text Munging" msgstr "" -#: ../../library/re.rst:1663 +#: ../../library/re.rst:1662 msgid "" ":func:`sub` replaces every occurrence of a pattern with a string or the " "result of a function. This example demonstrates using :func:`sub` with a " @@ -1869,11 +1869,11 @@ msgid "" "each word of a sentence except for the first and last characters::" msgstr "" -#: ../../library/re.rst:1680 +#: ../../library/re.rst:1679 msgid "Finding all Adverbs" msgstr "" -#: ../../library/re.rst:1682 +#: ../../library/re.rst:1681 msgid "" ":func:`findall` matches *all* occurrences of a pattern, not just the first " "one as :func:`search` does. For example, if a writer wanted to find all of " @@ -1881,11 +1881,11 @@ msgid "" "manner::" msgstr "" -#: ../../library/re.rst:1693 +#: ../../library/re.rst:1692 msgid "Finding all Adverbs and their Positions" msgstr "" -#: ../../library/re.rst:1695 +#: ../../library/re.rst:1694 msgid "" "If one wants more information about all matches of a pattern than the " "matched text, :func:`finditer` is useful as it provides :ref:`match objects " @@ -1894,11 +1894,11 @@ msgid "" "text, they would use :func:`finditer` in the following manner::" msgstr "" -#: ../../library/re.rst:1709 +#: ../../library/re.rst:1708 msgid "Raw String Notation" msgstr "" -#: ../../library/re.rst:1711 +#: ../../library/re.rst:1710 msgid "" "Raw string notation (``r\"text\"``) keeps regular expressions sane. Without " "it, every backslash (``'\\'``) in a regular expression would have to be " @@ -1906,7 +1906,7 @@ msgid "" "lines of code are functionally identical::" msgstr "" -#: ../../library/re.rst:1721 +#: ../../library/re.rst:1720 msgid "" "When one wants to match a literal backslash, it must be escaped in the " "regular expression. With raw string notation, this means ``r\"\\\\\"``. " @@ -1914,29 +1914,29 @@ msgid "" "following lines of code functionally identical::" msgstr "" -#: ../../library/re.rst:1733 +#: ../../library/re.rst:1732 msgid "Writing a Tokenizer" msgstr "" -#: ../../library/re.rst:1735 +#: ../../library/re.rst:1734 msgid "" "A `tokenizer or scanner `_ " "analyzes a string to categorize groups of characters. This is a useful " "first step in writing a compiler or interpreter." msgstr "" -#: ../../library/re.rst:1739 +#: ../../library/re.rst:1738 msgid "" "The text categories are specified with regular expressions. The technique " "is to combine those into a single master regular expression and to loop over " "successive matches::" msgstr "" -#: ../../library/re.rst:1795 +#: ../../library/re.rst:1794 msgid "The tokenizer produces the following output::" msgstr "" -#: ../../library/re.rst:1818 +#: ../../library/re.rst:1817 msgid "" "Friedl, Jeffrey. Mastering Regular Expressions. 3rd ed., O'Reilly Media, " "2009. The third edition of the book no longer covers Python at all, but the " From a23d0e1c4e96bbeb2509a8903f793cb398c4eb8c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 22 Dec 2022 00:17:55 +0000 Subject: [PATCH 2/3] sync with cpython 3e715e0c --- library/stdtypes.po | 1516 ++++++++++++++++++++++--------------------- library/weakref.po | 118 ++-- 2 files changed, 825 insertions(+), 809 deletions(-) diff --git a/library/stdtypes.po b/library/stdtypes.po index 84437de297..42c3110f84 100644 --- a/library/stdtypes.po +++ b/library/stdtypes.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-11-11 00:20+0000\n" +"POT-Creation-Date: 2022-12-22 00:15+0000\n" "PO-Revision-Date: 2022-06-12 15:22+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -135,8 +135,8 @@ msgstr "結果" #: ../../library/stdtypes.rst:85 ../../library/stdtypes.rst:275 #: ../../library/stdtypes.rst:414 ../../library/stdtypes.rst:921 -#: ../../library/stdtypes.rst:1126 ../../library/stdtypes.rst:2368 -#: ../../library/stdtypes.rst:3583 +#: ../../library/stdtypes.rst:1126 ../../library/stdtypes.rst:2371 +#: ../../library/stdtypes.rst:3589 msgid "Notes" msgstr "註解" @@ -150,8 +150,8 @@ msgstr "" #: ../../library/stdtypes.rst:87 ../../library/stdtypes.rst:285 #: ../../library/stdtypes.rst:923 ../../library/stdtypes.rst:926 -#: ../../library/stdtypes.rst:1137 ../../library/stdtypes.rst:2374 -#: ../../library/stdtypes.rst:3589 +#: ../../library/stdtypes.rst:1137 ../../library/stdtypes.rst:2377 +#: ../../library/stdtypes.rst:3595 msgid "\\(1)" msgstr "\\(1)" @@ -165,8 +165,8 @@ msgstr "" #: ../../library/stdtypes.rst:90 ../../library/stdtypes.rst:288 #: ../../library/stdtypes.rst:308 ../../library/stdtypes.rst:1165 -#: ../../library/stdtypes.rst:2378 ../../library/stdtypes.rst:2380 -#: ../../library/stdtypes.rst:3593 ../../library/stdtypes.rst:3595 +#: ../../library/stdtypes.rst:2381 ../../library/stdtypes.rst:2383 +#: ../../library/stdtypes.rst:3599 ../../library/stdtypes.rst:3601 msgid "\\(2)" msgstr "\\(2)" @@ -179,18 +179,18 @@ msgid "if *x* is false, then ``True``, else ``False``" msgstr "" #: ../../library/stdtypes.rst:93 ../../library/stdtypes.rst:935 -#: ../../library/stdtypes.rst:1168 ../../library/stdtypes.rst:2382 -#: ../../library/stdtypes.rst:2384 ../../library/stdtypes.rst:2386 -#: ../../library/stdtypes.rst:2388 ../../library/stdtypes.rst:3597 -#: ../../library/stdtypes.rst:3599 ../../library/stdtypes.rst:3601 -#: ../../library/stdtypes.rst:3603 +#: ../../library/stdtypes.rst:1168 ../../library/stdtypes.rst:2385 +#: ../../library/stdtypes.rst:2387 ../../library/stdtypes.rst:2389 +#: ../../library/stdtypes.rst:2391 ../../library/stdtypes.rst:3603 +#: ../../library/stdtypes.rst:3605 ../../library/stdtypes.rst:3607 +#: ../../library/stdtypes.rst:3609 msgid "\\(3)" msgstr "\\(3)" #: ../../library/stdtypes.rst:102 ../../library/stdtypes.rst:319 #: ../../library/stdtypes.rst:432 ../../library/stdtypes.rst:972 -#: ../../library/stdtypes.rst:1176 ../../library/stdtypes.rst:2414 -#: ../../library/stdtypes.rst:3633 +#: ../../library/stdtypes.rst:1176 ../../library/stdtypes.rst:2417 +#: ../../library/stdtypes.rst:3639 msgid "Notes:" msgstr "註解:" @@ -229,9 +229,9 @@ msgstr "" msgid "This table summarizes the comparison operations:" msgstr "" -#: ../../library/stdtypes.rst:143 ../../library/stdtypes.rst:2345 -#: ../../library/stdtypes.rst:2368 ../../library/stdtypes.rst:3560 -#: ../../library/stdtypes.rst:3583 +#: ../../library/stdtypes.rst:143 ../../library/stdtypes.rst:2348 +#: ../../library/stdtypes.rst:2371 ../../library/stdtypes.rst:3566 +#: ../../library/stdtypes.rst:3589 msgid "Meaning" msgstr "" @@ -514,7 +514,7 @@ msgid "" msgstr "" #: ../../library/stdtypes.rst:301 ../../library/stdtypes.rst:1158 -#: ../../library/stdtypes.rst:2376 ../../library/stdtypes.rst:3620 +#: ../../library/stdtypes.rst:2379 ../../library/stdtypes.rst:3626 msgid "\\(6)" msgstr "\\(6)" @@ -552,9 +552,9 @@ msgstr "" #: ../../library/stdtypes.rst:310 ../../library/stdtypes.rst:312 #: ../../library/stdtypes.rst:1147 ../../library/stdtypes.rst:1150 -#: ../../library/stdtypes.rst:2401 ../../library/stdtypes.rst:2404 -#: ../../library/stdtypes.rst:2407 ../../library/stdtypes.rst:3616 -#: ../../library/stdtypes.rst:3623 +#: ../../library/stdtypes.rst:2404 ../../library/stdtypes.rst:2407 +#: ../../library/stdtypes.rst:2410 ../../library/stdtypes.rst:3622 +#: ../../library/stdtypes.rst:3629 msgid "\\(5)" msgstr "\\(5)" @@ -690,8 +690,8 @@ msgstr "" #: ../../library/stdtypes.rst:416 ../../library/stdtypes.rst:419 #: ../../library/stdtypes.rst:422 ../../library/stdtypes.rst:1171 -#: ../../library/stdtypes.rst:2390 ../../library/stdtypes.rst:2394 -#: ../../library/stdtypes.rst:3605 ../../library/stdtypes.rst:3609 +#: ../../library/stdtypes.rst:2393 ../../library/stdtypes.rst:2397 +#: ../../library/stdtypes.rst:3611 ../../library/stdtypes.rst:3615 msgid "\\(4)" msgstr "\\(4)" @@ -1266,7 +1266,7 @@ msgid "" "before index *j*)" msgstr "" -#: ../../library/stdtypes.rst:948 ../../library/stdtypes.rst:3591 +#: ../../library/stdtypes.rst:948 ../../library/stdtypes.rst:3597 msgid "\\(8)" msgstr "\\(8)" @@ -1938,8 +1938,8 @@ msgstr "" #: ../../library/stdtypes.rst:1477 msgid "" -"Triple quoted: ``'''Three single quotes'''``, ``\"\"\"Three double quotes" -"\"\"\"``" +"Triple quoted: ``'''Three single quotes'''``, ``\"\"\"Three double " +"quotes\"\"\"``" msgstr "" #: ../../library/stdtypes.rst:1479 @@ -2115,35 +2115,42 @@ msgid "" msgstr "" #: ../../library/stdtypes.rst:1626 +msgid "Return the string encoded to :class:`bytes`." +msgstr "" + +#: ../../library/stdtypes.rst:1628 ../../library/stdtypes.rst:2763 msgid "" -"Return an encoded version of the string as a bytes object. Default encoding " -"is ``'utf-8'``. *errors* may be given to set a different error handling " -"scheme. The default for *errors* is ``'strict'``, meaning that encoding " -"errors raise a :exc:`UnicodeError`. Other possible values are ``'ignore'``, " -"``'replace'``, ``'xmlcharrefreplace'``, ``'backslashreplace'`` and any other " -"name registered via :func:`codecs.register_error`, see section :ref:`error-" -"handlers`. For a list of possible encodings, see section :ref:`standard-" -"encodings`." +"*encoding* defaults to ``'utf-8'``; see :ref:`standard-encodings` for " +"possible values." msgstr "" -#: ../../library/stdtypes.rst:1635 +#: ../../library/stdtypes.rst:1631 msgid "" -"By default, the *errors* argument is not checked for best performances, but " -"only used at the first encoding error. Enable the :ref:`Python Development " -"Mode `, or use a :ref:`debug build ` to check *errors*." +"*errors* controls how encoding errors are handled. If ``'strict'`` (the " +"default), a :exc:`UnicodeError` exception is raised. Other possible values " +"are ``'ignore'``, ``'replace'``, ``'xmlcharrefreplace'``, " +"``'backslashreplace'`` and any other name registered via :func:`codecs." +"register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../library/stdtypes.rst:1640 -msgid "Support for keyword arguments added." +#: ../../library/stdtypes.rst:1638 +msgid "" +"For performance reasons, the value of *errors* is not checked for validity " +"unless an encoding error actually occurs, :ref:`devmode` is enabled or a :" +"ref:`debug build ` is used." msgstr "" -#: ../../library/stdtypes.rst:1643 ../../library/stdtypes.rst:2779 +#: ../../library/stdtypes.rst:1643 ../../library/stdtypes.rst:2782 +msgid "Added support for keyword arguments." +msgstr "新增關鍵字引數的支援。" + +#: ../../library/stdtypes.rst:1646 ../../library/stdtypes.rst:2785 msgid "" -"The *errors* is now checked in development mode and in :ref:`debug mode " -"`." +"The value of the *errors* argument is now checked in :ref:`devmode` and in :" +"ref:`debug mode `." msgstr "" -#: ../../library/stdtypes.rst:1650 +#: ../../library/stdtypes.rst:1653 msgid "" "Return ``True`` if the string ends with the specified *suffix*, otherwise " "return ``False``. *suffix* can also be a tuple of suffixes to look for. " @@ -2151,7 +2158,7 @@ msgid "" "*end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:1658 +#: ../../library/stdtypes.rst:1661 msgid "" "Return a copy of the string where all tab characters are replaced by one or " "more spaces, depending on the current column and the given tab size. Tab " @@ -2160,28 +2167,28 @@ msgid "" "column is set to zero and the string is examined character by character. If " "the character is a tab (``\\t``), one or more space characters are inserted " "in the result until the current column is equal to the next tab position. " -"(The tab character itself is not copied.) If the character is a newline (``" -"\\n``) or return (``\\r``), it is copied and the current column is reset to " -"zero. Any other character is copied unchanged and the current column is " +"(The tab character itself is not copied.) If the character is a newline " +"(``\\n``) or return (``\\r``), it is copied and the current column is reset " +"to zero. Any other character is copied unchanged and the current column is " "incremented by one regardless of how the character is represented when " "printed." msgstr "" -#: ../../library/stdtypes.rst:1679 +#: ../../library/stdtypes.rst:1682 msgid "" "Return the lowest index in the string where substring *sub* is found within " "the slice ``s[start:end]``. Optional arguments *start* and *end* are " "interpreted as in slice notation. Return ``-1`` if *sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:1685 +#: ../../library/stdtypes.rst:1688 msgid "" "The :meth:`~str.find` method should be used only if you need to know the " "position of *sub*. To check if *sub* is a substring or not, use the :" "keyword:`in` operator::" msgstr "" -#: ../../library/stdtypes.rst:1695 +#: ../../library/stdtypes.rst:1698 msgid "" "Perform a string formatting operation. The string on which this method is " "called can contain literal text or replacement fields delimited by braces " @@ -2191,13 +2198,13 @@ msgid "" "the corresponding argument." msgstr "" -#: ../../library/stdtypes.rst:1705 +#: ../../library/stdtypes.rst:1708 msgid "" "See :ref:`formatstrings` for a description of the various formatting options " "that can be specified in format strings." msgstr "" -#: ../../library/stdtypes.rst:1709 +#: ../../library/stdtypes.rst:1712 msgid "" "When formatting a number (:class:`int`, :class:`float`, :class:`complex`, :" "class:`decimal.Decimal` and subclasses) with the ``n`` type (ex: ``'{:n}'." @@ -2208,26 +2215,26 @@ msgid "" "This temporary change affects other threads." msgstr "" -#: ../../library/stdtypes.rst:1718 +#: ../../library/stdtypes.rst:1721 msgid "" "When formatting a number with the ``n`` type, the function sets temporarily " "the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` locale in some cases." msgstr "" -#: ../../library/stdtypes.rst:1726 +#: ../../library/stdtypes.rst:1729 msgid "" "Similar to ``str.format(**mapping)``, except that ``mapping`` is used " "directly and not copied to a :class:`dict`. This is useful if for example " "``mapping`` is a dict subclass:" msgstr "" -#: ../../library/stdtypes.rst:1742 +#: ../../library/stdtypes.rst:1745 msgid "" "Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is " "not found." msgstr "" -#: ../../library/stdtypes.rst:1748 +#: ../../library/stdtypes.rst:1751 msgid "" "Return ``True`` if all characters in the string are alphanumeric and there " "is at least one character, ``False`` otherwise. A character ``c`` is " @@ -2235,24 +2242,24 @@ msgid "" "isdecimal()``, ``c.isdigit()``, or ``c.isnumeric()``." msgstr "" -#: ../../library/stdtypes.rst:1756 +#: ../../library/stdtypes.rst:1759 msgid "" "Return ``True`` if all characters in the string are alphabetic and there is " "at least one character, ``False`` otherwise. Alphabetic characters are " "those characters defined in the Unicode character database as \"Letter\", i." -"e., those with general category property being one of \"Lm\", \"Lt\", \"Lu" -"\", \"Ll\", or \"Lo\". Note that this is different from the \"Alphabetic\" " -"property defined in the Unicode Standard." +"e., those with general category property being one of \"Lm\", \"Lt\", " +"\"Lu\", \"Ll\", or \"Lo\". Note that this is different from the " +"\"Alphabetic\" property defined in the Unicode Standard." msgstr "" -#: ../../library/stdtypes.rst:1765 +#: ../../library/stdtypes.rst:1768 msgid "" "Return ``True`` if the string is empty or all characters in the string are " -"ASCII, ``False`` otherwise. ASCII characters have code points in the range U" -"+0000-U+007F." +"ASCII, ``False`` otherwise. ASCII characters have code points in the range " +"U+0000-U+007F." msgstr "" -#: ../../library/stdtypes.rst:1774 +#: ../../library/stdtypes.rst:1777 msgid "" "Return ``True`` if all characters in the string are decimal characters and " "there is at least one character, ``False`` otherwise. Decimal characters are " @@ -2261,7 +2268,7 @@ msgid "" "General Category \"Nd\"." msgstr "" -#: ../../library/stdtypes.rst:1784 +#: ../../library/stdtypes.rst:1787 msgid "" "Return ``True`` if all characters in the string are digits and there is at " "least one character, ``False`` otherwise. Digits include decimal characters " @@ -2271,32 +2278,32 @@ msgid "" "property value Numeric_Type=Digit or Numeric_Type=Decimal." msgstr "" -#: ../../library/stdtypes.rst:1794 +#: ../../library/stdtypes.rst:1797 msgid "" "Return ``True`` if the string is a valid identifier according to the " "language definition, section :ref:`identifiers`." msgstr "" -#: ../../library/stdtypes.rst:1797 +#: ../../library/stdtypes.rst:1800 msgid "" "Call :func:`keyword.iskeyword` to test whether string ``s`` is a reserved " "identifier, such as :keyword:`def` and :keyword:`class`." msgstr "" -#: ../../library/stdtypes.rst:1800 +#: ../../library/stdtypes.rst:1803 msgid "Example: ::" msgstr "" "範例:\n" "\n" "::" -#: ../../library/stdtypes.rst:1813 +#: ../../library/stdtypes.rst:1816 msgid "" "Return ``True`` if all cased characters [4]_ in the string are lowercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:1819 +#: ../../library/stdtypes.rst:1822 msgid "" "Return ``True`` if all characters in the string are numeric characters, and " "there is at least one character, ``False`` otherwise. Numeric characters " @@ -2306,7 +2313,7 @@ msgid "" "Numeric_Type=Decimal or Numeric_Type=Numeric." msgstr "" -#: ../../library/stdtypes.rst:1829 +#: ../../library/stdtypes.rst:1832 msgid "" "Return ``True`` if all characters in the string are printable or the string " "is empty, ``False`` otherwise. Nonprintable characters are those characters " @@ -2317,20 +2324,20 @@ msgid "" "of strings written to :data:`sys.stdout` or :data:`sys.stderr`.)" msgstr "" -#: ../../library/stdtypes.rst:1840 +#: ../../library/stdtypes.rst:1843 msgid "" "Return ``True`` if there are only whitespace characters in the string and " "there is at least one character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:1843 +#: ../../library/stdtypes.rst:1846 msgid "" "A character is *whitespace* if in the Unicode character database (see :mod:" -"`unicodedata`), either its general category is ``Zs`` (\"Separator, space" -"\"), or its bidirectional class is one of ``WS``, ``B``, or ``S``." +"`unicodedata`), either its general category is ``Zs`` (\"Separator, " +"space\"), or its bidirectional class is one of ``WS``, ``B``, or ``S``." msgstr "" -#: ../../library/stdtypes.rst:1851 +#: ../../library/stdtypes.rst:1854 msgid "" "Return ``True`` if the string is a titlecased string and there is at least " "one character, for example uppercase characters may only follow uncased " @@ -2338,13 +2345,13 @@ msgid "" "otherwise." msgstr "" -#: ../../library/stdtypes.rst:1858 +#: ../../library/stdtypes.rst:1861 msgid "" "Return ``True`` if all cased characters [4]_ in the string are uppercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:1876 +#: ../../library/stdtypes.rst:1879 msgid "" "Return a string which is the concatenation of the strings in *iterable*. A :" "exc:`TypeError` will be raised if there are any non-string values in " @@ -2352,26 +2359,26 @@ msgid "" "elements is the string providing this method." msgstr "" -#: ../../library/stdtypes.rst:1884 +#: ../../library/stdtypes.rst:1887 msgid "" "Return the string left justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:1891 +#: ../../library/stdtypes.rst:1894 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "lowercase." msgstr "" -#: ../../library/stdtypes.rst:1894 +#: ../../library/stdtypes.rst:1897 msgid "" "The lowercasing algorithm used is described in section 3.13 of the Unicode " "Standard." msgstr "" -#: ../../library/stdtypes.rst:1900 +#: ../../library/stdtypes.rst:1903 msgid "" "Return a copy of the string with leading characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -2380,19 +2387,19 @@ msgid "" "are stripped::" msgstr "" -#: ../../library/stdtypes.rst:1910 +#: ../../library/stdtypes.rst:1913 msgid "" "See :meth:`str.removeprefix` for a method that will remove a single prefix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:1921 +#: ../../library/stdtypes.rst:1924 msgid "" "This static method returns a translation table usable for :meth:`str." "translate`." msgstr "" -#: ../../library/stdtypes.rst:1923 +#: ../../library/stdtypes.rst:1926 msgid "" "If there is only one argument, it must be a dictionary mapping Unicode " "ordinals (integers) or characters (strings of length 1) to Unicode ordinals, " @@ -2400,7 +2407,7 @@ msgid "" "converted to ordinals." msgstr "" -#: ../../library/stdtypes.rst:1928 +#: ../../library/stdtypes.rst:1931 msgid "" "If there are two arguments, they must be strings of equal length, and in the " "resulting dictionary, each character in x will be mapped to the character at " @@ -2408,7 +2415,7 @@ msgid "" "whose characters will be mapped to ``None`` in the result." msgstr "" -#: ../../library/stdtypes.rst:1936 +#: ../../library/stdtypes.rst:1939 msgid "" "Split the string at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -2416,47 +2423,47 @@ msgid "" "containing the string itself, followed by two empty strings." msgstr "" -#: ../../library/stdtypes.rst:1944 +#: ../../library/stdtypes.rst:1947 msgid "" "If the string starts with the *prefix* string, return " "``string[len(prefix):]``. Otherwise, return a copy of the original string::" msgstr "" -#: ../../library/stdtypes.rst:1958 +#: ../../library/stdtypes.rst:1961 msgid "" "If the string ends with the *suffix* string and that *suffix* is not empty, " "return ``string[:-len(suffix)]``. Otherwise, return a copy of the original " "string::" msgstr "" -#: ../../library/stdtypes.rst:1972 +#: ../../library/stdtypes.rst:1975 msgid "" "Return a copy of the string with all occurrences of substring *old* replaced " "by *new*. If the optional argument *count* is given, only the first *count* " "occurrences are replaced." msgstr "" -#: ../../library/stdtypes.rst:1979 +#: ../../library/stdtypes.rst:1982 msgid "" "Return the highest index in the string where substring *sub* is found, such " "that *sub* is contained within ``s[start:end]``. Optional arguments *start* " "and *end* are interpreted as in slice notation. Return ``-1`` on failure." msgstr "" -#: ../../library/stdtypes.rst:1986 +#: ../../library/stdtypes.rst:1989 msgid "" "Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is " "not found." msgstr "" -#: ../../library/stdtypes.rst:1992 +#: ../../library/stdtypes.rst:1995 msgid "" "Return the string right justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:1999 +#: ../../library/stdtypes.rst:2002 msgid "" "Split the string at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -2464,7 +2471,7 @@ msgid "" "containing two empty strings, followed by the string itself." msgstr "" -#: ../../library/stdtypes.rst:2007 +#: ../../library/stdtypes.rst:2010 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done, the " @@ -2473,7 +2480,7 @@ msgid "" "behaves like :meth:`split` which is described in detail below." msgstr "" -#: ../../library/stdtypes.rst:2016 +#: ../../library/stdtypes.rst:2019 msgid "" "Return a copy of the string with trailing characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -2482,13 +2489,13 @@ msgid "" "are stripped::" msgstr "" -#: ../../library/stdtypes.rst:2026 +#: ../../library/stdtypes.rst:2029 msgid "" "See :meth:`str.removesuffix` for a method that will remove a single suffix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:2036 +#: ../../library/stdtypes.rst:2039 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, " @@ -2497,7 +2504,7 @@ msgid "" "possible splits are made)." msgstr "" -#: ../../library/stdtypes.rst:2042 +#: ../../library/stdtypes.rst:2045 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns " @@ -2506,23 +2513,23 @@ msgid "" "Splitting an empty string with a specified separator returns ``['']``." msgstr "" -#: ../../library/stdtypes.rst:2048 ../../library/stdtypes.rst:2064 -#: ../../library/stdtypes.rst:2116 ../../library/stdtypes.rst:2184 -#: ../../library/stdtypes.rst:2251 ../../library/stdtypes.rst:3095 -#: ../../library/stdtypes.rst:3111 ../../library/stdtypes.rst:3202 -#: ../../library/stdtypes.rst:3218 ../../library/stdtypes.rst:3243 -#: ../../library/stdtypes.rst:3257 ../../library/stdtypes.rst:3285 -#: ../../library/stdtypes.rst:3299 ../../library/stdtypes.rst:3317 -#: ../../library/stdtypes.rst:3344 ../../library/stdtypes.rst:3367 -#: ../../library/stdtypes.rst:3394 ../../library/stdtypes.rst:3436 -#: ../../library/stdtypes.rst:3460 +#: ../../library/stdtypes.rst:2051 ../../library/stdtypes.rst:2067 +#: ../../library/stdtypes.rst:2119 ../../library/stdtypes.rst:2187 +#: ../../library/stdtypes.rst:2254 ../../library/stdtypes.rst:3101 +#: ../../library/stdtypes.rst:3117 ../../library/stdtypes.rst:3208 +#: ../../library/stdtypes.rst:3224 ../../library/stdtypes.rst:3249 +#: ../../library/stdtypes.rst:3263 ../../library/stdtypes.rst:3291 +#: ../../library/stdtypes.rst:3305 ../../library/stdtypes.rst:3323 +#: ../../library/stdtypes.rst:3350 ../../library/stdtypes.rst:3373 +#: ../../library/stdtypes.rst:3400 ../../library/stdtypes.rst:3442 +#: ../../library/stdtypes.rst:3466 msgid "For example::" msgstr "" "舉例來說:\n" "\n" "::" -#: ../../library/stdtypes.rst:2057 +#: ../../library/stdtypes.rst:2060 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive whitespace are regarded as a single separator, " @@ -2532,131 +2539,131 @@ msgid "" "returns ``[]``." msgstr "" -#: ../../library/stdtypes.rst:2079 +#: ../../library/stdtypes.rst:2082 msgid "" "Return a list of the lines in the string, breaking at line boundaries. Line " "breaks are not included in the resulting list unless *keepends* is given and " "true." msgstr "" -#: ../../library/stdtypes.rst:2083 +#: ../../library/stdtypes.rst:2086 msgid "" "This method splits on the following line boundaries. In particular, the " "boundaries are a superset of :term:`universal newlines`." msgstr "" -#: ../../library/stdtypes.rst:2087 +#: ../../library/stdtypes.rst:2090 msgid "Representation" msgstr "" -#: ../../library/stdtypes.rst:2087 +#: ../../library/stdtypes.rst:2090 msgid "Description" msgstr "描述" -#: ../../library/stdtypes.rst:2089 +#: ../../library/stdtypes.rst:2092 msgid "``\\n``" msgstr "``\\n``" -#: ../../library/stdtypes.rst:2089 +#: ../../library/stdtypes.rst:2092 msgid "Line Feed" msgstr "" -#: ../../library/stdtypes.rst:2091 +#: ../../library/stdtypes.rst:2094 msgid "``\\r``" msgstr "``\\r``" -#: ../../library/stdtypes.rst:2091 +#: ../../library/stdtypes.rst:2094 msgid "Carriage Return" msgstr "" -#: ../../library/stdtypes.rst:2093 +#: ../../library/stdtypes.rst:2096 msgid "``\\r\\n``" msgstr "``\\r\\n``" -#: ../../library/stdtypes.rst:2093 +#: ../../library/stdtypes.rst:2096 msgid "Carriage Return + Line Feed" msgstr "" -#: ../../library/stdtypes.rst:2095 +#: ../../library/stdtypes.rst:2098 msgid "``\\v`` or ``\\x0b``" msgstr "``\\v`` 或 ``\\x0b``" -#: ../../library/stdtypes.rst:2095 +#: ../../library/stdtypes.rst:2098 msgid "Line Tabulation" msgstr "" -#: ../../library/stdtypes.rst:2097 +#: ../../library/stdtypes.rst:2100 msgid "``\\f`` or ``\\x0c``" msgstr "``\\f`` 或 ``\\x0c``" -#: ../../library/stdtypes.rst:2097 +#: ../../library/stdtypes.rst:2100 msgid "Form Feed" msgstr "" -#: ../../library/stdtypes.rst:2099 +#: ../../library/stdtypes.rst:2102 msgid "``\\x1c``" msgstr "``\\x1c``" -#: ../../library/stdtypes.rst:2099 +#: ../../library/stdtypes.rst:2102 msgid "File Separator" msgstr "" -#: ../../library/stdtypes.rst:2101 +#: ../../library/stdtypes.rst:2104 msgid "``\\x1d``" msgstr "``\\x1d``" -#: ../../library/stdtypes.rst:2101 +#: ../../library/stdtypes.rst:2104 msgid "Group Separator" msgstr "" -#: ../../library/stdtypes.rst:2103 +#: ../../library/stdtypes.rst:2106 msgid "``\\x1e``" msgstr "``\\x1e``" -#: ../../library/stdtypes.rst:2103 +#: ../../library/stdtypes.rst:2106 msgid "Record Separator" msgstr "" -#: ../../library/stdtypes.rst:2105 +#: ../../library/stdtypes.rst:2108 msgid "``\\x85``" msgstr "``\\x85``" -#: ../../library/stdtypes.rst:2105 +#: ../../library/stdtypes.rst:2108 msgid "Next Line (C1 Control Code)" msgstr "" -#: ../../library/stdtypes.rst:2107 +#: ../../library/stdtypes.rst:2110 msgid "``\\u2028``" msgstr "``\\u2028``" -#: ../../library/stdtypes.rst:2107 +#: ../../library/stdtypes.rst:2110 msgid "Line Separator" msgstr "" -#: ../../library/stdtypes.rst:2109 +#: ../../library/stdtypes.rst:2112 msgid "``\\u2029``" msgstr "``\\u2029``" -#: ../../library/stdtypes.rst:2109 +#: ../../library/stdtypes.rst:2112 msgid "Paragraph Separator" msgstr "" -#: ../../library/stdtypes.rst:2114 +#: ../../library/stdtypes.rst:2117 msgid "``\\v`` and ``\\f`` added to list of line boundaries." msgstr "" -#: ../../library/stdtypes.rst:2123 +#: ../../library/stdtypes.rst:2126 msgid "" "Unlike :meth:`~str.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../library/stdtypes.rst:2132 +#: ../../library/stdtypes.rst:2135 msgid "For comparison, ``split('\\n')`` gives::" msgstr "" -#: ../../library/stdtypes.rst:2142 +#: ../../library/stdtypes.rst:2145 msgid "" "Return ``True`` if string starts with the *prefix*, otherwise return " "``False``. *prefix* can also be a tuple of prefixes to look for. With " @@ -2664,7 +2671,7 @@ msgid "" "*end*, stop comparing string at that position." msgstr "" -#: ../../library/stdtypes.rst:2150 +#: ../../library/stdtypes.rst:2153 msgid "" "Return a copy of the string with the leading and trailing characters " "removed. The *chars* argument is a string specifying the set of characters " @@ -2673,7 +2680,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:2161 +#: ../../library/stdtypes.rst:2164 msgid "" "The outermost leading and trailing *chars* argument values are stripped from " "the string. Characters are removed from the leading end until reaching a " @@ -2681,20 +2688,20 @@ msgid "" "A similar action takes place on the trailing end. For example::" msgstr "" -#: ../../library/stdtypes.rst:2174 +#: ../../library/stdtypes.rst:2177 msgid "" "Return a copy of the string with uppercase characters converted to lowercase " "and vice versa. Note that it is not necessarily true that ``s.swapcase()." "swapcase() == s``." msgstr "" -#: ../../library/stdtypes.rst:2181 +#: ../../library/stdtypes.rst:2184 msgid "" "Return a titlecased version of the string where words start with an " "uppercase character and the remaining characters are lowercase." msgstr "" -#: ../../library/stdtypes.rst:2189 ../../library/stdtypes.rst:3404 +#: ../../library/stdtypes.rst:2192 ../../library/stdtypes.rst:3410 msgid "" "The algorithm uses a simple language-independent definition of a word as " "groups of consecutive letters. The definition works in many contexts but it " @@ -2702,19 +2709,19 @@ msgid "" "which may not be the desired result::" msgstr "" -#: ../../library/stdtypes.rst:2197 +#: ../../library/stdtypes.rst:2200 msgid "" "The :func:`string.capwords` function does not have this problem, as it " "splits words on spaces only." msgstr "" -#: ../../library/stdtypes.rst:2200 +#: ../../library/stdtypes.rst:2203 msgid "" "Alternatively, a workaround for apostrophes can be constructed using regular " "expressions::" msgstr "" -#: ../../library/stdtypes.rst:2215 +#: ../../library/stdtypes.rst:2218 msgid "" "Return a copy of the string in which each character has been mapped through " "the given translation table. The table must be an object that implements " @@ -2726,19 +2733,19 @@ msgid "" "exception, to map the character to itself." msgstr "" -#: ../../library/stdtypes.rst:2224 +#: ../../library/stdtypes.rst:2227 msgid "" "You can use :meth:`str.maketrans` to create a translation map from character-" "to-character mappings in different formats." msgstr "" -#: ../../library/stdtypes.rst:2227 +#: ../../library/stdtypes.rst:2230 msgid "" "See also the :mod:`codecs` module for a more flexible approach to custom " "character mappings." msgstr "" -#: ../../library/stdtypes.rst:2233 +#: ../../library/stdtypes.rst:2236 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s`` " @@ -2747,13 +2754,13 @@ msgid "" "titlecase)." msgstr "" -#: ../../library/stdtypes.rst:2239 +#: ../../library/stdtypes.rst:2242 msgid "" "The uppercasing algorithm used is described in section 3.13 of the Unicode " "Standard." msgstr "" -#: ../../library/stdtypes.rst:2245 +#: ../../library/stdtypes.rst:2248 msgid "" "Return a copy of the string left filled with ASCII ``'0'`` digits to make a " "string of length *width*. A leading sign prefix (``'+'``/``'-'``) is handled " @@ -2761,11 +2768,11 @@ msgid "" "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2263 +#: ../../library/stdtypes.rst:2266 msgid "``printf``-style String Formatting" msgstr "" -#: ../../library/stdtypes.rst:2276 +#: ../../library/stdtypes.rst:2279 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " @@ -2776,7 +2783,7 @@ msgid "" "or extensibility." msgstr "" -#: ../../library/stdtypes.rst:2284 +#: ../../library/stdtypes.rst:2287 msgid "" "String objects have one unique built-in operation: the ``%`` operator " "(modulo). This is also known as the string *formatting* or *interpolation* " @@ -2786,7 +2793,7 @@ msgid "" "in the C language." msgstr "" -#: ../../library/stdtypes.rst:2290 +#: ../../library/stdtypes.rst:2293 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -2794,36 +2801,36 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:2300 ../../library/stdtypes.rst:3515 +#: ../../library/stdtypes.rst:2303 ../../library/stdtypes.rst:3521 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: ../../library/stdtypes.rst:2303 ../../library/stdtypes.rst:3518 +#: ../../library/stdtypes.rst:2306 ../../library/stdtypes.rst:3524 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../library/stdtypes.rst:2305 ../../library/stdtypes.rst:3520 +#: ../../library/stdtypes.rst:2308 ../../library/stdtypes.rst:3526 msgid "" "Mapping key (optional), consisting of a parenthesised sequence of characters " "(for example, ``(somename)``)." msgstr "" -#: ../../library/stdtypes.rst:2308 ../../library/stdtypes.rst:3523 +#: ../../library/stdtypes.rst:2311 ../../library/stdtypes.rst:3529 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../library/stdtypes.rst:2311 ../../library/stdtypes.rst:3526 +#: ../../library/stdtypes.rst:2314 ../../library/stdtypes.rst:3532 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is read from the next element of the tuple in *values*, and the " "object to convert comes after the minimum field width and optional precision." msgstr "" -#: ../../library/stdtypes.rst:2315 ../../library/stdtypes.rst:3530 +#: ../../library/stdtypes.rst:2318 ../../library/stdtypes.rst:3536 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. " "If specified as ``'*'`` (an asterisk), the actual precision is read from the " @@ -2831,15 +2838,15 @@ msgid "" "the precision." msgstr "" -#: ../../library/stdtypes.rst:2320 ../../library/stdtypes.rst:3535 +#: ../../library/stdtypes.rst:2323 ../../library/stdtypes.rst:3541 msgid "Length modifier (optional)." msgstr "" -#: ../../library/stdtypes.rst:2322 ../../library/stdtypes.rst:3537 +#: ../../library/stdtypes.rst:2325 ../../library/stdtypes.rst:3543 msgid "Conversion type." msgstr "" -#: ../../library/stdtypes.rst:2324 +#: ../../library/stdtypes.rst:2327 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the string *must* include a parenthesised mapping key into that " @@ -2847,279 +2854,279 @@ msgid "" "selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:2333 ../../library/stdtypes.rst:3548 +#: ../../library/stdtypes.rst:2336 ../../library/stdtypes.rst:3554 msgid "" "In this case no ``*`` specifiers may occur in a format (since they require a " "sequential parameter list)." msgstr "" -#: ../../library/stdtypes.rst:2336 ../../library/stdtypes.rst:3551 +#: ../../library/stdtypes.rst:2339 ../../library/stdtypes.rst:3557 msgid "The conversion flag characters are:" msgstr "" -#: ../../library/stdtypes.rst:2345 ../../library/stdtypes.rst:3560 +#: ../../library/stdtypes.rst:2348 ../../library/stdtypes.rst:3566 msgid "Flag" msgstr "" -#: ../../library/stdtypes.rst:2347 ../../library/stdtypes.rst:3562 +#: ../../library/stdtypes.rst:2350 ../../library/stdtypes.rst:3568 msgid "``'#'``" msgstr "``'#'``" -#: ../../library/stdtypes.rst:2347 ../../library/stdtypes.rst:3562 +#: ../../library/stdtypes.rst:2350 ../../library/stdtypes.rst:3568 msgid "" "The value conversion will use the \"alternate form\" (where defined below)." msgstr "" -#: ../../library/stdtypes.rst:2350 ../../library/stdtypes.rst:3565 +#: ../../library/stdtypes.rst:2353 ../../library/stdtypes.rst:3571 msgid "``'0'``" msgstr "``'0'``" -#: ../../library/stdtypes.rst:2350 ../../library/stdtypes.rst:3565 +#: ../../library/stdtypes.rst:2353 ../../library/stdtypes.rst:3571 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../library/stdtypes.rst:2352 ../../library/stdtypes.rst:3567 +#: ../../library/stdtypes.rst:2355 ../../library/stdtypes.rst:3573 msgid "``'-'``" msgstr "``'-'``" -#: ../../library/stdtypes.rst:2352 ../../library/stdtypes.rst:3567 +#: ../../library/stdtypes.rst:2355 ../../library/stdtypes.rst:3573 msgid "" "The converted value is left adjusted (overrides the ``'0'`` conversion if " "both are given)." msgstr "" -#: ../../library/stdtypes.rst:2355 ../../library/stdtypes.rst:3570 +#: ../../library/stdtypes.rst:2358 ../../library/stdtypes.rst:3576 msgid "``' '``" msgstr "``' '``" -#: ../../library/stdtypes.rst:2355 ../../library/stdtypes.rst:3570 +#: ../../library/stdtypes.rst:2358 ../../library/stdtypes.rst:3576 msgid "" "(a space) A blank should be left before a positive number (or empty string) " "produced by a signed conversion." msgstr "" -#: ../../library/stdtypes.rst:2358 ../../library/stdtypes.rst:3573 +#: ../../library/stdtypes.rst:2361 ../../library/stdtypes.rst:3579 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/stdtypes.rst:2358 ../../library/stdtypes.rst:3573 +#: ../../library/stdtypes.rst:2361 ../../library/stdtypes.rst:3579 msgid "" "A sign character (``'+'`` or ``'-'``) will precede the conversion (overrides " "a \"space\" flag)." msgstr "" -#: ../../library/stdtypes.rst:2362 ../../library/stdtypes.rst:3577 +#: ../../library/stdtypes.rst:2365 ../../library/stdtypes.rst:3583 msgid "" "A length modifier (``h``, ``l``, or ``L``) may be present, but is ignored as " "it is not necessary for Python -- so e.g. ``%ld`` is identical to ``%d``." msgstr "" -#: ../../library/stdtypes.rst:2365 ../../library/stdtypes.rst:3580 +#: ../../library/stdtypes.rst:2368 ../../library/stdtypes.rst:3586 msgid "The conversion types are:" msgstr "" -#: ../../library/stdtypes.rst:2368 ../../library/stdtypes.rst:3583 +#: ../../library/stdtypes.rst:2371 ../../library/stdtypes.rst:3589 msgid "Conversion" msgstr "" -#: ../../library/stdtypes.rst:2370 ../../library/stdtypes.rst:3585 +#: ../../library/stdtypes.rst:2373 ../../library/stdtypes.rst:3591 msgid "``'d'``" msgstr "``'d'``" -#: ../../library/stdtypes.rst:2370 ../../library/stdtypes.rst:2372 -#: ../../library/stdtypes.rst:3585 ../../library/stdtypes.rst:3587 +#: ../../library/stdtypes.rst:2373 ../../library/stdtypes.rst:2375 +#: ../../library/stdtypes.rst:3591 ../../library/stdtypes.rst:3593 msgid "Signed integer decimal." msgstr "" -#: ../../library/stdtypes.rst:2372 ../../library/stdtypes.rst:3587 +#: ../../library/stdtypes.rst:2375 ../../library/stdtypes.rst:3593 msgid "``'i'``" msgstr "``'i'``" -#: ../../library/stdtypes.rst:2374 ../../library/stdtypes.rst:3589 +#: ../../library/stdtypes.rst:2377 ../../library/stdtypes.rst:3595 msgid "``'o'``" msgstr "``'o'``" -#: ../../library/stdtypes.rst:2374 ../../library/stdtypes.rst:3589 +#: ../../library/stdtypes.rst:2377 ../../library/stdtypes.rst:3595 msgid "Signed octal value." msgstr "" -#: ../../library/stdtypes.rst:2376 ../../library/stdtypes.rst:3591 +#: ../../library/stdtypes.rst:2379 ../../library/stdtypes.rst:3597 msgid "``'u'``" msgstr "``'u'``" -#: ../../library/stdtypes.rst:2376 ../../library/stdtypes.rst:3591 +#: ../../library/stdtypes.rst:2379 ../../library/stdtypes.rst:3597 msgid "Obsolete type -- it is identical to ``'d'``." msgstr "" -#: ../../library/stdtypes.rst:2378 ../../library/stdtypes.rst:3593 +#: ../../library/stdtypes.rst:2381 ../../library/stdtypes.rst:3599 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/stdtypes.rst:2378 ../../library/stdtypes.rst:3593 +#: ../../library/stdtypes.rst:2381 ../../library/stdtypes.rst:3599 msgid "Signed hexadecimal (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:2380 ../../library/stdtypes.rst:3595 +#: ../../library/stdtypes.rst:2383 ../../library/stdtypes.rst:3601 msgid "``'X'``" msgstr "``'X'``" -#: ../../library/stdtypes.rst:2380 ../../library/stdtypes.rst:3595 +#: ../../library/stdtypes.rst:2383 ../../library/stdtypes.rst:3601 msgid "Signed hexadecimal (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:2382 ../../library/stdtypes.rst:3597 +#: ../../library/stdtypes.rst:2385 ../../library/stdtypes.rst:3603 msgid "``'e'``" msgstr "``'e'``" -#: ../../library/stdtypes.rst:2382 ../../library/stdtypes.rst:3597 +#: ../../library/stdtypes.rst:2385 ../../library/stdtypes.rst:3603 msgid "Floating point exponential format (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:2384 ../../library/stdtypes.rst:3599 +#: ../../library/stdtypes.rst:2387 ../../library/stdtypes.rst:3605 msgid "``'E'``" msgstr "``'E'``" -#: ../../library/stdtypes.rst:2384 ../../library/stdtypes.rst:3599 +#: ../../library/stdtypes.rst:2387 ../../library/stdtypes.rst:3605 msgid "Floating point exponential format (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:2386 ../../library/stdtypes.rst:3601 +#: ../../library/stdtypes.rst:2389 ../../library/stdtypes.rst:3607 msgid "``'f'``" msgstr "``'f'``" -#: ../../library/stdtypes.rst:2386 ../../library/stdtypes.rst:2388 -#: ../../library/stdtypes.rst:3601 ../../library/stdtypes.rst:3603 +#: ../../library/stdtypes.rst:2389 ../../library/stdtypes.rst:2391 +#: ../../library/stdtypes.rst:3607 ../../library/stdtypes.rst:3609 msgid "Floating point decimal format." msgstr "" -#: ../../library/stdtypes.rst:2388 ../../library/stdtypes.rst:3603 +#: ../../library/stdtypes.rst:2391 ../../library/stdtypes.rst:3609 msgid "``'F'``" msgstr "``'F'``" -#: ../../library/stdtypes.rst:2390 ../../library/stdtypes.rst:3605 +#: ../../library/stdtypes.rst:2393 ../../library/stdtypes.rst:3611 msgid "``'g'``" msgstr "``'g'``" -#: ../../library/stdtypes.rst:2390 ../../library/stdtypes.rst:3605 +#: ../../library/stdtypes.rst:2393 ../../library/stdtypes.rst:3611 msgid "" "Floating point format. Uses lowercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:2394 ../../library/stdtypes.rst:3609 +#: ../../library/stdtypes.rst:2397 ../../library/stdtypes.rst:3615 msgid "``'G'``" msgstr "``'G'``" -#: ../../library/stdtypes.rst:2394 ../../library/stdtypes.rst:3609 +#: ../../library/stdtypes.rst:2397 ../../library/stdtypes.rst:3615 msgid "" "Floating point format. Uses uppercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:2398 ../../library/stdtypes.rst:3613 +#: ../../library/stdtypes.rst:2401 ../../library/stdtypes.rst:3619 msgid "``'c'``" msgstr "``'c'``" -#: ../../library/stdtypes.rst:2398 +#: ../../library/stdtypes.rst:2401 msgid "Single character (accepts integer or single character string)." msgstr "" -#: ../../library/stdtypes.rst:2401 ../../library/stdtypes.rst:3626 +#: ../../library/stdtypes.rst:2404 ../../library/stdtypes.rst:3632 msgid "``'r'``" msgstr "``'r'``" -#: ../../library/stdtypes.rst:2401 +#: ../../library/stdtypes.rst:2404 msgid "String (converts any Python object using :func:`repr`)." msgstr "" -#: ../../library/stdtypes.rst:2404 ../../library/stdtypes.rst:3620 +#: ../../library/stdtypes.rst:2407 ../../library/stdtypes.rst:3626 msgid "``'s'``" msgstr "``'s'``" -#: ../../library/stdtypes.rst:2404 +#: ../../library/stdtypes.rst:2407 msgid "String (converts any Python object using :func:`str`)." msgstr "" -#: ../../library/stdtypes.rst:2407 ../../library/stdtypes.rst:3623 +#: ../../library/stdtypes.rst:2410 ../../library/stdtypes.rst:3629 msgid "``'a'``" msgstr "``'a'``" -#: ../../library/stdtypes.rst:2407 +#: ../../library/stdtypes.rst:2410 msgid "String (converts any Python object using :func:`ascii`)." msgstr "" -#: ../../library/stdtypes.rst:2410 ../../library/stdtypes.rst:3629 +#: ../../library/stdtypes.rst:2413 ../../library/stdtypes.rst:3635 msgid "``'%'``" msgstr "``'%'``" -#: ../../library/stdtypes.rst:2410 ../../library/stdtypes.rst:3629 +#: ../../library/stdtypes.rst:2413 ../../library/stdtypes.rst:3635 msgid "No argument is converted, results in a ``'%'`` character in the result." msgstr "" -#: ../../library/stdtypes.rst:2417 ../../library/stdtypes.rst:3636 +#: ../../library/stdtypes.rst:2420 ../../library/stdtypes.rst:3642 msgid "" "The alternate form causes a leading octal specifier (``'0o'``) to be " "inserted before the first digit." msgstr "" -#: ../../library/stdtypes.rst:2421 ../../library/stdtypes.rst:3640 +#: ../../library/stdtypes.rst:2424 ../../library/stdtypes.rst:3646 msgid "" "The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on " "whether the ``'x'`` or ``'X'`` format was used) to be inserted before the " "first digit." msgstr "" -#: ../../library/stdtypes.rst:2425 ../../library/stdtypes.rst:3644 +#: ../../library/stdtypes.rst:2428 ../../library/stdtypes.rst:3650 msgid "" "The alternate form causes the result to always contain a decimal point, even " "if no digits follow it." msgstr "" -#: ../../library/stdtypes.rst:2428 ../../library/stdtypes.rst:3647 +#: ../../library/stdtypes.rst:2431 ../../library/stdtypes.rst:3653 msgid "" "The precision determines the number of digits after the decimal point and " "defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:2432 ../../library/stdtypes.rst:3651 +#: ../../library/stdtypes.rst:2435 ../../library/stdtypes.rst:3657 msgid "" "The alternate form causes the result to always contain a decimal point, and " "trailing zeroes are not removed as they would otherwise be." msgstr "" -#: ../../library/stdtypes.rst:2435 ../../library/stdtypes.rst:3654 +#: ../../library/stdtypes.rst:2438 ../../library/stdtypes.rst:3660 msgid "" "The precision determines the number of significant digits before and after " "the decimal point and defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:2439 ../../library/stdtypes.rst:3658 +#: ../../library/stdtypes.rst:2442 ../../library/stdtypes.rst:3664 msgid "If precision is ``N``, the output is truncated to ``N`` characters." msgstr "" -#: ../../library/stdtypes.rst:2442 ../../library/stdtypes.rst:3667 +#: ../../library/stdtypes.rst:2445 ../../library/stdtypes.rst:3673 msgid "See :pep:`237`." msgstr "參閱 :pep:`237`\\ 。" -#: ../../library/stdtypes.rst:2444 +#: ../../library/stdtypes.rst:2447 msgid "" "Since Python strings have an explicit length, ``%s`` conversions do not " "assume that ``'\\0'`` is the end of the string." msgstr "" -#: ../../library/stdtypes.rst:2449 +#: ../../library/stdtypes.rst:2452 msgid "" "``%f`` conversions for numbers whose absolute value is over 1e50 are no " "longer replaced by ``%g`` conversions." msgstr "" -#: ../../library/stdtypes.rst:2460 +#: ../../library/stdtypes.rst:2463 msgid "" "Binary Sequence Types --- :class:`bytes`, :class:`bytearray`, :class:" "`memoryview`" msgstr "" -#: ../../library/stdtypes.rst:2468 +#: ../../library/stdtypes.rst:2471 msgid "" "The core built-in types for manipulating binary data are :class:`bytes` and :" "class:`bytearray`. They are supported by :class:`memoryview` which uses the :" @@ -3127,17 +3134,17 @@ msgid "" "objects without needing to make a copy." msgstr "" -#: ../../library/stdtypes.rst:2473 +#: ../../library/stdtypes.rst:2476 msgid "" "The :mod:`array` module supports efficient storage of basic data types like " "32-bit integers and IEEE754 double-precision floating values." msgstr "" -#: ../../library/stdtypes.rst:2479 +#: ../../library/stdtypes.rst:2482 msgid "Bytes Objects" msgstr "" -#: ../../library/stdtypes.rst:2483 +#: ../../library/stdtypes.rst:2486 msgid "" "Bytes objects are immutable sequences of single bytes. Since many major " "binary protocols are based on the ASCII text encoding, bytes objects offer " @@ -3145,40 +3152,40 @@ msgid "" "and are closely related to string objects in a variety of other ways." msgstr "" -#: ../../library/stdtypes.rst:2490 +#: ../../library/stdtypes.rst:2493 msgid "" "Firstly, the syntax for bytes literals is largely the same as that for " "string literals, except that a ``b`` prefix is added:" msgstr "" -#: ../../library/stdtypes.rst:2493 +#: ../../library/stdtypes.rst:2496 msgid "Single quotes: ``b'still allows embedded \"double\" quotes'``" msgstr "" -#: ../../library/stdtypes.rst:2494 +#: ../../library/stdtypes.rst:2497 msgid "Double quotes: ``b\"still allows embedded 'single' quotes\"``" msgstr "" -#: ../../library/stdtypes.rst:2495 +#: ../../library/stdtypes.rst:2498 msgid "" "Triple quoted: ``b'''3 single quotes'''``, ``b\"\"\"3 double quotes\"\"\"``" msgstr "" -#: ../../library/stdtypes.rst:2497 +#: ../../library/stdtypes.rst:2500 msgid "" "Only ASCII characters are permitted in bytes literals (regardless of the " "declared source code encoding). Any binary values over 127 must be entered " "into bytes literals using the appropriate escape sequence." msgstr "" -#: ../../library/stdtypes.rst:2501 +#: ../../library/stdtypes.rst:2504 msgid "" "As with string literals, bytes literals may also use a ``r`` prefix to " "disable processing of escape sequences. See :ref:`strings` for more about " "the various forms of bytes literal, including supported escape sequences." msgstr "" -#: ../../library/stdtypes.rst:2505 +#: ../../library/stdtypes.rst:2508 msgid "" "While bytes literals and representations are based on ASCII text, bytes " "objects actually behave like immutable sequences of integers, with each " @@ -3191,29 +3198,29 @@ msgid "" "compatible will usually lead to data corruption)." msgstr "" -#: ../../library/stdtypes.rst:2515 +#: ../../library/stdtypes.rst:2518 msgid "" "In addition to the literal forms, bytes objects can be created in a number " "of other ways:" msgstr "" -#: ../../library/stdtypes.rst:2518 +#: ../../library/stdtypes.rst:2521 msgid "A zero-filled bytes object of a specified length: ``bytes(10)``" msgstr "" -#: ../../library/stdtypes.rst:2519 +#: ../../library/stdtypes.rst:2522 msgid "From an iterable of integers: ``bytes(range(20))``" msgstr "" -#: ../../library/stdtypes.rst:2520 +#: ../../library/stdtypes.rst:2523 msgid "Copying existing binary data via the buffer protocol: ``bytes(obj)``" msgstr "" -#: ../../library/stdtypes.rst:2522 +#: ../../library/stdtypes.rst:2525 msgid "Also see the :ref:`bytes ` built-in." msgstr "" -#: ../../library/stdtypes.rst:2524 +#: ../../library/stdtypes.rst:2527 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -3221,32 +3228,32 @@ msgid "" "that format:" msgstr "" -#: ../../library/stdtypes.rst:2530 +#: ../../library/stdtypes.rst:2533 msgid "" "This :class:`bytes` class method returns a bytes object, decoding the given " "string object. The string must contain two hexadecimal digits per byte, " "with ASCII whitespace being ignored." msgstr "" -#: ../../library/stdtypes.rst:2537 +#: ../../library/stdtypes.rst:2540 msgid "" ":meth:`bytes.fromhex` now skips all ASCII whitespace in the string, not just " "spaces." msgstr "" -#: ../../library/stdtypes.rst:2541 +#: ../../library/stdtypes.rst:2544 msgid "" "A reverse conversion function exists to transform a bytes object into its " "hexadecimal representation." msgstr "" -#: ../../library/stdtypes.rst:2546 ../../library/stdtypes.rst:2631 +#: ../../library/stdtypes.rst:2549 ../../library/stdtypes.rst:2634 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the instance." msgstr "" -#: ../../library/stdtypes.rst:2552 +#: ../../library/stdtypes.rst:2555 msgid "" "If you want to make the hex string easier to read, you can specify a single " "character separator *sep* parameter to include in the output. By default, " @@ -3255,13 +3262,13 @@ msgid "" "the separator position from the right, negative values from the left." msgstr "" -#: ../../library/stdtypes.rst:2569 +#: ../../library/stdtypes.rst:2572 msgid "" ":meth:`bytes.hex` now supports optional *sep* and *bytes_per_sep* parameters " "to insert separators between bytes in the hex output." msgstr "" -#: ../../library/stdtypes.rst:2573 +#: ../../library/stdtypes.rst:2576 msgid "" "Since bytes objects are sequences of integers (akin to a tuple), for a bytes " "object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be a bytes " @@ -3269,58 +3276,58 @@ msgid "" "and slicing will produce a string of length 1)" msgstr "" -#: ../../library/stdtypes.rst:2578 +#: ../../library/stdtypes.rst:2581 msgid "" "The representation of bytes objects uses the literal format (``b'...'``) " "since it is often more useful than e.g. ``bytes([46, 46, 46])``. You can " "always convert a bytes object into a list of integers using ``list(b)``." msgstr "" -#: ../../library/stdtypes.rst:2586 +#: ../../library/stdtypes.rst:2589 msgid "Bytearray Objects" msgstr "" -#: ../../library/stdtypes.rst:2590 +#: ../../library/stdtypes.rst:2593 msgid "" ":class:`bytearray` objects are a mutable counterpart to :class:`bytes` " "objects." msgstr "" -#: ../../library/stdtypes.rst:2595 +#: ../../library/stdtypes.rst:2598 msgid "" "There is no dedicated literal syntax for bytearray objects, instead they are " "always created by calling the constructor:" msgstr "" -#: ../../library/stdtypes.rst:2598 +#: ../../library/stdtypes.rst:2601 msgid "Creating an empty instance: ``bytearray()``" msgstr "" -#: ../../library/stdtypes.rst:2599 +#: ../../library/stdtypes.rst:2602 msgid "Creating a zero-filled instance with a given length: ``bytearray(10)``" msgstr "" -#: ../../library/stdtypes.rst:2600 +#: ../../library/stdtypes.rst:2603 msgid "From an iterable of integers: ``bytearray(range(20))``" msgstr "" -#: ../../library/stdtypes.rst:2601 +#: ../../library/stdtypes.rst:2604 msgid "" "Copying existing binary data via the buffer protocol: ``bytearray(b'Hi!')``" msgstr "" -#: ../../library/stdtypes.rst:2603 +#: ../../library/stdtypes.rst:2606 msgid "" "As bytearray objects are mutable, they support the :ref:`mutable ` sequence operations in addition to the common bytes and bytearray " "operations described in :ref:`bytes-methods`." msgstr "" -#: ../../library/stdtypes.rst:2607 +#: ../../library/stdtypes.rst:2610 msgid "Also see the :ref:`bytearray ` built-in." msgstr "" -#: ../../library/stdtypes.rst:2609 +#: ../../library/stdtypes.rst:2612 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -3328,33 +3335,33 @@ msgid "" "in that format:" msgstr "" -#: ../../library/stdtypes.rst:2615 +#: ../../library/stdtypes.rst:2618 msgid "" "This :class:`bytearray` class method returns bytearray object, decoding the " "given string object. The string must contain two hexadecimal digits per " "byte, with ASCII whitespace being ignored." msgstr "" -#: ../../library/stdtypes.rst:2622 +#: ../../library/stdtypes.rst:2625 msgid "" ":meth:`bytearray.fromhex` now skips all ASCII whitespace in the string, not " "just spaces." msgstr "" -#: ../../library/stdtypes.rst:2626 +#: ../../library/stdtypes.rst:2629 msgid "" "A reverse conversion function exists to transform a bytearray object into " "its hexadecimal representation." msgstr "" -#: ../../library/stdtypes.rst:2639 +#: ../../library/stdtypes.rst:2642 msgid "" "Similar to :meth:`bytes.hex`, :meth:`bytearray.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../library/stdtypes.rst:2644 +#: ../../library/stdtypes.rst:2647 msgid "" "Since bytearray objects are sequences of integers (akin to a list), for a " "bytearray object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be " @@ -3362,7 +3369,7 @@ msgid "" "both indexing and slicing will produce a string of length 1)" msgstr "" -#: ../../library/stdtypes.rst:2649 +#: ../../library/stdtypes.rst:2652 msgid "" "The representation of bytearray objects uses the bytes literal format " "(``bytearray(b'...')``) since it is often more useful than e.g. " @@ -3370,11 +3377,11 @@ msgid "" "a list of integers using ``list(b)``." msgstr "" -#: ../../library/stdtypes.rst:2658 +#: ../../library/stdtypes.rst:2661 msgid "Bytes and Bytearray Operations" msgstr "" -#: ../../library/stdtypes.rst:2663 +#: ../../library/stdtypes.rst:2666 msgid "" "Both bytes and bytearray objects support the :ref:`common ` " "sequence operations. They interoperate not just with operands of the same " @@ -3383,132 +3390,129 @@ msgid "" "return type of the result may depend on the order of operands." msgstr "" -#: ../../library/stdtypes.rst:2671 +#: ../../library/stdtypes.rst:2674 msgid "" "The methods on bytes and bytearray objects don't accept strings as their " "arguments, just as the methods on strings don't accept bytes as their " "arguments. For example, you have to write::" msgstr "" -#: ../../library/stdtypes.rst:2678 +#: ../../library/stdtypes.rst:2681 msgid "and::" msgstr "" "和:\n" "\n" "::" -#: ../../library/stdtypes.rst:2683 +#: ../../library/stdtypes.rst:2686 msgid "" "Some bytes and bytearray operations assume the use of ASCII compatible " "binary formats, and hence should be avoided when working with arbitrary " "binary data. These restrictions are covered below." msgstr "" -#: ../../library/stdtypes.rst:2688 +#: ../../library/stdtypes.rst:2691 msgid "" "Using these ASCII based operations to manipulate binary data that is not " "stored in an ASCII based format may lead to data corruption." msgstr "" -#: ../../library/stdtypes.rst:2691 +#: ../../library/stdtypes.rst:2694 msgid "" "The following methods on bytes and bytearray objects can be used with " "arbitrary binary data." msgstr "" -#: ../../library/stdtypes.rst:2697 +#: ../../library/stdtypes.rst:2700 msgid "" "Return the number of non-overlapping occurrences of subsequence *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../library/stdtypes.rst:2701 ../../library/stdtypes.rst:2803 -#: ../../library/stdtypes.rst:2825 ../../library/stdtypes.rst:2891 -#: ../../library/stdtypes.rst:2904 +#: ../../library/stdtypes.rst:2704 ../../library/stdtypes.rst:2809 +#: ../../library/stdtypes.rst:2831 ../../library/stdtypes.rst:2897 +#: ../../library/stdtypes.rst:2910 msgid "" "The subsequence to search for may be any :term:`bytes-like object` or an " "integer in the range 0 to 255." msgstr "" -#: ../../library/stdtypes.rst:2704 +#: ../../library/stdtypes.rst:2707 msgid "" "If *sub* is empty, returns the number of empty slices between characters " "which is the length of the bytes object plus one." msgstr "" -#: ../../library/stdtypes.rst:2707 ../../library/stdtypes.rst:2815 -#: ../../library/stdtypes.rst:2828 ../../library/stdtypes.rst:2894 -#: ../../library/stdtypes.rst:2907 +#: ../../library/stdtypes.rst:2710 ../../library/stdtypes.rst:2821 +#: ../../library/stdtypes.rst:2834 ../../library/stdtypes.rst:2900 +#: ../../library/stdtypes.rst:2913 msgid "Also accept an integer in the range 0 to 255 as the subsequence." msgstr "" -#: ../../library/stdtypes.rst:2714 +#: ../../library/stdtypes.rst:2717 msgid "" "If the binary data starts with the *prefix* string, return " "``bytes[len(prefix):]``. Otherwise, return a copy of the original binary " "data::" msgstr "" -#: ../../library/stdtypes.rst:2723 +#: ../../library/stdtypes.rst:2726 msgid "The *prefix* may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:2727 ../../library/stdtypes.rst:2749 -#: ../../library/stdtypes.rst:2879 ../../library/stdtypes.rst:2972 -#: ../../library/stdtypes.rst:2986 ../../library/stdtypes.rst:3017 -#: ../../library/stdtypes.rst:3031 ../../library/stdtypes.rst:3073 -#: ../../library/stdtypes.rst:3143 ../../library/stdtypes.rst:3161 -#: ../../library/stdtypes.rst:3189 ../../library/stdtypes.rst:3328 -#: ../../library/stdtypes.rst:3383 ../../library/stdtypes.rst:3426 -#: ../../library/stdtypes.rst:3447 ../../library/stdtypes.rst:3469 -#: ../../library/stdtypes.rst:3671 +#: ../../library/stdtypes.rst:2730 ../../library/stdtypes.rst:2752 +#: ../../library/stdtypes.rst:2885 ../../library/stdtypes.rst:2978 +#: ../../library/stdtypes.rst:2992 ../../library/stdtypes.rst:3023 +#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:3079 +#: ../../library/stdtypes.rst:3149 ../../library/stdtypes.rst:3167 +#: ../../library/stdtypes.rst:3195 ../../library/stdtypes.rst:3334 +#: ../../library/stdtypes.rst:3389 ../../library/stdtypes.rst:3432 +#: ../../library/stdtypes.rst:3453 ../../library/stdtypes.rst:3475 +#: ../../library/stdtypes.rst:3677 msgid "" "The bytearray version of this method does *not* operate in place - it always " "produces a new object, even if no changes were made." msgstr "" -#: ../../library/stdtypes.rst:2736 +#: ../../library/stdtypes.rst:2739 msgid "" "If the binary data ends with the *suffix* string and that *suffix* is not " "empty, return ``bytes[:-len(suffix)]``. Otherwise, return a copy of the " "original binary data::" msgstr "" -#: ../../library/stdtypes.rst:2745 +#: ../../library/stdtypes.rst:2748 msgid "The *suffix* may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:2758 -msgid "" -"Return a string decoded from the given bytes. Default encoding is " -"``'utf-8'``. *errors* may be given to set a different error handling " -"scheme. The default for *errors* is ``'strict'``, meaning that encoding " -"errors raise a :exc:`UnicodeError`. Other possible values are ``'ignore'``, " -"``'replace'`` and any other name registered via :func:`codecs." -"register_error`, see section :ref:`error-handlers`. For a list of possible " -"encodings, see section :ref:`standard-encodings`." +#: ../../library/stdtypes.rst:2761 +msgid "Return the bytes decoded to a :class:`str`." msgstr "" #: ../../library/stdtypes.rst:2766 msgid "" -"By default, the *errors* argument is not checked for best performances, but " -"only used at the first decoding error. Enable the :ref:`Python Development " -"Mode `, or use a :ref:`debug build ` to check *errors*." +"*errors* controls how decoding errors are handled. If ``'strict'`` (the " +"default), a :exc:`UnicodeError` exception is raised. Other possible values " +"are ``'ignore'``, ``'replace'``, and any other name registered via :func:" +"`codecs.register_error`. See :ref:`error-handlers` for details." msgstr "" #: ../../library/stdtypes.rst:2772 msgid "" -"Passing the *encoding* argument to :class:`str` allows decoding any :term:" -"`bytes-like object` directly, without needing to make a temporary bytes or " -"bytearray object." +"For performance reasons, the value of *errors* is not checked for validity " +"unless a decoding error actually occurs, :ref:`devmode` is enabled or a :ref:" +"`debug build ` is used." msgstr "" -#: ../../library/stdtypes.rst:2776 -msgid "Added support for keyword arguments." -msgstr "新增關鍵字引數的支援。" +#: ../../library/stdtypes.rst:2778 +msgid "" +"Passing the *encoding* argument to :class:`str` allows decoding any :term:" +"`bytes-like object` directly, without needing to make a temporary :class:`!" +"bytes` or :class:`!bytearray` object." +msgstr "" -#: ../../library/stdtypes.rst:2787 +#: ../../library/stdtypes.rst:2793 msgid "" "Return ``True`` if the binary data ends with the specified *suffix*, " "otherwise return ``False``. *suffix* can also be a tuple of suffixes to " @@ -3516,11 +3520,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:2792 +#: ../../library/stdtypes.rst:2798 msgid "The suffix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:2798 +#: ../../library/stdtypes.rst:2804 msgid "" "Return the lowest index in the data where the subsequence *sub* is found, " "such that *sub* is contained in the slice ``s[start:end]``. Optional " @@ -3528,20 +3532,20 @@ msgid "" "``-1`` if *sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:2808 +#: ../../library/stdtypes.rst:2814 msgid "" "The :meth:`~bytes.find` method should be used only if you need to know the " "position of *sub*. To check if *sub* is a substring or not, use the :" "keyword:`in` operator::" msgstr "" -#: ../../library/stdtypes.rst:2822 +#: ../../library/stdtypes.rst:2828 msgid "" "Like :meth:`~bytes.find`, but raise :exc:`ValueError` when the subsequence " "is not found." msgstr "" -#: ../../library/stdtypes.rst:2835 +#: ../../library/stdtypes.rst:2841 msgid "" "Return a bytes or bytearray object which is the concatenation of the binary " "data sequences in *iterable*. A :exc:`TypeError` will be raised if there " @@ -3551,7 +3555,7 @@ msgid "" "method." msgstr "" -#: ../../library/stdtypes.rst:2846 +#: ../../library/stdtypes.rst:2852 msgid "" "This static method returns a translation table usable for :meth:`bytes." "translate` that will map each character in *from* into the character at the " @@ -3559,7 +3563,7 @@ msgid "" "objects ` and have the same length." msgstr "" -#: ../../library/stdtypes.rst:2857 +#: ../../library/stdtypes.rst:2863 msgid "" "Split the sequence at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -3568,24 +3572,24 @@ msgid "" "by two empty bytes or bytearray objects." msgstr "" -#: ../../library/stdtypes.rst:2864 ../../library/stdtypes.rst:2921 +#: ../../library/stdtypes.rst:2870 ../../library/stdtypes.rst:2927 msgid "The separator to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:2870 +#: ../../library/stdtypes.rst:2876 msgid "" "Return a copy of the sequence with all occurrences of subsequence *old* " "replaced by *new*. If the optional argument *count* is given, only the " "first *count* occurrences are replaced." msgstr "" -#: ../../library/stdtypes.rst:2874 +#: ../../library/stdtypes.rst:2880 msgid "" "The subsequence to search for and its replacement may be any :term:`bytes-" "like object`." msgstr "" -#: ../../library/stdtypes.rst:2886 +#: ../../library/stdtypes.rst:2892 msgid "" "Return the highest index in the sequence where the subsequence *sub* is " "found, such that *sub* is contained within ``s[start:end]``. Optional " @@ -3593,13 +3597,13 @@ msgid "" "``-1`` on failure." msgstr "" -#: ../../library/stdtypes.rst:2901 +#: ../../library/stdtypes.rst:2907 msgid "" "Like :meth:`~bytes.rfind` but raises :exc:`ValueError` when the subsequence " "*sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:2914 +#: ../../library/stdtypes.rst:2920 msgid "" "Split the sequence at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -3608,7 +3612,7 @@ msgid "" "followed by a copy of the original sequence." msgstr "" -#: ../../library/stdtypes.rst:2927 +#: ../../library/stdtypes.rst:2933 msgid "" "Return ``True`` if the binary data starts with the specified *prefix*, " "otherwise return ``False``. *prefix* can also be a tuple of prefixes to " @@ -3616,11 +3620,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:2932 +#: ../../library/stdtypes.rst:2938 msgid "The prefix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:2938 +#: ../../library/stdtypes.rst:2944 msgid "" "Return a copy of the bytes or bytearray object where all bytes occurring in " "the optional argument *delete* are removed, and the remaining bytes have " @@ -3628,22 +3632,22 @@ msgid "" "object of length 256." msgstr "" -#: ../../library/stdtypes.rst:2943 +#: ../../library/stdtypes.rst:2949 msgid "" "You can use the :func:`bytes.maketrans` method to create a translation table." msgstr "" -#: ../../library/stdtypes.rst:2946 +#: ../../library/stdtypes.rst:2952 msgid "" "Set the *table* argument to ``None`` for translations that only delete " "characters::" msgstr "" -#: ../../library/stdtypes.rst:2952 +#: ../../library/stdtypes.rst:2958 msgid "*delete* is now supported as a keyword argument." msgstr "" -#: ../../library/stdtypes.rst:2956 +#: ../../library/stdtypes.rst:2962 msgid "" "The following methods on bytes and bytearray objects have default behaviours " "that assume the use of ASCII compatible binary formats, but can still be " @@ -3652,7 +3656,7 @@ msgid "" "instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:2965 +#: ../../library/stdtypes.rst:2971 msgid "" "Return a copy of the object centered in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -3660,7 +3664,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2979 +#: ../../library/stdtypes.rst:2985 msgid "" "Return a copy of the object left justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -3668,7 +3672,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2993 +#: ../../library/stdtypes.rst:2999 msgid "" "Return a copy of the sequence with specified leading bytes removed. The " "*chars* argument is a binary sequence specifying the set of byte values to " @@ -3678,14 +3682,14 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3005 +#: ../../library/stdtypes.rst:3011 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removeprefix` for a method that will remove a " "single prefix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3024 +#: ../../library/stdtypes.rst:3030 msgid "" "Return a copy of the object right justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -3693,7 +3697,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3038 +#: ../../library/stdtypes.rst:3044 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are " @@ -3703,7 +3707,7 @@ msgid "" "described in detail below." msgstr "" -#: ../../library/stdtypes.rst:3049 +#: ../../library/stdtypes.rst:3055 msgid "" "Return a copy of the sequence with specified trailing bytes removed. The " "*chars* argument is a binary sequence specifying the set of byte values to " @@ -3713,14 +3717,14 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3061 +#: ../../library/stdtypes.rst:3067 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removesuffix` for a method that will remove a " "single suffix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3080 +#: ../../library/stdtypes.rst:3086 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given and non-negative, at most " @@ -3729,7 +3733,7 @@ msgid "" "limit on the number of splits (all possible splits are made)." msgstr "" -#: ../../library/stdtypes.rst:3086 +#: ../../library/stdtypes.rst:3092 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty subsequences (for example, ``b'1,,2'.split(b',')`` " @@ -3740,7 +3744,7 @@ msgid "" "object being split. The *sep* argument may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3104 +#: ../../library/stdtypes.rst:3110 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive ASCII whitespace are regarded as a single " @@ -3750,7 +3754,7 @@ msgid "" "without a specified separator returns ``[]``." msgstr "" -#: ../../library/stdtypes.rst:3125 +#: ../../library/stdtypes.rst:3131 msgid "" "Return a copy of the sequence with specified leading and trailing bytes " "removed. The *chars* argument is a binary sequence specifying the set of " @@ -3760,13 +3764,13 @@ msgid "" "a prefix or suffix; rather, all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3138 +#: ../../library/stdtypes.rst:3144 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`." msgstr "" -#: ../../library/stdtypes.rst:3147 +#: ../../library/stdtypes.rst:3153 msgid "" "The following methods on bytes and bytearray objects assume the use of ASCII " "compatible binary formats and should not be applied to arbitrary binary " @@ -3774,14 +3778,14 @@ msgid "" "operate in place, and instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:3155 +#: ../../library/stdtypes.rst:3161 msgid "" "Return a copy of the sequence with each byte interpreted as an ASCII " "character, and the first byte capitalized and the rest lowercased. Non-ASCII " "byte values are passed through unchanged." msgstr "" -#: ../../library/stdtypes.rst:3168 +#: ../../library/stdtypes.rst:3174 msgid "" "Return a copy of the sequence where all ASCII tab characters are replaced by " "one or more ASCII spaces, depending on the current column and the given tab " @@ -3797,7 +3801,7 @@ msgid "" "by one regardless of how the byte value is represented when printed::" msgstr "" -#: ../../library/stdtypes.rst:3196 +#: ../../library/stdtypes.rst:3202 msgid "" "Return ``True`` if all bytes in the sequence are alphabetical ASCII " "characters or ASCII decimal digits and the sequence is not empty, ``False`` " @@ -3806,7 +3810,7 @@ msgid "" "digits are those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:3213 +#: ../../library/stdtypes.rst:3219 msgid "" "Return ``True`` if all bytes in the sequence are alphabetic ASCII characters " "and the sequence is not empty, ``False`` otherwise. Alphabetic ASCII " @@ -3814,35 +3818,35 @@ msgid "" "``b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:3229 +#: ../../library/stdtypes.rst:3235 msgid "" "Return ``True`` if the sequence is empty or all bytes in the sequence are " "ASCII, ``False`` otherwise. ASCII bytes are in the range 0-0x7F." msgstr "" -#: ../../library/stdtypes.rst:3239 +#: ../../library/stdtypes.rst:3245 msgid "" "Return ``True`` if all bytes in the sequence are ASCII decimal digits and " "the sequence is not empty, ``False`` otherwise. ASCII decimal digits are " "those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:3254 +#: ../../library/stdtypes.rst:3260 msgid "" "Return ``True`` if there is at least one lowercase ASCII character in the " "sequence and no uppercase ASCII characters, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:3264 ../../library/stdtypes.rst:3306 -#: ../../library/stdtypes.rst:3322 ../../library/stdtypes.rst:3372 -#: ../../library/stdtypes.rst:3441 +#: ../../library/stdtypes.rst:3270 ../../library/stdtypes.rst:3312 +#: ../../library/stdtypes.rst:3328 ../../library/stdtypes.rst:3378 +#: ../../library/stdtypes.rst:3447 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " "values in the sequence ``b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:3272 +#: ../../library/stdtypes.rst:3278 msgid "" "Return ``True`` if all bytes in the sequence are ASCII whitespace and the " "sequence is not empty, ``False`` otherwise. ASCII whitespace characters are " @@ -3850,27 +3854,27 @@ msgid "" "newline, carriage return, vertical tab, form feed)." msgstr "" -#: ../../library/stdtypes.rst:3281 +#: ../../library/stdtypes.rst:3287 msgid "" "Return ``True`` if the sequence is ASCII titlecase and the sequence is not " "empty, ``False`` otherwise. See :meth:`bytes.title` for more details on the " "definition of \"titlecase\"." msgstr "" -#: ../../library/stdtypes.rst:3296 +#: ../../library/stdtypes.rst:3302 msgid "" "Return ``True`` if there is at least one uppercase alphabetic ASCII " "character in the sequence and no lowercase ASCII characters, ``False`` " "otherwise." msgstr "" -#: ../../library/stdtypes.rst:3314 +#: ../../library/stdtypes.rst:3320 msgid "" "Return a copy of the sequence with all the uppercase ASCII characters " "converted to their corresponding lowercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:3339 +#: ../../library/stdtypes.rst:3345 msgid "" "Return a list of the lines in the binary sequence, breaking at ASCII line " "boundaries. This method uses the :term:`universal newlines` approach to " @@ -3878,20 +3882,20 @@ msgid "" "*keepends* is given and true." msgstr "" -#: ../../library/stdtypes.rst:3351 +#: ../../library/stdtypes.rst:3357 msgid "" "Unlike :meth:`~bytes.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../library/stdtypes.rst:3364 +#: ../../library/stdtypes.rst:3370 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart and vice-versa." msgstr "" -#: ../../library/stdtypes.rst:3376 +#: ../../library/stdtypes.rst:3382 msgid "" "Unlike :func:`str.swapcase()`, it is always the case that ``bin.swapcase()." "swapcase() == bin`` for the binary versions. Case conversions are " @@ -3899,14 +3903,14 @@ msgid "" "Unicode code points." msgstr "" -#: ../../library/stdtypes.rst:3390 +#: ../../library/stdtypes.rst:3396 msgid "" "Return a titlecased version of the binary sequence where words start with an " "uppercase ASCII character and the remaining characters are lowercase. " "Uncased byte values are left unmodified." msgstr "" -#: ../../library/stdtypes.rst:3399 +#: ../../library/stdtypes.rst:3405 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " @@ -3914,18 +3918,18 @@ msgid "" "values are uncased." msgstr "" -#: ../../library/stdtypes.rst:3412 +#: ../../library/stdtypes.rst:3418 msgid "" "A workaround for apostrophes can be constructed using regular expressions::" msgstr "" -#: ../../library/stdtypes.rst:3433 +#: ../../library/stdtypes.rst:3439 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:3454 +#: ../../library/stdtypes.rst:3460 msgid "" "Return a copy of the sequence left filled with ASCII ``b'0'`` digits to make " "a sequence of length *width*. A leading sign prefix (``b'+'``/ ``b'-'``) is " @@ -3934,11 +3938,11 @@ msgid "" "*width* is less than or equal to ``len(seq)``." msgstr "" -#: ../../library/stdtypes.rst:3476 +#: ../../library/stdtypes.rst:3482 msgid "``printf``-style Bytes Formatting" msgstr "" -#: ../../library/stdtypes.rst:3493 +#: ../../library/stdtypes.rst:3499 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " @@ -3946,7 +3950,7 @@ msgid "" "dictionary, wrap it in a tuple." msgstr "" -#: ../../library/stdtypes.rst:3498 +#: ../../library/stdtypes.rst:3504 msgid "" "Bytes objects (``bytes``/``bytearray``) have one unique built-in operation: " "the ``%`` operator (modulo). This is also known as the bytes *formatting* or " @@ -3956,7 +3960,7 @@ msgid "" "func:`sprintf` in the C language." msgstr "" -#: ../../library/stdtypes.rst:3505 +#: ../../library/stdtypes.rst:3511 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -3964,7 +3968,7 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:3539 +#: ../../library/stdtypes.rst:3545 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the bytes object *must* include a parenthesised mapping key into " @@ -3972,73 +3976,73 @@ msgid "" "mapping key selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:3613 +#: ../../library/stdtypes.rst:3619 msgid "Single byte (accepts integer or single byte objects)." msgstr "" -#: ../../library/stdtypes.rst:3616 +#: ../../library/stdtypes.rst:3622 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/stdtypes.rst:3616 +#: ../../library/stdtypes.rst:3622 msgid "" "Bytes (any object that follows the :ref:`buffer protocol ` or " "has :meth:`__bytes__`)." msgstr "" -#: ../../library/stdtypes.rst:3620 +#: ../../library/stdtypes.rst:3626 msgid "" "``'s'`` is an alias for ``'b'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:3623 +#: ../../library/stdtypes.rst:3629 msgid "" "Bytes (converts any Python object using ``repr(obj).encode('ascii', " "'backslashreplace')``)." msgstr "" -#: ../../library/stdtypes.rst:3626 +#: ../../library/stdtypes.rst:3632 msgid "" "``'r'`` is an alias for ``'a'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:3626 +#: ../../library/stdtypes.rst:3632 msgid "\\(7)" msgstr "\\(7)" -#: ../../library/stdtypes.rst:3661 +#: ../../library/stdtypes.rst:3667 msgid "``b'%s'`` is deprecated, but will not be removed during the 3.x series." msgstr "" -#: ../../library/stdtypes.rst:3664 +#: ../../library/stdtypes.rst:3670 msgid "``b'%r'`` is deprecated, but will not be removed during the 3.x series." msgstr "" -#: ../../library/stdtypes.rst:3676 +#: ../../library/stdtypes.rst:3682 msgid ":pep:`461` - Adding % formatting to bytes and bytearray" msgstr "" -#: ../../library/stdtypes.rst:3683 +#: ../../library/stdtypes.rst:3689 msgid "Memory Views" msgstr "" -#: ../../library/stdtypes.rst:3685 +#: ../../library/stdtypes.rst:3691 msgid "" ":class:`memoryview` objects allow Python code to access the internal data of " "an object that supports the :ref:`buffer protocol ` without " "copying." msgstr "" -#: ../../library/stdtypes.rst:3691 +#: ../../library/stdtypes.rst:3697 msgid "" "Create a :class:`memoryview` that references *object*. *object* must " "support the buffer protocol. Built-in objects that support the buffer " "protocol include :class:`bytes` and :class:`bytearray`." msgstr "" -#: ../../library/stdtypes.rst:3695 +#: ../../library/stdtypes.rst:3701 msgid "" "A :class:`memoryview` has the notion of an *element*, which is the atomic " "memory unit handled by the originating *object*. For many simple types such " @@ -4046,7 +4050,7 @@ msgid "" "other types such as :class:`array.array` may have bigger elements." msgstr "" -#: ../../library/stdtypes.rst:3700 +#: ../../library/stdtypes.rst:3706 msgid "" "``len(view)`` is equal to the length of :class:`~memoryview.tolist`. If " "``view.ndim = 0``, the length is 1. If ``view.ndim = 1``, the length is " @@ -4056,13 +4060,13 @@ msgid "" "bytes in a single element." msgstr "" -#: ../../library/stdtypes.rst:3707 +#: ../../library/stdtypes.rst:3713 msgid "" "A :class:`memoryview` supports slicing and indexing to expose its data. One-" "dimensional slicing will result in a subview::" msgstr "" -#: ../../library/stdtypes.rst:3720 +#: ../../library/stdtypes.rst:3726 msgid "" "If :class:`~memoryview.format` is one of the native format specifiers from " "the :mod:`struct` module, indexing with an integer or a tuple of integers is " @@ -4073,82 +4077,82 @@ msgid "" "memoryviews can be indexed with the empty tuple." msgstr "" -#: ../../library/stdtypes.rst:3729 +#: ../../library/stdtypes.rst:3735 msgid "Here is an example with a non-byte format::" msgstr "" -#: ../../library/stdtypes.rst:3741 +#: ../../library/stdtypes.rst:3747 msgid "" "If the underlying object is writable, the memoryview supports one-" "dimensional slice assignment. Resizing is not allowed::" msgstr "" -#: ../../library/stdtypes.rst:3762 +#: ../../library/stdtypes.rst:3768 msgid "" "One-dimensional memoryviews of hashable (read-only) types with formats 'B', " "'b' or 'c' are also hashable. The hash is defined as ``hash(m) == hash(m." "tobytes())``::" msgstr "" -#: ../../library/stdtypes.rst:3774 +#: ../../library/stdtypes.rst:3780 msgid "" "One-dimensional memoryviews can now be sliced. One-dimensional memoryviews " "with formats 'B', 'b' or 'c' are now hashable." msgstr "" -#: ../../library/stdtypes.rst:3778 +#: ../../library/stdtypes.rst:3784 msgid "" "memoryview is now registered automatically with :class:`collections.abc." "Sequence`" msgstr "" -#: ../../library/stdtypes.rst:3782 +#: ../../library/stdtypes.rst:3788 msgid "memoryviews can now be indexed with tuple of integers." msgstr "" -#: ../../library/stdtypes.rst:3785 +#: ../../library/stdtypes.rst:3791 msgid ":class:`memoryview` has several methods:" msgstr "" -#: ../../library/stdtypes.rst:3789 +#: ../../library/stdtypes.rst:3795 msgid "" "A memoryview and a :pep:`3118` exporter are equal if their shapes are " "equivalent and if all corresponding values are equal when the operands' " "respective format codes are interpreted using :mod:`struct` syntax." msgstr "" -#: ../../library/stdtypes.rst:3793 +#: ../../library/stdtypes.rst:3799 msgid "" "For the subset of :mod:`struct` format strings currently supported by :meth:" "`tolist`, ``v`` and ``w`` are equal if ``v.tolist() == w.tolist()``::" msgstr "" -#: ../../library/stdtypes.rst:3812 +#: ../../library/stdtypes.rst:3818 msgid "" "If either format string is not supported by the :mod:`struct` module, then " "the objects will always compare as unequal (even if the format strings and " "buffer contents are identical)::" msgstr "" -#: ../../library/stdtypes.rst:3828 +#: ../../library/stdtypes.rst:3834 msgid "" "Note that, as with floating point numbers, ``v is w`` does *not* imply ``v " "== w`` for memoryview objects." msgstr "" -#: ../../library/stdtypes.rst:3831 +#: ../../library/stdtypes.rst:3837 msgid "" "Previous versions compared the raw memory disregarding the item format and " "the logical array structure." msgstr "" -#: ../../library/stdtypes.rst:3837 +#: ../../library/stdtypes.rst:3843 msgid "" "Return the data in the buffer as a bytestring. This is equivalent to " "calling the :class:`bytes` constructor on the memoryview. ::" msgstr "" -#: ../../library/stdtypes.rst:3846 +#: ../../library/stdtypes.rst:3852 msgid "" "For non-contiguous arrays the result is equal to the flattened list " "representation with all elements converted to bytes. :meth:`tobytes` " @@ -4156,7 +4160,7 @@ msgid "" "module syntax." msgstr "" -#: ../../library/stdtypes.rst:3851 +#: ../../library/stdtypes.rst:3857 msgid "" "*order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data of the " "original array is converted to C or Fortran order. For contiguous views, 'A' " @@ -4165,36 +4169,36 @@ msgid "" "to C first. *order=None* is the same as *order='C'*." msgstr "" -#: ../../library/stdtypes.rst:3860 +#: ../../library/stdtypes.rst:3866 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the buffer. ::" msgstr "" -#: ../../library/stdtypes.rst:3869 +#: ../../library/stdtypes.rst:3875 msgid "" "Similar to :meth:`bytes.hex`, :meth:`memoryview.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../library/stdtypes.rst:3876 +#: ../../library/stdtypes.rst:3882 msgid "Return the data in the buffer as a list of elements. ::" msgstr "" -#: ../../library/stdtypes.rst:3886 +#: ../../library/stdtypes.rst:3892 msgid "" ":meth:`tolist` now supports all single character native formats in :mod:" "`struct` module syntax as well as multi-dimensional representations." msgstr "" -#: ../../library/stdtypes.rst:3893 +#: ../../library/stdtypes.rst:3899 msgid "" "Return a readonly version of the memoryview object. The original memoryview " "object is unchanged. ::" msgstr "" -#: ../../library/stdtypes.rst:3912 +#: ../../library/stdtypes.rst:3918 msgid "" "Release the underlying buffer exposed by the memoryview object. Many " "objects take special actions when a view is held on them (for example, a :" @@ -4203,20 +4207,20 @@ msgid "" "resources) as soon as possible." msgstr "" -#: ../../library/stdtypes.rst:3918 +#: ../../library/stdtypes.rst:3924 msgid "" "After this method has been called, any further operation on the view raises " "a :class:`ValueError` (except :meth:`release()` itself which can be called " "multiple times)::" msgstr "" -#: ../../library/stdtypes.rst:3929 +#: ../../library/stdtypes.rst:3935 msgid "" "The context management protocol can be used for a similar effect, using the " "``with`` statement::" msgstr "" -#: ../../library/stdtypes.rst:3945 +#: ../../library/stdtypes.rst:3951 msgid "" "Cast a memoryview to a new format or shape. *shape* defaults to " "``[byte_length//new_itemsize]``, which means that the result view will be " @@ -4225,57 +4229,57 @@ msgid "" "contiguous -> 1D." msgstr "" -#: ../../library/stdtypes.rst:3951 +#: ../../library/stdtypes.rst:3957 msgid "" "The destination format is restricted to a single element native format in :" "mod:`struct` syntax. One of the formats must be a byte format ('B', 'b' or " "'c'). The byte length of the result must be the same as the original length." msgstr "" -#: ../../library/stdtypes.rst:3956 +#: ../../library/stdtypes.rst:3962 msgid "Cast 1D/long to 1D/unsigned bytes::" msgstr "" -#: ../../library/stdtypes.rst:3979 +#: ../../library/stdtypes.rst:3985 msgid "Cast 1D/unsigned bytes to 1D/char::" msgstr "" -#: ../../library/stdtypes.rst:3992 +#: ../../library/stdtypes.rst:3998 msgid "Cast 1D/bytes to 3D/ints to 1D/signed char::" msgstr "" -#: ../../library/stdtypes.rst:4018 +#: ../../library/stdtypes.rst:4024 msgid "Cast 1D/unsigned long to 2D/unsigned long::" msgstr "" -#: ../../library/stdtypes.rst:4032 +#: ../../library/stdtypes.rst:4038 msgid "The source format is no longer restricted when casting to a byte view." msgstr "" -#: ../../library/stdtypes.rst:4035 +#: ../../library/stdtypes.rst:4041 msgid "There are also several readonly attributes available:" msgstr "" -#: ../../library/stdtypes.rst:4039 +#: ../../library/stdtypes.rst:4045 msgid "The underlying object of the memoryview::" msgstr "" -#: ../../library/stdtypes.rst:4050 +#: ../../library/stdtypes.rst:4056 msgid "" "``nbytes == product(shape) * itemsize == len(m.tobytes())``. This is the " "amount of space in bytes that the array would use in a contiguous " "representation. It is not necessarily equal to ``len(m)``::" msgstr "" -#: ../../library/stdtypes.rst:4069 +#: ../../library/stdtypes.rst:4075 msgid "Multi-dimensional arrays::" msgstr "" -#: ../../library/stdtypes.rst:4086 +#: ../../library/stdtypes.rst:4092 msgid "A bool indicating whether the memory is read only." msgstr "" -#: ../../library/stdtypes.rst:4090 +#: ../../library/stdtypes.rst:4096 msgid "" "A string containing the format (in :mod:`struct` module style) for each " "element in the view. A memoryview can be created from exporters with " @@ -4283,59 +4287,59 @@ msgid "" "restricted to native single element formats." msgstr "" -#: ../../library/stdtypes.rst:4095 +#: ../../library/stdtypes.rst:4101 msgid "" "format ``'B'`` is now handled according to the struct module syntax. This " "means that ``memoryview(b'abc')[0] == b'abc'[0] == 97``." msgstr "" -#: ../../library/stdtypes.rst:4101 +#: ../../library/stdtypes.rst:4107 msgid "The size in bytes of each element of the memoryview::" msgstr "" -#: ../../library/stdtypes.rst:4114 +#: ../../library/stdtypes.rst:4120 msgid "" "An integer indicating how many dimensions of a multi-dimensional array the " "memory represents." msgstr "" -#: ../../library/stdtypes.rst:4119 +#: ../../library/stdtypes.rst:4125 msgid "" "A tuple of integers the length of :attr:`ndim` giving the shape of the " "memory as an N-dimensional array." msgstr "" -#: ../../library/stdtypes.rst:4122 ../../library/stdtypes.rst:4130 +#: ../../library/stdtypes.rst:4128 ../../library/stdtypes.rst:4136 msgid "An empty tuple instead of ``None`` when ndim = 0." msgstr "" -#: ../../library/stdtypes.rst:4127 +#: ../../library/stdtypes.rst:4133 msgid "" "A tuple of integers the length of :attr:`ndim` giving the size in bytes to " "access each element for each dimension of the array." msgstr "" -#: ../../library/stdtypes.rst:4135 +#: ../../library/stdtypes.rst:4141 msgid "Used internally for PIL-style arrays. The value is informational only." msgstr "" -#: ../../library/stdtypes.rst:4139 +#: ../../library/stdtypes.rst:4145 msgid "A bool indicating whether the memory is C-:term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4145 +#: ../../library/stdtypes.rst:4151 msgid "A bool indicating whether the memory is Fortran :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4151 +#: ../../library/stdtypes.rst:4157 msgid "A bool indicating whether the memory is :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4159 +#: ../../library/stdtypes.rst:4165 msgid "Set Types --- :class:`set`, :class:`frozenset`" msgstr "" -#: ../../library/stdtypes.rst:4163 +#: ../../library/stdtypes.rst:4169 msgid "" "A :dfn:`set` object is an unordered collection of distinct :term:`hashable` " "objects. Common uses include membership testing, removing duplicates from a " @@ -4345,7 +4349,7 @@ msgid "" "`collections` module.)" msgstr "" -#: ../../library/stdtypes.rst:4170 +#: ../../library/stdtypes.rst:4176 msgid "" "Like other collections, sets support ``x in set``, ``len(set)``, and ``for x " "in set``. Being an unordered collection, sets do not record element " @@ -4353,7 +4357,7 @@ msgid "" "slicing, or other sequence-like behavior." msgstr "" -#: ../../library/stdtypes.rst:4175 +#: ../../library/stdtypes.rst:4181 msgid "" "There are currently two built-in set types, :class:`set` and :class:" "`frozenset`. The :class:`set` type is mutable --- the contents can be " @@ -4365,18 +4369,18 @@ msgid "" "of another set." msgstr "" -#: ../../library/stdtypes.rst:4183 +#: ../../library/stdtypes.rst:4189 msgid "" "Non-empty sets (not frozensets) can be created by placing a comma-separated " "list of elements within braces, for example: ``{'jack', 'sjoerd'}``, in " "addition to the :class:`set` constructor." msgstr "" -#: ../../library/stdtypes.rst:4187 +#: ../../library/stdtypes.rst:4193 msgid "The constructors for both classes work the same:" msgstr "" -#: ../../library/stdtypes.rst:4192 +#: ../../library/stdtypes.rst:4198 msgid "" "Return a new set or frozenset object whose elements are taken from " "*iterable*. The elements of a set must be :term:`hashable`. To represent " @@ -4384,92 +4388,92 @@ msgid "" "*iterable* is not specified, a new empty set is returned." msgstr "" -#: ../../library/stdtypes.rst:4198 +#: ../../library/stdtypes.rst:4204 msgid "Sets can be created by several means:" msgstr "" -#: ../../library/stdtypes.rst:4200 +#: ../../library/stdtypes.rst:4206 msgid "" "Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:4201 +#: ../../library/stdtypes.rst:4207 msgid "" "Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}``" msgstr "" -#: ../../library/stdtypes.rst:4202 +#: ../../library/stdtypes.rst:4208 msgid "" "Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', " "'foo'])``" msgstr "" -#: ../../library/stdtypes.rst:4204 +#: ../../library/stdtypes.rst:4210 msgid "" "Instances of :class:`set` and :class:`frozenset` provide the following " "operations:" msgstr "" -#: ../../library/stdtypes.rst:4209 +#: ../../library/stdtypes.rst:4215 msgid "Return the number of elements in set *s* (cardinality of *s*)." msgstr "" -#: ../../library/stdtypes.rst:4213 +#: ../../library/stdtypes.rst:4219 msgid "Test *x* for membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:4217 +#: ../../library/stdtypes.rst:4223 msgid "Test *x* for non-membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:4221 +#: ../../library/stdtypes.rst:4227 msgid "" "Return ``True`` if the set has no elements in common with *other*. Sets are " "disjoint if and only if their intersection is the empty set." msgstr "" -#: ../../library/stdtypes.rst:4227 +#: ../../library/stdtypes.rst:4233 msgid "Test whether every element in the set is in *other*." msgstr "" -#: ../../library/stdtypes.rst:4231 +#: ../../library/stdtypes.rst:4237 msgid "" "Test whether the set is a proper subset of *other*, that is, ``set <= other " "and set != other``." msgstr "" -#: ../../library/stdtypes.rst:4237 +#: ../../library/stdtypes.rst:4243 msgid "Test whether every element in *other* is in the set." msgstr "" -#: ../../library/stdtypes.rst:4241 +#: ../../library/stdtypes.rst:4247 msgid "" "Test whether the set is a proper superset of *other*, that is, ``set >= " "other and set != other``." msgstr "" -#: ../../library/stdtypes.rst:4247 +#: ../../library/stdtypes.rst:4253 msgid "Return a new set with elements from the set and all others." msgstr "" -#: ../../library/stdtypes.rst:4252 +#: ../../library/stdtypes.rst:4258 msgid "Return a new set with elements common to the set and all others." msgstr "" -#: ../../library/stdtypes.rst:4257 +#: ../../library/stdtypes.rst:4263 msgid "Return a new set with elements in the set that are not in the others." msgstr "" -#: ../../library/stdtypes.rst:4262 +#: ../../library/stdtypes.rst:4268 msgid "" "Return a new set with elements in either the set or *other* but not both." msgstr "" -#: ../../library/stdtypes.rst:4266 +#: ../../library/stdtypes.rst:4272 msgid "Return a shallow copy of the set." msgstr "" -#: ../../library/stdtypes.rst:4269 +#: ../../library/stdtypes.rst:4275 msgid "" "Note, the non-operator versions of :meth:`union`, :meth:`intersection`, :" "meth:`difference`, :meth:`symmetric_difference`, :meth:`issubset`, and :meth:" @@ -4479,7 +4483,7 @@ msgid "" "the more readable ``set('abc').intersection('cbs')``." msgstr "" -#: ../../library/stdtypes.rst:4276 +#: ../../library/stdtypes.rst:4282 msgid "" "Both :class:`set` and :class:`frozenset` support set to set comparisons. Two " "sets are equal if and only if every element of each set is contained in the " @@ -4489,14 +4493,14 @@ msgid "" "set is a proper superset of the second set (is a superset, but is not equal)." msgstr "" -#: ../../library/stdtypes.rst:4283 +#: ../../library/stdtypes.rst:4289 msgid "" "Instances of :class:`set` are compared to instances of :class:`frozenset` " "based on their members. For example, ``set('abc') == frozenset('abc')`` " "returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``." msgstr "" -#: ../../library/stdtypes.rst:4287 +#: ../../library/stdtypes.rst:4293 msgid "" "The subset and equality comparisons do not generalize to a total ordering " "function. For example, any two nonempty disjoint sets are not equal and are " @@ -4504,71 +4508,71 @@ msgid "" "``ab``." msgstr "" -#: ../../library/stdtypes.rst:4292 +#: ../../library/stdtypes.rst:4298 msgid "" "Since sets only define partial ordering (subset relationships), the output " "of the :meth:`list.sort` method is undefined for lists of sets." msgstr "" -#: ../../library/stdtypes.rst:4295 +#: ../../library/stdtypes.rst:4301 msgid "Set elements, like dictionary keys, must be :term:`hashable`." msgstr "" -#: ../../library/stdtypes.rst:4297 +#: ../../library/stdtypes.rst:4303 msgid "" "Binary operations that mix :class:`set` instances with :class:`frozenset` " "return the type of the first operand. For example: ``frozenset('ab') | " "set('bc')`` returns an instance of :class:`frozenset`." msgstr "" -#: ../../library/stdtypes.rst:4301 +#: ../../library/stdtypes.rst:4307 msgid "" "The following table lists operations available for :class:`set` that do not " "apply to immutable instances of :class:`frozenset`:" msgstr "" -#: ../../library/stdtypes.rst:4307 +#: ../../library/stdtypes.rst:4313 msgid "Update the set, adding elements from all others." msgstr "" -#: ../../library/stdtypes.rst:4312 +#: ../../library/stdtypes.rst:4318 msgid "Update the set, keeping only elements found in it and all others." msgstr "" -#: ../../library/stdtypes.rst:4317 +#: ../../library/stdtypes.rst:4323 msgid "Update the set, removing elements found in others." msgstr "" -#: ../../library/stdtypes.rst:4322 +#: ../../library/stdtypes.rst:4328 msgid "" "Update the set, keeping only elements found in either set, but not in both." msgstr "" -#: ../../library/stdtypes.rst:4326 +#: ../../library/stdtypes.rst:4332 msgid "Add element *elem* to the set." msgstr "" -#: ../../library/stdtypes.rst:4330 +#: ../../library/stdtypes.rst:4336 msgid "" "Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is not " "contained in the set." msgstr "" -#: ../../library/stdtypes.rst:4335 +#: ../../library/stdtypes.rst:4341 msgid "Remove element *elem* from the set if it is present." msgstr "" -#: ../../library/stdtypes.rst:4339 +#: ../../library/stdtypes.rst:4345 msgid "" "Remove and return an arbitrary element from the set. Raises :exc:`KeyError` " "if the set is empty." msgstr "" -#: ../../library/stdtypes.rst:4344 +#: ../../library/stdtypes.rst:4350 msgid "Remove all elements from the set." msgstr "" -#: ../../library/stdtypes.rst:4347 +#: ../../library/stdtypes.rst:4353 msgid "" "Note, the non-operator versions of the :meth:`update`, :meth:" "`intersection_update`, :meth:`difference_update`, and :meth:" @@ -4576,18 +4580,18 @@ msgid "" "argument." msgstr "" -#: ../../library/stdtypes.rst:4352 +#: ../../library/stdtypes.rst:4358 msgid "" "Note, the *elem* argument to the :meth:`__contains__`, :meth:`remove`, and :" "meth:`discard` methods may be a set. To support searching for an equivalent " "frozenset, a temporary one is created from *elem*." msgstr "" -#: ../../library/stdtypes.rst:4360 +#: ../../library/stdtypes.rst:4366 msgid "Mapping Types --- :class:`dict`" msgstr "" -#: ../../library/stdtypes.rst:4370 +#: ../../library/stdtypes.rst:4376 msgid "" "A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. " "Mappings are mutable objects. There is currently only one standard mapping " @@ -4596,7 +4600,7 @@ msgid "" "module.)" msgstr "" -#: ../../library/stdtypes.rst:4376 +#: ../../library/stdtypes.rst:4382 msgid "" "A dictionary's keys are *almost* arbitrary values. Values that are not :" "term:`hashable`, that is, values containing lists, dictionaries or other " @@ -4605,33 +4609,33 @@ msgid "" "and ``True``) can be used interchangeably to index the same dictionary entry." msgstr "" -#: ../../library/stdtypes.rst:4387 +#: ../../library/stdtypes.rst:4393 msgid "" "Return a new dictionary initialized from an optional positional argument and " "a possibly empty set of keyword arguments." msgstr "" -#: ../../library/stdtypes.rst:4390 +#: ../../library/stdtypes.rst:4396 msgid "Dictionaries can be created by several means:" msgstr "" -#: ../../library/stdtypes.rst:4392 +#: ../../library/stdtypes.rst:4398 msgid "" "Use a comma-separated list of ``key: value`` pairs within braces: ``{'jack': " "4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:4394 +#: ../../library/stdtypes.rst:4400 msgid "Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``" msgstr "" -#: ../../library/stdtypes.rst:4395 +#: ../../library/stdtypes.rst:4401 msgid "" "Use the type constructor: ``dict()``, ``dict([('foo', 100), ('bar', " "200)])``, ``dict(foo=100, bar=200)``" msgstr "" -#: ../../library/stdtypes.rst:4398 +#: ../../library/stdtypes.rst:4404 msgid "" "If no positional argument is given, an empty dictionary is created. If a " "positional argument is given and it is a mapping object, a dictionary is " @@ -4643,7 +4647,7 @@ msgid "" "value for that key becomes the corresponding value in the new dictionary." msgstr "" -#: ../../library/stdtypes.rst:4408 +#: ../../library/stdtypes.rst:4414 msgid "" "If keyword arguments are given, the keyword arguments and their values are " "added to the dictionary created from the positional argument. If a key " @@ -4651,39 +4655,39 @@ msgid "" "the value from the positional argument." msgstr "" -#: ../../library/stdtypes.rst:4413 +#: ../../library/stdtypes.rst:4419 msgid "" "To illustrate, the following examples all return a dictionary equal to " "``{\"one\": 1, \"two\": 2, \"three\": 3}``::" msgstr "" -#: ../../library/stdtypes.rst:4425 +#: ../../library/stdtypes.rst:4431 msgid "" "Providing keyword arguments as in the first example only works for keys that " "are valid Python identifiers. Otherwise, any valid keys can be used." msgstr "" -#: ../../library/stdtypes.rst:4429 +#: ../../library/stdtypes.rst:4435 msgid "" "These are the operations that dictionaries support (and therefore, custom " "mapping types should support too):" msgstr "" -#: ../../library/stdtypes.rst:4434 +#: ../../library/stdtypes.rst:4440 msgid "Return a list of all the keys used in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:4438 +#: ../../library/stdtypes.rst:4444 msgid "Return the number of items in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:4442 +#: ../../library/stdtypes.rst:4448 msgid "" "Return the item of *d* with key *key*. Raises a :exc:`KeyError` if *key* is " "not in the map." msgstr "" -#: ../../library/stdtypes.rst:4447 +#: ../../library/stdtypes.rst:4453 msgid "" "If a subclass of dict defines a method :meth:`__missing__` and *key* is not " "present, the ``d[key]`` operation calls that method with the key *key* as " @@ -4694,51 +4698,51 @@ msgid "" "an instance variable::" msgstr "" -#: ../../library/stdtypes.rst:4465 +#: ../../library/stdtypes.rst:4471 msgid "" "The example above shows part of the implementation of :class:`collections." "Counter`. A different ``__missing__`` method is used by :class:`collections." "defaultdict`." msgstr "" -#: ../../library/stdtypes.rst:4471 +#: ../../library/stdtypes.rst:4477 msgid "Set ``d[key]`` to *value*." msgstr "" -#: ../../library/stdtypes.rst:4475 +#: ../../library/stdtypes.rst:4481 msgid "" "Remove ``d[key]`` from *d*. Raises a :exc:`KeyError` if *key* is not in the " "map." msgstr "" -#: ../../library/stdtypes.rst:4480 +#: ../../library/stdtypes.rst:4486 msgid "Return ``True`` if *d* has a key *key*, else ``False``." msgstr "" -#: ../../library/stdtypes.rst:4484 +#: ../../library/stdtypes.rst:4490 msgid "Equivalent to ``not key in d``." msgstr "" -#: ../../library/stdtypes.rst:4488 +#: ../../library/stdtypes.rst:4494 msgid "" "Return an iterator over the keys of the dictionary. This is a shortcut for " "``iter(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:4493 +#: ../../library/stdtypes.rst:4499 msgid "Remove all items from the dictionary." msgstr "" -#: ../../library/stdtypes.rst:4497 +#: ../../library/stdtypes.rst:4503 msgid "Return a shallow copy of the dictionary." msgstr "" -#: ../../library/stdtypes.rst:4501 +#: ../../library/stdtypes.rst:4507 msgid "" "Create a new dictionary with keys from *iterable* and values set to *value*." msgstr "" -#: ../../library/stdtypes.rst:4503 +#: ../../library/stdtypes.rst:4509 msgid "" ":meth:`fromkeys` is a class method that returns a new dictionary. *value* " "defaults to ``None``. All of the values refer to just a single instance, so " @@ -4747,70 +4751,70 @@ msgid "" "` instead." msgstr "" -#: ../../library/stdtypes.rst:4511 +#: ../../library/stdtypes.rst:4517 msgid "" "Return the value for *key* if *key* is in the dictionary, else *default*. If " "*default* is not given, it defaults to ``None``, so that this method never " "raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:4517 +#: ../../library/stdtypes.rst:4523 msgid "" "Return a new view of the dictionary's items (``(key, value)`` pairs). See " "the :ref:`documentation of view objects `." msgstr "" -#: ../../library/stdtypes.rst:4522 +#: ../../library/stdtypes.rst:4528 msgid "" "Return a new view of the dictionary's keys. See the :ref:`documentation of " "view objects `." msgstr "" -#: ../../library/stdtypes.rst:4527 +#: ../../library/stdtypes.rst:4533 msgid "" "If *key* is in the dictionary, remove it and return its value, else return " "*default*. If *default* is not given and *key* is not in the dictionary, a :" "exc:`KeyError` is raised." msgstr "" -#: ../../library/stdtypes.rst:4533 +#: ../../library/stdtypes.rst:4539 msgid "" "Remove and return a ``(key, value)`` pair from the dictionary. Pairs are " "returned in :abbr:`LIFO (last-in, first-out)` order." msgstr "" -#: ../../library/stdtypes.rst:4536 +#: ../../library/stdtypes.rst:4542 msgid "" ":meth:`popitem` is useful to destructively iterate over a dictionary, as " "often used in set algorithms. If the dictionary is empty, calling :meth:" "`popitem` raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:4540 +#: ../../library/stdtypes.rst:4546 msgid "" "LIFO order is now guaranteed. In prior versions, :meth:`popitem` would " "return an arbitrary key/value pair." msgstr "" -#: ../../library/stdtypes.rst:4546 +#: ../../library/stdtypes.rst:4552 msgid "" "Return a reverse iterator over the keys of the dictionary. This is a " "shortcut for ``reversed(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:4553 +#: ../../library/stdtypes.rst:4559 msgid "" "If *key* is in the dictionary, return its value. If not, insert *key* with " "a value of *default* and return *default*. *default* defaults to ``None``." msgstr "" -#: ../../library/stdtypes.rst:4559 +#: ../../library/stdtypes.rst:4565 msgid "" "Update the dictionary with the key/value pairs from *other*, overwriting " "existing keys. Return ``None``." msgstr "" -#: ../../library/stdtypes.rst:4562 +#: ../../library/stdtypes.rst:4568 msgid "" ":meth:`update` accepts either another dictionary object or an iterable of " "key/value pairs (as tuples or other iterables of length two). If keyword " @@ -4818,71 +4822,71 @@ msgid "" "pairs: ``d.update(red=1, blue=2)``." msgstr "" -#: ../../library/stdtypes.rst:4569 +#: ../../library/stdtypes.rst:4575 msgid "" "Return a new view of the dictionary's values. See the :ref:`documentation " "of view objects `." msgstr "" -#: ../../library/stdtypes.rst:4572 +#: ../../library/stdtypes.rst:4578 msgid "" "An equality comparison between one ``dict.values()`` view and another will " "always return ``False``. This also applies when comparing ``dict.values()`` " "to itself::" msgstr "" -#: ../../library/stdtypes.rst:4582 +#: ../../library/stdtypes.rst:4588 msgid "" "Create a new dictionary with the merged keys and values of *d* and *other*, " "which must both be dictionaries. The values of *other* take priority when " "*d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:4590 +#: ../../library/stdtypes.rst:4596 msgid "" "Update the dictionary *d* with keys and values from *other*, which may be " "either a :term:`mapping` or an :term:`iterable` of key/value pairs. The " "values of *other* take priority when *d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:4596 +#: ../../library/stdtypes.rst:4602 msgid "" "Dictionaries compare equal if and only if they have the same ``(key, " "value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', " "'>') raise :exc:`TypeError`." msgstr "" -#: ../../library/stdtypes.rst:4600 +#: ../../library/stdtypes.rst:4606 msgid "" "Dictionaries preserve insertion order. Note that updating a key does not " "affect the order. Keys added after deletion are inserted at the end. ::" msgstr "" -#: ../../library/stdtypes.rst:4618 +#: ../../library/stdtypes.rst:4624 msgid "" "Dictionary order is guaranteed to be insertion order. This behavior was an " "implementation detail of CPython from 3.6." msgstr "" -#: ../../library/stdtypes.rst:4622 +#: ../../library/stdtypes.rst:4628 msgid "Dictionaries and dictionary views are reversible. ::" msgstr "" -#: ../../library/stdtypes.rst:4634 +#: ../../library/stdtypes.rst:4640 msgid "Dictionaries are now reversible." msgstr "" -#: ../../library/stdtypes.rst:4639 +#: ../../library/stdtypes.rst:4645 msgid "" ":class:`types.MappingProxyType` can be used to create a read-only view of a :" "class:`dict`." msgstr "" -#: ../../library/stdtypes.rst:4646 +#: ../../library/stdtypes.rst:4652 msgid "Dictionary view objects" msgstr "字典視圖物件" -#: ../../library/stdtypes.rst:4648 +#: ../../library/stdtypes.rst:4654 msgid "" "The objects returned by :meth:`dict.keys`, :meth:`dict.values` and :meth:" "`dict.items` are *view objects*. They provide a dynamic view on the " @@ -4890,23 +4894,23 @@ msgid "" "reflects these changes." msgstr "" -#: ../../library/stdtypes.rst:4653 +#: ../../library/stdtypes.rst:4659 msgid "" "Dictionary views can be iterated over to yield their respective data, and " "support membership tests:" msgstr "" -#: ../../library/stdtypes.rst:4658 +#: ../../library/stdtypes.rst:4664 msgid "Return the number of entries in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:4662 +#: ../../library/stdtypes.rst:4668 msgid "" "Return an iterator over the keys, values or items (represented as tuples of " "``(key, value)``) in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:4665 +#: ../../library/stdtypes.rst:4671 msgid "" "Keys and values are iterated over in insertion order. This allows the " "creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = zip(d." @@ -4914,39 +4918,39 @@ msgid "" "[(v, k) for (k, v) in d.items()]``." msgstr "" -#: ../../library/stdtypes.rst:4670 +#: ../../library/stdtypes.rst:4676 msgid "" "Iterating views while adding or deleting entries in the dictionary may raise " "a :exc:`RuntimeError` or fail to iterate over all entries." msgstr "" -#: ../../library/stdtypes.rst:4673 +#: ../../library/stdtypes.rst:4679 msgid "Dictionary order is guaranteed to be insertion order." msgstr "" -#: ../../library/stdtypes.rst:4678 +#: ../../library/stdtypes.rst:4684 msgid "" "Return ``True`` if *x* is in the underlying dictionary's keys, values or " "items (in the latter case, *x* should be a ``(key, value)`` tuple)." msgstr "" -#: ../../library/stdtypes.rst:4683 +#: ../../library/stdtypes.rst:4689 msgid "" "Return a reverse iterator over the keys, values or items of the dictionary. " "The view will be iterated in reverse order of the insertion." msgstr "" -#: ../../library/stdtypes.rst:4686 +#: ../../library/stdtypes.rst:4692 msgid "Dictionary views are now reversible." msgstr "" -#: ../../library/stdtypes.rst:4691 +#: ../../library/stdtypes.rst:4697 msgid "" "Return a :class:`types.MappingProxyType` that wraps the original dictionary " "to which the view refers." msgstr "" -#: ../../library/stdtypes.rst:4696 +#: ../../library/stdtypes.rst:4702 msgid "" "Keys views are set-like since their entries are unique and hashable. If all " "values are hashable, so that ``(key, value)`` pairs are unique and hashable, " @@ -4956,15 +4960,15 @@ msgid "" "abc.Set` are available (for example, ``==``, ``<``, or ``^``)." msgstr "" -#: ../../library/stdtypes.rst:4703 +#: ../../library/stdtypes.rst:4709 msgid "An example of dictionary view usage::" msgstr "" -#: ../../library/stdtypes.rst:4744 +#: ../../library/stdtypes.rst:4750 msgid "Context Manager Types" msgstr "" -#: ../../library/stdtypes.rst:4751 +#: ../../library/stdtypes.rst:4757 msgid "" "Python's :keyword:`with` statement supports the concept of a runtime context " "defined by a context manager. This is implemented using a pair of methods " @@ -4972,7 +4976,7 @@ msgid "" "before the statement body is executed and exited when the statement ends:" msgstr "" -#: ../../library/stdtypes.rst:4759 +#: ../../library/stdtypes.rst:4765 msgid "" "Enter the runtime context and return either this object or another object " "related to the runtime context. The value returned by this method is bound " @@ -4980,14 +4984,14 @@ msgid "" "using this context manager." msgstr "" -#: ../../library/stdtypes.rst:4764 +#: ../../library/stdtypes.rst:4770 msgid "" "An example of a context manager that returns itself is a :term:`file " "object`. File objects return themselves from __enter__() to allow :func:" "`open` to be used as the context expression in a :keyword:`with` statement." msgstr "" -#: ../../library/stdtypes.rst:4768 +#: ../../library/stdtypes.rst:4774 msgid "" "An example of a context manager that returns a related object is the one " "returned by :func:`decimal.localcontext`. These managers set the active " @@ -4997,7 +5001,7 @@ msgid "" "the :keyword:`!with` statement." msgstr "" -#: ../../library/stdtypes.rst:4778 +#: ../../library/stdtypes.rst:4784 msgid "" "Exit the runtime context and return a Boolean flag indicating if any " "exception that occurred should be suppressed. If an exception occurred while " @@ -5006,7 +5010,7 @@ msgid "" "arguments are ``None``." msgstr "" -#: ../../library/stdtypes.rst:4783 +#: ../../library/stdtypes.rst:4789 msgid "" "Returning a true value from this method will cause the :keyword:`with` " "statement to suppress the exception and continue execution with the " @@ -5017,7 +5021,7 @@ msgid "" "statement." msgstr "" -#: ../../library/stdtypes.rst:4790 +#: ../../library/stdtypes.rst:4796 msgid "" "The exception passed in should never be reraised explicitly - instead, this " "method should return a false value to indicate that the method completed " @@ -5026,7 +5030,7 @@ msgid "" "method has actually failed." msgstr "" -#: ../../library/stdtypes.rst:4796 +#: ../../library/stdtypes.rst:4802 msgid "" "Python defines several context managers to support easy thread " "synchronisation, prompt closure of files or other objects, and simpler " @@ -5035,7 +5039,7 @@ msgid "" "management protocol. See the :mod:`contextlib` module for some examples." msgstr "" -#: ../../library/stdtypes.rst:4802 +#: ../../library/stdtypes.rst:4808 msgid "" "Python's :term:`generator`\\s and the :class:`contextlib.contextmanager` " "decorator provide a convenient way to implement these protocols. If a " @@ -5045,7 +5049,7 @@ msgid "" "rather than the iterator produced by an undecorated generator function." msgstr "" -#: ../../library/stdtypes.rst:4809 +#: ../../library/stdtypes.rst:4815 msgid "" "Note that there is no specific slot for any of these methods in the type " "structure for Python objects in the Python/C API. Extension types wanting to " @@ -5054,23 +5058,23 @@ msgid "" "a single class dictionary lookup is negligible." msgstr "" -#: ../../library/stdtypes.rst:4817 +#: ../../library/stdtypes.rst:4823 msgid "" "Type Annotation Types --- :ref:`Generic Alias `, :ref:" "`Union `" msgstr "" -#: ../../library/stdtypes.rst:4822 +#: ../../library/stdtypes.rst:4828 msgid "" "The core built-in types for :term:`type annotations ` are :ref:" "`Generic Alias ` and :ref:`Union `." msgstr "" -#: ../../library/stdtypes.rst:4829 +#: ../../library/stdtypes.rst:4835 msgid "Generic Alias Type" msgstr "" -#: ../../library/stdtypes.rst:4835 +#: ../../library/stdtypes.rst:4841 msgid "" "``GenericAlias`` objects are generally created by :ref:`subscripting " "` a class. They are most often used with :ref:`container " @@ -5080,19 +5084,19 @@ msgid "" "are intended primarily for use with :term:`type annotations `." msgstr "" -#: ../../library/stdtypes.rst:4845 +#: ../../library/stdtypes.rst:4851 msgid "" "It is generally only possible to subscript a class if the class implements " "the special method :meth:`~object.__class_getitem__`." msgstr "" -#: ../../library/stdtypes.rst:4848 +#: ../../library/stdtypes.rst:4854 msgid "" "A ``GenericAlias`` object acts as a proxy for a :term:`generic type`, " "implementing *parameterized generics*." msgstr "" -#: ../../library/stdtypes.rst:4851 +#: ../../library/stdtypes.rst:4857 msgid "" "For a container class, the argument(s) supplied to a :ref:`subscription " "` of the class may indicate the type(s) of the elements an " @@ -5101,7 +5105,7 @@ msgid "" "`bytes`." msgstr "" -#: ../../library/stdtypes.rst:4857 +#: ../../library/stdtypes.rst:4863 msgid "" "For a class which defines :meth:`~object.__class_getitem__` but is not a " "container, the argument(s) supplied to a subscription of the class will " @@ -5110,7 +5114,7 @@ msgid "" "the :class:`str` data type and the :class:`bytes` data type:" msgstr "" -#: ../../library/stdtypes.rst:4863 +#: ../../library/stdtypes.rst:4869 msgid "" "If ``x = re.search('foo', 'foo')``, ``x`` will be a :ref:`re.Match ` object where the return values of ``x.group(0)`` and ``x[0]`` will " @@ -5118,7 +5122,7 @@ msgid "" "annotations with the ``GenericAlias`` ``re.Match[str]``." msgstr "" -#: ../../library/stdtypes.rst:4869 +#: ../../library/stdtypes.rst:4875 msgid "" "If ``y = re.search(b'bar', b'bar')``, (note the ``b`` for :class:`bytes`), " "``y`` will also be an instance of ``re.Match``, but the return values of ``y." @@ -5127,21 +5131,21 @@ msgid "" "objects>` objects with ``re.Match[bytes]``." msgstr "" -#: ../../library/stdtypes.rst:4875 +#: ../../library/stdtypes.rst:4881 msgid "" "``GenericAlias`` objects are instances of the class :class:`types." "GenericAlias`, which can also be used to create ``GenericAlias`` objects " "directly." msgstr "" -#: ../../library/stdtypes.rst:4881 +#: ../../library/stdtypes.rst:4887 msgid "" "Creates a ``GenericAlias`` representing a type ``T`` parameterized by types " "*X*, *Y*, and more depending on the ``T`` used. For example, a function " "expecting a :class:`list` containing :class:`float` elements::" msgstr "" -#: ../../library/stdtypes.rst:4889 +#: ../../library/stdtypes.rst:4895 msgid "" "Another example for :term:`mapping` objects, using a :class:`dict`, which is " "a generic type expecting two type parameters representing the key type and " @@ -5149,13 +5153,13 @@ msgid "" "of type :class:`str` and values of type :class:`int`::" msgstr "" -#: ../../library/stdtypes.rst:4897 +#: ../../library/stdtypes.rst:4903 msgid "" "The builtin functions :func:`isinstance` and :func:`issubclass` do not " "accept ``GenericAlias`` types for their second argument::" msgstr "" -#: ../../library/stdtypes.rst:4905 +#: ../../library/stdtypes.rst:4911 msgid "" "The Python runtime does not enforce :term:`type annotations `. " "This extends to generic types and their type parameters. When creating a " @@ -5164,331 +5168,331 @@ msgid "" "discouraged, but will run without errors::" msgstr "" -#: ../../library/stdtypes.rst:4915 +#: ../../library/stdtypes.rst:4921 msgid "" "Furthermore, parameterized generics erase type parameters during object " "creation::" msgstr "" -#: ../../library/stdtypes.rst:4926 +#: ../../library/stdtypes.rst:4932 msgid "" "Calling :func:`repr` or :func:`str` on a generic shows the parameterized " "type::" msgstr "" -#: ../../library/stdtypes.rst:4934 +#: ../../library/stdtypes.rst:4940 msgid "" "The :meth:`~object.__getitem__` method of generic containers will raise an " "exception to disallow mistakes like ``dict[str][str]``::" msgstr "" -#: ../../library/stdtypes.rst:4942 +#: ../../library/stdtypes.rst:4948 msgid "" "However, such expressions are valid when :ref:`type variables ` " "are used. The index must have as many elements as there are type variable " "items in the ``GenericAlias`` object's :attr:`~genericalias.__args__`. ::" msgstr "" -#: ../../library/stdtypes.rst:4953 +#: ../../library/stdtypes.rst:4959 msgid "Standard Generic Classes" msgstr "" -#: ../../library/stdtypes.rst:4955 +#: ../../library/stdtypes.rst:4961 msgid "" "The following standard library classes support parameterized generics. This " "list is non-exhaustive." msgstr "" -#: ../../library/stdtypes.rst:4958 +#: ../../library/stdtypes.rst:4964 msgid ":class:`tuple`" msgstr ":class:`tuple`" -#: ../../library/stdtypes.rst:4959 +#: ../../library/stdtypes.rst:4965 msgid ":class:`list`" msgstr ":class:`list`" -#: ../../library/stdtypes.rst:4960 +#: ../../library/stdtypes.rst:4966 msgid ":class:`dict`" msgstr ":class:`dict`" -#: ../../library/stdtypes.rst:4961 +#: ../../library/stdtypes.rst:4967 msgid ":class:`set`" msgstr ":class:`set`" -#: ../../library/stdtypes.rst:4962 +#: ../../library/stdtypes.rst:4968 msgid ":class:`frozenset`" msgstr ":class:`frozenset`" -#: ../../library/stdtypes.rst:4963 +#: ../../library/stdtypes.rst:4969 msgid ":class:`type`" msgstr ":class:`type`" -#: ../../library/stdtypes.rst:4964 +#: ../../library/stdtypes.rst:4970 msgid ":class:`collections.deque`" msgstr ":class:`collections.deque`" -#: ../../library/stdtypes.rst:4965 +#: ../../library/stdtypes.rst:4971 msgid ":class:`collections.defaultdict`" msgstr ":class:`collections.defaultdict`" -#: ../../library/stdtypes.rst:4966 +#: ../../library/stdtypes.rst:4972 msgid ":class:`collections.OrderedDict`" msgstr ":class:`collections.OrderedDict`" -#: ../../library/stdtypes.rst:4967 +#: ../../library/stdtypes.rst:4973 msgid ":class:`collections.Counter`" msgstr ":class:`collections.Counter`" -#: ../../library/stdtypes.rst:4968 +#: ../../library/stdtypes.rst:4974 msgid ":class:`collections.ChainMap`" msgstr ":class:`collections.ChainMap`" -#: ../../library/stdtypes.rst:4969 +#: ../../library/stdtypes.rst:4975 msgid ":class:`collections.abc.Awaitable`" msgstr ":class:`collections.abc.Awaitable`" -#: ../../library/stdtypes.rst:4970 +#: ../../library/stdtypes.rst:4976 msgid ":class:`collections.abc.Coroutine`" msgstr ":class:`collections.abc.Coroutine`" -#: ../../library/stdtypes.rst:4971 +#: ../../library/stdtypes.rst:4977 msgid ":class:`collections.abc.AsyncIterable`" msgstr ":class:`collections.abc.AsyncIterable`" -#: ../../library/stdtypes.rst:4972 +#: ../../library/stdtypes.rst:4978 msgid ":class:`collections.abc.AsyncIterator`" msgstr ":class:`collections.abc.AsyncIterator`" -#: ../../library/stdtypes.rst:4973 +#: ../../library/stdtypes.rst:4979 msgid ":class:`collections.abc.AsyncGenerator`" msgstr ":class:`collections.abc.AsyncGenerator`" -#: ../../library/stdtypes.rst:4974 +#: ../../library/stdtypes.rst:4980 msgid ":class:`collections.abc.Iterable`" msgstr ":class:`collections.abc.Iterable`" -#: ../../library/stdtypes.rst:4975 +#: ../../library/stdtypes.rst:4981 msgid ":class:`collections.abc.Iterator`" msgstr ":class:`collections.abc.Iterator`" -#: ../../library/stdtypes.rst:4976 +#: ../../library/stdtypes.rst:4982 msgid ":class:`collections.abc.Generator`" msgstr ":class:`collections.abc.Generator`" -#: ../../library/stdtypes.rst:4977 +#: ../../library/stdtypes.rst:4983 msgid ":class:`collections.abc.Reversible`" msgstr ":class:`collections.abc.Reversible`" -#: ../../library/stdtypes.rst:4978 +#: ../../library/stdtypes.rst:4984 msgid ":class:`collections.abc.Container`" msgstr ":class:`collections.abc.Container`" -#: ../../library/stdtypes.rst:4979 +#: ../../library/stdtypes.rst:4985 msgid ":class:`collections.abc.Collection`" msgstr ":class:`collections.abc.Collection`" -#: ../../library/stdtypes.rst:4980 +#: ../../library/stdtypes.rst:4986 msgid ":class:`collections.abc.Callable`" msgstr ":class:`collections.abc.Callable`" -#: ../../library/stdtypes.rst:4981 +#: ../../library/stdtypes.rst:4987 msgid ":class:`collections.abc.Set`" msgstr ":class:`collections.abc.Set`" -#: ../../library/stdtypes.rst:4982 +#: ../../library/stdtypes.rst:4988 msgid ":class:`collections.abc.MutableSet`" msgstr ":class:`collections.abc.MutableSet`" -#: ../../library/stdtypes.rst:4983 +#: ../../library/stdtypes.rst:4989 msgid ":class:`collections.abc.Mapping`" msgstr ":class:`collections.abc.Mapping`" -#: ../../library/stdtypes.rst:4984 +#: ../../library/stdtypes.rst:4990 msgid ":class:`collections.abc.MutableMapping`" msgstr ":class:`collections.abc.MutableMapping`" -#: ../../library/stdtypes.rst:4985 +#: ../../library/stdtypes.rst:4991 msgid ":class:`collections.abc.Sequence`" msgstr ":class:`collections.abc.Sequence`" -#: ../../library/stdtypes.rst:4986 +#: ../../library/stdtypes.rst:4992 msgid ":class:`collections.abc.MutableSequence`" msgstr ":class:`collections.abc.MutableSequence`" -#: ../../library/stdtypes.rst:4987 +#: ../../library/stdtypes.rst:4993 msgid ":class:`collections.abc.ByteString`" msgstr ":class:`collections.abc.ByteString`" -#: ../../library/stdtypes.rst:4988 +#: ../../library/stdtypes.rst:4994 msgid ":class:`collections.abc.MappingView`" msgstr ":class:`collections.abc.MappingView`" -#: ../../library/stdtypes.rst:4989 +#: ../../library/stdtypes.rst:4995 msgid ":class:`collections.abc.KeysView`" msgstr ":class:`collections.abc.KeysView`" -#: ../../library/stdtypes.rst:4990 +#: ../../library/stdtypes.rst:4996 msgid ":class:`collections.abc.ItemsView`" msgstr ":class:`collections.abc.ItemsView`" -#: ../../library/stdtypes.rst:4991 +#: ../../library/stdtypes.rst:4997 msgid ":class:`collections.abc.ValuesView`" msgstr ":class:`collections.abc.ValuesView`" -#: ../../library/stdtypes.rst:4992 +#: ../../library/stdtypes.rst:4998 msgid ":class:`contextlib.AbstractContextManager`" msgstr ":class:`contextlib.AbstractContextManager`" -#: ../../library/stdtypes.rst:4993 +#: ../../library/stdtypes.rst:4999 msgid ":class:`contextlib.AbstractAsyncContextManager`" msgstr ":class:`contextlib.AbstractAsyncContextManager`" -#: ../../library/stdtypes.rst:4994 +#: ../../library/stdtypes.rst:5000 msgid ":class:`dataclasses.Field`" msgstr ":class:`dataclasses.Field`" -#: ../../library/stdtypes.rst:4995 +#: ../../library/stdtypes.rst:5001 msgid ":class:`functools.cached_property`" msgstr ":class:`functools.cached_property`" -#: ../../library/stdtypes.rst:4996 +#: ../../library/stdtypes.rst:5002 msgid ":class:`functools.partialmethod`" msgstr ":class:`functools.partialmethod`" -#: ../../library/stdtypes.rst:4997 +#: ../../library/stdtypes.rst:5003 msgid ":class:`os.PathLike`" msgstr ":class:`os.PathLike`" -#: ../../library/stdtypes.rst:4998 +#: ../../library/stdtypes.rst:5004 msgid ":class:`queue.LifoQueue`" msgstr ":class:`queue.LifoQueue`" -#: ../../library/stdtypes.rst:4999 +#: ../../library/stdtypes.rst:5005 msgid ":class:`queue.Queue`" msgstr ":class:`queue.Queue`" -#: ../../library/stdtypes.rst:5000 +#: ../../library/stdtypes.rst:5006 msgid ":class:`queue.PriorityQueue`" msgstr ":class:`queue.PriorityQueue`" -#: ../../library/stdtypes.rst:5001 +#: ../../library/stdtypes.rst:5007 msgid ":class:`queue.SimpleQueue`" msgstr ":class:`queue.SimpleQueue`" -#: ../../library/stdtypes.rst:5002 +#: ../../library/stdtypes.rst:5008 msgid ":ref:`re.Pattern `" msgstr ":ref:`re.Pattern `" -#: ../../library/stdtypes.rst:5003 +#: ../../library/stdtypes.rst:5009 msgid ":ref:`re.Match `" msgstr ":ref:`re.Match `" -#: ../../library/stdtypes.rst:5004 +#: ../../library/stdtypes.rst:5010 msgid ":class:`shelve.BsdDbShelf`" msgstr ":class:`shelve.BsdDbShelf`" -#: ../../library/stdtypes.rst:5005 +#: ../../library/stdtypes.rst:5011 msgid ":class:`shelve.DbfilenameShelf`" msgstr ":class:`shelve.DbfilenameShelf`" -#: ../../library/stdtypes.rst:5006 +#: ../../library/stdtypes.rst:5012 msgid ":class:`shelve.Shelf`" msgstr ":class:`shelve.Shelf`" -#: ../../library/stdtypes.rst:5007 +#: ../../library/stdtypes.rst:5013 msgid ":class:`types.MappingProxyType`" msgstr ":class:`types.MappingProxyType`" -#: ../../library/stdtypes.rst:5008 +#: ../../library/stdtypes.rst:5014 msgid ":class:`weakref.WeakKeyDictionary`" msgstr ":class:`weakref.WeakKeyDictionary`" -#: ../../library/stdtypes.rst:5009 +#: ../../library/stdtypes.rst:5015 msgid ":class:`weakref.WeakMethod`" msgstr ":class:`weakref.WeakMethod`" -#: ../../library/stdtypes.rst:5010 +#: ../../library/stdtypes.rst:5016 msgid ":class:`weakref.WeakSet`" msgstr ":class:`weakref.WeakSet`" -#: ../../library/stdtypes.rst:5011 +#: ../../library/stdtypes.rst:5017 msgid ":class:`weakref.WeakValueDictionary`" msgstr ":class:`weakref.WeakValueDictionary`" -#: ../../library/stdtypes.rst:5016 +#: ../../library/stdtypes.rst:5022 msgid "Special Attributes of ``GenericAlias`` objects" msgstr "" -#: ../../library/stdtypes.rst:5018 +#: ../../library/stdtypes.rst:5024 msgid "All parameterized generics implement special read-only attributes." msgstr "" -#: ../../library/stdtypes.rst:5022 +#: ../../library/stdtypes.rst:5028 msgid "This attribute points at the non-parameterized generic class::" msgstr "" -#: ../../library/stdtypes.rst:5030 +#: ../../library/stdtypes.rst:5036 msgid "" "This attribute is a :class:`tuple` (possibly of length 1) of generic types " "passed to the original :meth:`~object.__class_getitem__` of the generic " "class::" msgstr "" -#: ../../library/stdtypes.rst:5040 +#: ../../library/stdtypes.rst:5046 msgid "" "This attribute is a lazily computed tuple (possibly empty) of unique type " "variables found in ``__args__``::" msgstr "" -#: ../../library/stdtypes.rst:5051 +#: ../../library/stdtypes.rst:5057 msgid "" "A ``GenericAlias`` object with :class:`typing.ParamSpec` parameters may not " "have correct ``__parameters__`` after substitution because :class:`typing." "ParamSpec` is intended primarily for static type checking." msgstr "" -#: ../../library/stdtypes.rst:5058 +#: ../../library/stdtypes.rst:5064 msgid "" "A boolean that is true if the alias has been unpacked using the ``*`` " "operator (see :data:`~typing.TypeVarTuple`)." msgstr "" -#: ../../library/stdtypes.rst:5067 +#: ../../library/stdtypes.rst:5073 msgid ":pep:`484` - Type Hints" msgstr "" -#: ../../library/stdtypes.rst:5067 +#: ../../library/stdtypes.rst:5073 msgid "Introducing Python's framework for type annotations." msgstr "" -#: ../../library/stdtypes.rst:5072 +#: ../../library/stdtypes.rst:5078 msgid ":pep:`585` - Type Hinting Generics In Standard Collections" msgstr "" -#: ../../library/stdtypes.rst:5070 +#: ../../library/stdtypes.rst:5076 msgid "" "Introducing the ability to natively parameterize standard-library classes, " "provided they implement the special class method :meth:`~object." "__class_getitem__`." msgstr "" -#: ../../library/stdtypes.rst:5075 +#: ../../library/stdtypes.rst:5081 msgid "" ":ref:`Generics`, :ref:`user-defined generics ` and :" "class:`typing.Generic`" msgstr "" -#: ../../library/stdtypes.rst:5075 +#: ../../library/stdtypes.rst:5081 msgid "" "Documentation on how to implement generic classes that can be parameterized " "at runtime and understood by static type-checkers." msgstr "" -#: ../../library/stdtypes.rst:5084 +#: ../../library/stdtypes.rst:5090 msgid "Union Type" msgstr "" -#: ../../library/stdtypes.rst:5090 +#: ../../library/stdtypes.rst:5096 msgid "" "A union object holds the value of the ``|`` (bitwise or) operation on " "multiple :ref:`type objects `. These types are intended " @@ -5497,7 +5501,7 @@ msgid "" "Union`." msgstr "" -#: ../../library/stdtypes.rst:5097 +#: ../../library/stdtypes.rst:5103 msgid "" "Defines a union object which holds types *X*, *Y*, and so forth. ``X | Y`` " "means either X or Y. It is equivalent to ``typing.Union[X, Y]``. For " @@ -5505,76 +5509,76 @@ msgid "" "class:`float`::" msgstr "" -#: ../../library/stdtypes.rst:5107 +#: ../../library/stdtypes.rst:5113 msgid "" "Union objects can be tested for equality with other union objects. Details:" msgstr "" -#: ../../library/stdtypes.rst:5109 +#: ../../library/stdtypes.rst:5115 msgid "Unions of unions are flattened::" msgstr "" -#: ../../library/stdtypes.rst:5113 +#: ../../library/stdtypes.rst:5119 msgid "Redundant types are removed::" msgstr "" -#: ../../library/stdtypes.rst:5117 +#: ../../library/stdtypes.rst:5123 msgid "When comparing unions, the order is ignored::" msgstr "" -#: ../../library/stdtypes.rst:5121 +#: ../../library/stdtypes.rst:5127 msgid "It is compatible with :data:`typing.Union`::" msgstr "" -#: ../../library/stdtypes.rst:5125 +#: ../../library/stdtypes.rst:5131 msgid "Optional types can be spelled as a union with ``None``::" msgstr "" -#: ../../library/stdtypes.rst:5132 +#: ../../library/stdtypes.rst:5138 msgid "" "Calls to :func:`isinstance` and :func:`issubclass` are also supported with a " "union object::" msgstr "" -#: ../../library/stdtypes.rst:5138 +#: ../../library/stdtypes.rst:5144 msgid "" "However, union objects containing :ref:`parameterized generics ` cannot be used::" msgstr "" -#: ../../library/stdtypes.rst:5146 +#: ../../library/stdtypes.rst:5152 msgid "" "The user-exposed type for the union object can be accessed from :data:`types." "UnionType` and used for :func:`isinstance` checks. An object cannot be " "instantiated from the type::" msgstr "" -#: ../../library/stdtypes.rst:5159 +#: ../../library/stdtypes.rst:5165 msgid "" "The :meth:`__or__` method for type objects was added to support the syntax " "``X | Y``. If a metaclass implements :meth:`__or__`, the Union may override " "it::" msgstr "" -#: ../../library/stdtypes.rst:5177 +#: ../../library/stdtypes.rst:5183 msgid ":pep:`604` -- PEP proposing the ``X | Y`` syntax and the Union type." msgstr "" -#: ../../library/stdtypes.rst:5185 +#: ../../library/stdtypes.rst:5191 msgid "Other Built-in Types" msgstr "" -#: ../../library/stdtypes.rst:5187 +#: ../../library/stdtypes.rst:5193 msgid "" "The interpreter supports several other kinds of objects. Most of these " "support only one or two operations." msgstr "" -#: ../../library/stdtypes.rst:5194 +#: ../../library/stdtypes.rst:5200 msgid "Modules" msgstr "模組" -#: ../../library/stdtypes.rst:5196 +#: ../../library/stdtypes.rst:5202 msgid "" "The only special operation on a module is attribute access: ``m.name``, " "where *m* is a module and *name* accesses a name defined in *m*'s symbol " @@ -5585,7 +5589,7 @@ msgid "" "*foo* somewhere.)" msgstr "" -#: ../../library/stdtypes.rst:5203 +#: ../../library/stdtypes.rst:5209 msgid "" "A special attribute of every module is :attr:`~object.__dict__`. This is the " "dictionary containing the module's symbol table. Modifying this dictionary " @@ -5596,32 +5600,32 @@ msgid "" "recommended." msgstr "" -#: ../../library/stdtypes.rst:5211 +#: ../../library/stdtypes.rst:5217 msgid "" "Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ````." msgstr "" -#: ../../library/stdtypes.rst:5219 +#: ../../library/stdtypes.rst:5225 msgid "Classes and Class Instances" msgstr "" -#: ../../library/stdtypes.rst:5221 +#: ../../library/stdtypes.rst:5227 msgid "See :ref:`objects` and :ref:`class` for these." msgstr "" -#: ../../library/stdtypes.rst:5227 +#: ../../library/stdtypes.rst:5233 msgid "Functions" msgstr "函式" -#: ../../library/stdtypes.rst:5229 +#: ../../library/stdtypes.rst:5235 msgid "" "Function objects are created by function definitions. The only operation on " "a function object is to call it: ``func(argument-list)``." msgstr "" -#: ../../library/stdtypes.rst:5232 +#: ../../library/stdtypes.rst:5238 msgid "" "There are really two flavors of function objects: built-in functions and " "user-defined functions. Both support the same operation (to call the " @@ -5629,15 +5633,15 @@ msgid "" "types." msgstr "" -#: ../../library/stdtypes.rst:5236 +#: ../../library/stdtypes.rst:5242 msgid "See :ref:`function` for more information." msgstr "更多資訊請見 :ref:`function`\\ 。" -#: ../../library/stdtypes.rst:5242 +#: ../../library/stdtypes.rst:5248 msgid "Methods" msgstr "" -#: ../../library/stdtypes.rst:5246 +#: ../../library/stdtypes.rst:5252 msgid "" "Methods are functions that are called using the attribute notation. There " "are two flavors: built-in methods (such as :meth:`append` on lists) and " @@ -5645,7 +5649,7 @@ msgid "" "support them." msgstr "" -#: ../../library/stdtypes.rst:5251 +#: ../../library/stdtypes.rst:5257 msgid "" "If you access a method (a function defined in a class namespace) through an " "instance, you get a special object: a :dfn:`bound method` (also called :dfn:" @@ -5657,7 +5661,7 @@ msgid "" "arg-2, ..., arg-n)``." msgstr "" -#: ../../library/stdtypes.rst:5260 +#: ../../library/stdtypes.rst:5266 msgid "" "Like function objects, bound method objects support getting arbitrary " "attributes. However, since method attributes are actually stored on the " @@ -5667,15 +5671,15 @@ msgid "" "attribute, you need to explicitly set it on the underlying function object::" msgstr "" -#: ../../library/stdtypes.rst:5280 ../../library/stdtypes.rst:5311 +#: ../../library/stdtypes.rst:5286 ../../library/stdtypes.rst:5317 msgid "See :ref:`types` for more information." msgstr "更多資訊請見 :ref:`types`\\ 。" -#: ../../library/stdtypes.rst:5288 +#: ../../library/stdtypes.rst:5294 msgid "Code Objects" msgstr "" -#: ../../library/stdtypes.rst:5294 +#: ../../library/stdtypes.rst:5300 msgid "" "Code objects are used by the implementation to represent \"pseudo-compiled\" " "executable Python code such as a function body. They differ from function " @@ -5685,23 +5689,23 @@ msgid "" "`__code__` attribute. See also the :mod:`code` module." msgstr "" -#: ../../library/stdtypes.rst:5301 +#: ../../library/stdtypes.rst:5307 msgid "" "Accessing ``__code__`` raises an :ref:`auditing event ` ``object." "__getattr__`` with arguments ``obj`` and ``\"__code__\"``." msgstr "" -#: ../../library/stdtypes.rst:5308 +#: ../../library/stdtypes.rst:5314 msgid "" "A code object can be executed or evaluated by passing it (instead of a " "source string) to the :func:`exec` or :func:`eval` built-in functions." msgstr "" -#: ../../library/stdtypes.rst:5317 +#: ../../library/stdtypes.rst:5323 msgid "Type Objects" msgstr "" -#: ../../library/stdtypes.rst:5323 +#: ../../library/stdtypes.rst:5329 msgid "" "Type objects represent the various object types. An object's type is " "accessed by the built-in function :func:`type`. There are no special " @@ -5709,30 +5713,30 @@ msgid "" "standard built-in types." msgstr "" -#: ../../library/stdtypes.rst:5328 +#: ../../library/stdtypes.rst:5334 msgid "Types are written like this: ````." msgstr "" -#: ../../library/stdtypes.rst:5334 +#: ../../library/stdtypes.rst:5340 msgid "The Null Object" msgstr "" -#: ../../library/stdtypes.rst:5336 +#: ../../library/stdtypes.rst:5342 msgid "" "This object is returned by functions that don't explicitly return a value. " "It supports no special operations. There is exactly one null object, named " "``None`` (a built-in name). ``type(None)()`` produces the same singleton." msgstr "" -#: ../../library/stdtypes.rst:5340 +#: ../../library/stdtypes.rst:5346 msgid "It is written as ``None``." msgstr "" -#: ../../library/stdtypes.rst:5347 +#: ../../library/stdtypes.rst:5353 msgid "The Ellipsis Object" msgstr "" -#: ../../library/stdtypes.rst:5349 +#: ../../library/stdtypes.rst:5355 msgid "" "This object is commonly used by slicing (see :ref:`slicings`). It supports " "no special operations. There is exactly one ellipsis object, named :const:" @@ -5740,15 +5744,15 @@ msgid "" "`Ellipsis` singleton." msgstr "" -#: ../../library/stdtypes.rst:5354 +#: ../../library/stdtypes.rst:5360 msgid "It is written as ``Ellipsis`` or ``...``." msgstr "" -#: ../../library/stdtypes.rst:5360 +#: ../../library/stdtypes.rst:5366 msgid "The NotImplemented Object" msgstr "" -#: ../../library/stdtypes.rst:5362 +#: ../../library/stdtypes.rst:5368 msgid "" "This object is returned from comparisons and binary operations when they are " "asked to operate on types they don't support. See :ref:`comparisons` for " @@ -5756,15 +5760,15 @@ msgid "" "``type(NotImplemented)()`` produces the singleton instance." msgstr "" -#: ../../library/stdtypes.rst:5367 +#: ../../library/stdtypes.rst:5373 msgid "It is written as ``NotImplemented``." msgstr "" -#: ../../library/stdtypes.rst:5373 +#: ../../library/stdtypes.rst:5379 msgid "Boolean Values" msgstr "" -#: ../../library/stdtypes.rst:5375 +#: ../../library/stdtypes.rst:5381 msgid "" "Boolean values are the two constant objects ``False`` and ``True``. They " "are used to represent truth values (although other values can also be " @@ -5775,81 +5779,81 @@ msgid "" "(see section :ref:`truth` above)." msgstr "" -#: ../../library/stdtypes.rst:5388 +#: ../../library/stdtypes.rst:5394 msgid "They are written as ``False`` and ``True``, respectively." msgstr "" -#: ../../library/stdtypes.rst:5394 +#: ../../library/stdtypes.rst:5400 msgid "Internal Objects" msgstr "" -#: ../../library/stdtypes.rst:5396 +#: ../../library/stdtypes.rst:5402 msgid "" "See :ref:`types` for this information. It describes stack frame objects, " "traceback objects, and slice objects." msgstr "" -#: ../../library/stdtypes.rst:5403 +#: ../../library/stdtypes.rst:5409 msgid "Special Attributes" msgstr "" -#: ../../library/stdtypes.rst:5405 +#: ../../library/stdtypes.rst:5411 msgid "" "The implementation adds a few special read-only attributes to several object " "types, where they are relevant. Some of these are not reported by the :func:" "`dir` built-in function." msgstr "" -#: ../../library/stdtypes.rst:5412 +#: ../../library/stdtypes.rst:5418 msgid "" "A dictionary or other mapping object used to store an object's (writable) " "attributes." msgstr "" -#: ../../library/stdtypes.rst:5418 +#: ../../library/stdtypes.rst:5424 msgid "The class to which a class instance belongs." msgstr "" -#: ../../library/stdtypes.rst:5423 +#: ../../library/stdtypes.rst:5429 msgid "The tuple of base classes of a class object." msgstr "" -#: ../../library/stdtypes.rst:5428 +#: ../../library/stdtypes.rst:5434 msgid "" "The name of the class, function, method, descriptor, or generator instance." msgstr "" -#: ../../library/stdtypes.rst:5434 +#: ../../library/stdtypes.rst:5440 msgid "" "The :term:`qualified name` of the class, function, method, descriptor, or " "generator instance." msgstr "" -#: ../../library/stdtypes.rst:5442 +#: ../../library/stdtypes.rst:5448 msgid "" "This attribute is a tuple of classes that are considered when looking for " "base classes during method resolution." msgstr "" -#: ../../library/stdtypes.rst:5448 +#: ../../library/stdtypes.rst:5454 msgid "" "This method can be overridden by a metaclass to customize the method " "resolution order for its instances. It is called at class instantiation, " "and its result is stored in :attr:`~class.__mro__`." msgstr "" -#: ../../library/stdtypes.rst:5455 +#: ../../library/stdtypes.rst:5461 msgid "" "Each class keeps a list of weak references to its immediate subclasses. " "This method returns a list of all those references still alive. The list is " "in definition order. Example::" msgstr "" -#: ../../library/stdtypes.rst:5466 +#: ../../library/stdtypes.rst:5472 msgid "Integer string conversion length limitation" msgstr "" -#: ../../library/stdtypes.rst:5468 +#: ../../library/stdtypes.rst:5474 msgid "" "CPython has a global limit for converting between :class:`int` and :class:" "`str` to mitigate denial of service attacks. This limit *only* applies to " @@ -5857,7 +5861,7 @@ msgid "" "binary conversions are unlimited. The limit can be configured." msgstr "" -#: ../../library/stdtypes.rst:5473 +#: ../../library/stdtypes.rst:5479 msgid "" "The :class:`int` type in CPython is an abitrary length number stored in " "binary form (commonly known as a \"bignum\"). There exists no algorithm that " @@ -5867,25 +5871,25 @@ msgid "" "value such as ``int('1' * 500_000)`` can take over a second on a fast CPU." msgstr "" -#: ../../library/stdtypes.rst:5480 +#: ../../library/stdtypes.rst:5486 msgid "" "Limiting conversion size offers a practical way to avoid `CVE-2020-10735 " "`_." msgstr "" -#: ../../library/stdtypes.rst:5483 +#: ../../library/stdtypes.rst:5489 msgid "" "The limit is applied to the number of digit characters in the input or " "output string when a non-linear conversion algorithm would be involved. " "Underscores and the sign are not counted towards the limit." msgstr "" -#: ../../library/stdtypes.rst:5487 +#: ../../library/stdtypes.rst:5493 msgid "" "When an operation would exceed the limit, a :exc:`ValueError` is raised:" msgstr "" -#: ../../library/stdtypes.rst:5509 +#: ../../library/stdtypes.rst:5515 msgid "" "The default limit is 4300 digits as provided in :data:`sys.int_info." "default_max_str_digits `. The lowest limit that can be " @@ -5893,94 +5897,94 @@ msgid "" "str_digits_check_threshold `." msgstr "" -#: ../../library/stdtypes.rst:5514 +#: ../../library/stdtypes.rst:5520 msgid "Verification:" msgstr "" -#: ../../library/stdtypes.rst:5529 +#: ../../library/stdtypes.rst:5535 msgid "Affected APIs" msgstr "" -#: ../../library/stdtypes.rst:5531 +#: ../../library/stdtypes.rst:5537 msgid "" "The limitation only applies to potentially slow conversions between :class:" "`int` and :class:`str` or :class:`bytes`:" msgstr "" -#: ../../library/stdtypes.rst:5534 +#: ../../library/stdtypes.rst:5540 msgid "``int(string)`` with default base 10." msgstr "" -#: ../../library/stdtypes.rst:5535 +#: ../../library/stdtypes.rst:5541 msgid "``int(string, base)`` for all bases that are not a power of 2." msgstr "" -#: ../../library/stdtypes.rst:5536 +#: ../../library/stdtypes.rst:5542 msgid "``str(integer)``." msgstr "``str(integer)``。" -#: ../../library/stdtypes.rst:5537 +#: ../../library/stdtypes.rst:5543 msgid "``repr(integer)``" msgstr "``repr(integer)``" -#: ../../library/stdtypes.rst:5538 +#: ../../library/stdtypes.rst:5544 msgid "" -"any other string conversion to base 10, for example ``f\"{integer}\"``, ``" -"\"{}\".format(integer)``, or ``b\"%d\" % integer``." +"any other string conversion to base 10, for example ``f\"{integer}\"``, " +"``\"{}\".format(integer)``, or ``b\"%d\" % integer``." msgstr "" -#: ../../library/stdtypes.rst:5541 +#: ../../library/stdtypes.rst:5547 msgid "The limitations do not apply to functions with a linear algorithm:" msgstr "" -#: ../../library/stdtypes.rst:5543 +#: ../../library/stdtypes.rst:5549 msgid "``int(string, base)`` with base 2, 4, 8, 16, or 32." msgstr "" -#: ../../library/stdtypes.rst:5544 +#: ../../library/stdtypes.rst:5550 msgid ":func:`int.from_bytes` and :func:`int.to_bytes`." msgstr "" -#: ../../library/stdtypes.rst:5545 +#: ../../library/stdtypes.rst:5551 msgid ":func:`hex`, :func:`oct`, :func:`bin`." msgstr "" -#: ../../library/stdtypes.rst:5546 +#: ../../library/stdtypes.rst:5552 msgid ":ref:`formatspec` for hex, octal, and binary numbers." msgstr "" -#: ../../library/stdtypes.rst:5547 +#: ../../library/stdtypes.rst:5553 msgid ":class:`str` to :class:`float`." msgstr "" -#: ../../library/stdtypes.rst:5548 +#: ../../library/stdtypes.rst:5554 msgid ":class:`str` to :class:`decimal.Decimal`." msgstr "" -#: ../../library/stdtypes.rst:5551 +#: ../../library/stdtypes.rst:5557 msgid "Configuring the limit" msgstr "" -#: ../../library/stdtypes.rst:5553 +#: ../../library/stdtypes.rst:5559 msgid "" "Before Python starts up you can use an environment variable or an " "interpreter command line flag to configure the limit:" msgstr "" -#: ../../library/stdtypes.rst:5556 +#: ../../library/stdtypes.rst:5562 msgid "" ":envvar:`PYTHONINTMAXSTRDIGITS`, e.g. ``PYTHONINTMAXSTRDIGITS=640 python3`` " "to set the limit to 640 or ``PYTHONINTMAXSTRDIGITS=0 python3`` to disable " "the limitation." msgstr "" -#: ../../library/stdtypes.rst:5559 +#: ../../library/stdtypes.rst:5565 msgid "" ":option:`-X int_max_str_digits <-X>`, e.g. ``python3 -X " "int_max_str_digits=640``" msgstr "" -#: ../../library/stdtypes.rst:5561 +#: ../../library/stdtypes.rst:5567 msgid "" ":data:`sys.flags.int_max_str_digits` contains the value of :envvar:" "`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`. If both the " @@ -5989,38 +5993,38 @@ msgid "" "int_info.default_max_str_digits` was used during initilization." msgstr "" -#: ../../library/stdtypes.rst:5567 +#: ../../library/stdtypes.rst:5573 msgid "" "From code, you can inspect the current limit and set a new one using these :" "mod:`sys` APIs:" msgstr "" -#: ../../library/stdtypes.rst:5570 +#: ../../library/stdtypes.rst:5576 msgid "" ":func:`sys.get_int_max_str_digits` and :func:`sys.set_int_max_str_digits` " "are a getter and setter for the interpreter-wide limit. Subinterpreters have " "their own limit." msgstr "" -#: ../../library/stdtypes.rst:5574 +#: ../../library/stdtypes.rst:5580 msgid "" "Information about the default and minimum can be found in :attr:`sys." "int_info`:" msgstr "" -#: ../../library/stdtypes.rst:5576 +#: ../../library/stdtypes.rst:5582 msgid "" ":data:`sys.int_info.default_max_str_digits ` is the compiled-" "in default limit." msgstr "" -#: ../../library/stdtypes.rst:5578 +#: ../../library/stdtypes.rst:5584 msgid "" ":data:`sys.int_info.str_digits_check_threshold ` is the lowest " "accepted value for the limit (other than 0 which disables it)." msgstr "" -#: ../../library/stdtypes.rst:5585 +#: ../../library/stdtypes.rst:5591 msgid "" "Setting a low limit *can* lead to problems. While rare, code exists that " "contains integer constants in decimal in their source that exceed the " @@ -6032,7 +6036,7 @@ msgid "" "constants is to convert them to ``0x`` hexadecimal form as it has no limit." msgstr "" -#: ../../library/stdtypes.rst:5594 +#: ../../library/stdtypes.rst:5600 msgid "" "Test your application thoroughly if you use a low limit. Ensure your tests " "run with the limit set early via the environment or flag so that it applies " @@ -6040,11 +6044,11 @@ msgid "" "to precompile ``.py`` sources to ``.pyc`` files." msgstr "" -#: ../../library/stdtypes.rst:5600 +#: ../../library/stdtypes.rst:5606 msgid "Recommended configuration" msgstr "" -#: ../../library/stdtypes.rst:5602 +#: ../../library/stdtypes.rst:5608 msgid "" "The default :data:`sys.int_info.default_max_str_digits` is expected to be " "reasonable for most applications. If your application requires a different " @@ -6052,45 +6056,45 @@ msgid "" "as these APIs were added in security patch releases in versions before 3.11." msgstr "" -#: ../../library/stdtypes.rst:5607 +#: ../../library/stdtypes.rst:5613 msgid "Example::" msgstr "" "範例:\n" "\n" "::" -#: ../../library/stdtypes.rst:5619 +#: ../../library/stdtypes.rst:5625 msgid "If you need to disable it entirely, set it to ``0``." msgstr "" -#: ../../library/stdtypes.rst:5623 +#: ../../library/stdtypes.rst:5629 msgid "Footnotes" msgstr "註解" -#: ../../library/stdtypes.rst:5624 +#: ../../library/stdtypes.rst:5630 msgid "" "Additional information on these special methods may be found in the Python " "Reference Manual (:ref:`customization`)." msgstr "" -#: ../../library/stdtypes.rst:5627 +#: ../../library/stdtypes.rst:5633 msgid "" "As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, " "and similarly for tuples." msgstr "" -#: ../../library/stdtypes.rst:5630 +#: ../../library/stdtypes.rst:5636 msgid "They must have since the parser can't tell the type of the operands." msgstr "" -#: ../../library/stdtypes.rst:5632 +#: ../../library/stdtypes.rst:5638 msgid "" -"Cased characters are those with general category property being one of \"Lu" -"\" (Letter, uppercase), \"Ll\" (Letter, lowercase), or \"Lt\" (Letter, " +"Cased characters are those with general category property being one of " +"\"Lu\" (Letter, uppercase), \"Ll\" (Letter, lowercase), or \"Lt\" (Letter, " "titlecase)." msgstr "" -#: ../../library/stdtypes.rst:5635 +#: ../../library/stdtypes.rst:5641 msgid "" "To format only a tuple you should therefore provide a singleton tuple whose " "only element is the tuple to be formatted." diff --git a/library/weakref.po b/library/weakref.po index bb9d3e9b8b..e49c2cabcb 100644 --- a/library/weakref.po +++ b/library/weakref.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-01 00:20+0000\n" +"POT-Creation-Date: 2022-12-22 00:15+0000\n" "PO-Revision-Date: 2018-05-23 16:15+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -241,10 +241,22 @@ msgid "" msgstr "" #: ../../library/weakref.rst:175 +msgid "" +"Note that when a key with equal value to an existing key (but not equal " +"identity) is inserted into the dictionary, it replaces the value but does " +"not replace the existing key. Due to this, when the reference to the " +"original key is deleted, it also deletes the entry in the dictionary::" +msgstr "" + +#: ../../library/weakref.rst:188 +msgid "A workaround would be to remove the key prior to reassignment::" +msgstr "" + +#: ../../library/weakref.rst:199 msgid "Added support for ``|`` and ``|=`` operators, specified in :pep:`584`." msgstr "新增 :pep:`584` 所述對於 ``|`` 與 ``|=`` 運算子的支援。" -#: ../../library/weakref.rst:178 +#: ../../library/weakref.rst:202 msgid "" ":class:`WeakKeyDictionary` objects have an additional method that exposes " "the internal references directly. The references are not guaranteed to be " @@ -254,39 +266,39 @@ msgid "" "longer than needed." msgstr "" -#: ../../library/weakref.rst:188 +#: ../../library/weakref.rst:212 msgid "Return an iterable of the weak references to the keys." msgstr "" -#: ../../library/weakref.rst:193 +#: ../../library/weakref.rst:217 msgid "" "Mapping class that references values weakly. Entries in the dictionary will " "be discarded when no strong reference to the value exists any more." msgstr "" -#: ../../library/weakref.rst:196 +#: ../../library/weakref.rst:220 msgid "" "Added support for ``|`` and ``|=`` operators, as specified in :pep:`584`." msgstr "" -#: ../../library/weakref.rst:199 +#: ../../library/weakref.rst:223 msgid "" ":class:`WeakValueDictionary` objects have an additional method that has the " "same issues as the :meth:`keyrefs` method of :class:`WeakKeyDictionary` " "objects." msgstr "" -#: ../../library/weakref.rst:206 +#: ../../library/weakref.rst:230 msgid "Return an iterable of the weak references to the values." msgstr "" -#: ../../library/weakref.rst:211 +#: ../../library/weakref.rst:235 msgid "" "Set class that keeps weak references to its elements. An element will be " "discarded when no strong reference to it exists any more." msgstr "" -#: ../../library/weakref.rst:217 +#: ../../library/weakref.rst:241 msgid "" "A custom :class:`ref` subclass which simulates a weak reference to a bound " "method (i.e., a method defined on a class and looked up on an instance). " @@ -295,13 +307,13 @@ msgid "" "method until either the object or the original function dies::" msgstr "" -#: ../../library/weakref.rst:241 +#: ../../library/weakref.rst:265 msgid "" "*callback* is the same as the parameter of the same name to the :func:`ref` " "function." msgstr "" -#: ../../library/weakref.rst:247 +#: ../../library/weakref.rst:271 msgid "" "Return a callable finalizer object which will be called when *obj* is " "garbage collected. Unlike an ordinary weak reference, a finalizer will " @@ -309,7 +321,7 @@ msgid "" "lifecycle management." msgstr "" -#: ../../library/weakref.rst:252 +#: ../../library/weakref.rst:276 msgid "" "A finalizer is considered *alive* until it is called (either explicitly or " "at garbage collection), and after that it is *dead*. Calling a live " @@ -317,7 +329,7 @@ msgid "" "calling a dead finalizer returns :const:`None`." msgstr "" -#: ../../library/weakref.rst:257 +#: ../../library/weakref.rst:281 msgid "" "Exceptions raised by finalizer callbacks during garbage collection will be " "shown on the standard error output, but cannot be propagated. They are " @@ -325,50 +337,50 @@ msgid "" "`__del__` method or a weak reference's callback." msgstr "" -#: ../../library/weakref.rst:263 +#: ../../library/weakref.rst:287 msgid "" "When the program exits, each remaining live finalizer is called unless its :" "attr:`atexit` attribute has been set to false. They are called in reverse " "order of creation." msgstr "" -#: ../../library/weakref.rst:267 +#: ../../library/weakref.rst:291 msgid "" "A finalizer will never invoke its callback during the later part of the :" "term:`interpreter shutdown` when module globals are liable to have been " "replaced by :const:`None`." msgstr "" -#: ../../library/weakref.rst:273 +#: ../../library/weakref.rst:297 msgid "" "If *self* is alive then mark it as dead and return the result of calling " "``func(*args, **kwargs)``. If *self* is dead then return :const:`None`." msgstr "" -#: ../../library/weakref.rst:279 +#: ../../library/weakref.rst:303 msgid "" "If *self* is alive then mark it as dead and return the tuple ``(obj, func, " "args, kwargs)``. If *self* is dead then return :const:`None`." msgstr "" -#: ../../library/weakref.rst:285 +#: ../../library/weakref.rst:309 msgid "" "If *self* is alive then return the tuple ``(obj, func, args, kwargs)``. If " "*self* is dead then return :const:`None`." msgstr "" -#: ../../library/weakref.rst:290 +#: ../../library/weakref.rst:314 msgid "Property which is true if the finalizer is alive, false otherwise." msgstr "" -#: ../../library/weakref.rst:294 +#: ../../library/weakref.rst:318 msgid "" "A writable boolean property which by default is true. When the program " "exits, it calls all remaining live finalizers for which :attr:`.atexit` is " "true. They are called in reverse order of creation." msgstr "" -#: ../../library/weakref.rst:301 +#: ../../library/weakref.rst:325 msgid "" "It is important to ensure that *func*, *args* and *kwargs* do not own any " "references to *obj*, either directly or indirectly, since otherwise *obj* " @@ -376,60 +388,60 @@ msgid "" "bound method of *obj*." msgstr "" -#: ../../library/weakref.rst:311 +#: ../../library/weakref.rst:335 msgid "The type object for weak references objects." msgstr "" -#: ../../library/weakref.rst:316 +#: ../../library/weakref.rst:340 msgid "The type object for proxies of objects which are not callable." msgstr "" -#: ../../library/weakref.rst:321 +#: ../../library/weakref.rst:345 msgid "The type object for proxies of callable objects." msgstr "" -#: ../../library/weakref.rst:326 +#: ../../library/weakref.rst:350 msgid "" "Sequence containing all the type objects for proxies. This can make it " "simpler to test if an object is a proxy without being dependent on naming " "both proxy types." msgstr "" -#: ../../library/weakref.rst:334 +#: ../../library/weakref.rst:358 msgid ":pep:`205` - Weak References" msgstr "" -#: ../../library/weakref.rst:334 +#: ../../library/weakref.rst:358 msgid "" "The proposal and rationale for this feature, including links to earlier " "implementations and information about similar features in other languages." msgstr "" -#: ../../library/weakref.rst:341 +#: ../../library/weakref.rst:365 msgid "Weak Reference Objects" msgstr "" -#: ../../library/weakref.rst:343 +#: ../../library/weakref.rst:367 msgid "" "Weak reference objects have no methods and no attributes besides :attr:`ref." "__callback__`. A weak reference object allows the referent to be obtained, " "if it still exists, by calling it:" msgstr "" -#: ../../library/weakref.rst:357 +#: ../../library/weakref.rst:381 msgid "" "If the referent no longer exists, calling the reference object returns :" "const:`None`:" msgstr "" -#: ../../library/weakref.rst:364 +#: ../../library/weakref.rst:388 msgid "" "Testing that a weak reference object is still live should be done using the " "expression ``ref() is not None``. Normally, application code that needs to " "use a reference object should follow this pattern::" msgstr "" -#: ../../library/weakref.rst:377 +#: ../../library/weakref.rst:401 msgid "" "Using a separate test for \"liveness\" creates race conditions in threaded " "applications; another thread can cause a weak reference to become " @@ -437,7 +449,7 @@ msgid "" "safe in threaded applications as well as single-threaded applications." msgstr "" -#: ../../library/weakref.rst:382 +#: ../../library/weakref.rst:406 msgid "" "Specialized versions of :class:`ref` objects can be created through " "subclassing. This is used in the implementation of the :class:" @@ -447,18 +459,18 @@ msgid "" "to retrieve the referent." msgstr "" -#: ../../library/weakref.rst:388 +#: ../../library/weakref.rst:412 msgid "" "This example shows how a subclass of :class:`ref` can be used to store " "additional information about an object and affect the value that's returned " "when the referent is accessed::" msgstr "" -#: ../../library/weakref.rst:415 +#: ../../library/weakref.rst:439 msgid "Example" msgstr "範例" -#: ../../library/weakref.rst:417 +#: ../../library/weakref.rst:441 msgid "" "This simple example shows how an application can use object IDs to retrieve " "objects that it has seen before. The IDs of the objects can then be used in " @@ -466,67 +478,67 @@ msgid "" "objects can still be retrieved by ID if they do." msgstr "" -#: ../../library/weakref.rst:442 +#: ../../library/weakref.rst:466 msgid "Finalizer Objects" msgstr "" -#: ../../library/weakref.rst:444 +#: ../../library/weakref.rst:468 msgid "" "The main benefit of using :class:`finalize` is that it makes it simple to " "register a callback without needing to preserve the returned finalizer " "object. For instance" msgstr "" -#: ../../library/weakref.rst:458 +#: ../../library/weakref.rst:482 msgid "" "The finalizer can be called directly as well. However the finalizer will " "invoke the callback at most once." msgstr "" -#: ../../library/weakref.rst:474 +#: ../../library/weakref.rst:498 msgid "" "You can unregister a finalizer using its :meth:`~finalize.detach` method. " "This kills the finalizer and returns the arguments passed to the constructor " "when it was created." msgstr "" -#: ../../library/weakref.rst:488 +#: ../../library/weakref.rst:512 msgid "" "Unless you set the :attr:`~finalize.atexit` attribute to :const:`False`, a " "finalizer will be called when the program exits if it is still alive. For " "instance" msgstr "" -#: ../../library/weakref.rst:503 +#: ../../library/weakref.rst:527 msgid "Comparing finalizers with :meth:`__del__` methods" msgstr "" -#: ../../library/weakref.rst:505 +#: ../../library/weakref.rst:529 msgid "" "Suppose we want to create a class whose instances represent temporary " "directories. The directories should be deleted with their contents when the " "first of the following events occurs:" msgstr "" -#: ../../library/weakref.rst:509 +#: ../../library/weakref.rst:533 msgid "the object is garbage collected," msgstr "" -#: ../../library/weakref.rst:510 +#: ../../library/weakref.rst:534 msgid "the object's :meth:`remove` method is called, or" msgstr "" -#: ../../library/weakref.rst:511 +#: ../../library/weakref.rst:535 msgid "the program exits." msgstr "" -#: ../../library/weakref.rst:513 +#: ../../library/weakref.rst:537 msgid "" "We might try to implement the class using a :meth:`__del__` method as " "follows::" msgstr "" -#: ../../library/weakref.rst:532 +#: ../../library/weakref.rst:556 msgid "" "Starting with Python 3.4, :meth:`__del__` methods no longer prevent " "reference cycles from being garbage collected, and module globals are no " @@ -534,35 +546,35 @@ msgid "" "code should work without any issues on CPython." msgstr "" -#: ../../library/weakref.rst:537 +#: ../../library/weakref.rst:561 msgid "" "However, handling of :meth:`__del__` methods is notoriously implementation " "specific, since it depends on internal details of the interpreter's garbage " "collector implementation." msgstr "" -#: ../../library/weakref.rst:541 +#: ../../library/weakref.rst:565 msgid "" "A more robust alternative can be to define a finalizer which only references " "the specific functions and objects that it needs, rather than having access " "to the full state of the object::" msgstr "" -#: ../../library/weakref.rst:557 +#: ../../library/weakref.rst:581 msgid "" "Defined like this, our finalizer only receives a reference to the details it " "needs to clean up the directory appropriately. If the object never gets " "garbage collected the finalizer will still be called at exit." msgstr "" -#: ../../library/weakref.rst:561 +#: ../../library/weakref.rst:585 msgid "" "The other advantage of weakref based finalizers is that they can be used to " "register finalizers for classes where the definition is controlled by a " "third party, such as running code when a module is unloaded::" msgstr "" -#: ../../library/weakref.rst:573 +#: ../../library/weakref.rst:597 msgid "" "If you create a finalizer object in a daemonic thread just as the program " "exits then there is the possibility that the finalizer does not get called " From 39f6b228592f3750d4b4a5cd7095550c24e27a0d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Dec 2022 00:19:15 +0000 Subject: [PATCH 3/3] sync with cpython 1fa4c6bd --- faq/programming.po | 700 ++++++++++++++++++------------------ reference/executionmodel.po | 47 +-- 2 files changed, 374 insertions(+), 373 deletions(-) diff --git a/faq/programming.po b/faq/programming.po index a20b3e5d61..38b67b8801 100644 --- a/faq/programming.po +++ b/faq/programming.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-11-12 06:58+0000\n" +"POT-Creation-Date: 2022-12-23 00:16+0000\n" "PO-Revision-Date: 2018-05-23 14:35+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -212,30 +212,30 @@ msgstr "" msgid "Core Language" msgstr "" -#: ../../faq/programming.rst:117 +#: ../../faq/programming.rst:119 msgid "Why am I getting an UnboundLocalError when the variable has a value?" msgstr "為什麼當變數有值時我得到錯誤訊息 UnboundLocalError" -#: ../../faq/programming.rst:119 +#: ../../faq/programming.rst:121 msgid "" "It can be a surprise to get the :exc:`UnboundLocalError` in previously " "working code when it is modified by adding an assignment statement somewhere " "in the body of a function." msgstr "" -#: ../../faq/programming.rst:123 +#: ../../faq/programming.rst:125 msgid "This code:" msgstr "這段程式碼:" -#: ../../faq/programming.rst:132 +#: ../../faq/programming.rst:134 msgid "works, but this code:" msgstr "可以執行,但是這段程式:" -#: ../../faq/programming.rst:139 +#: ../../faq/programming.rst:141 msgid "results in an :exc:`!UnboundLocalError`:" msgstr "導致 :exc:`!UnboundLocalError`:" -#: ../../faq/programming.rst:146 +#: ../../faq/programming.rst:148 msgid "" "This is because when you make an assignment to a variable in a scope, that " "variable becomes local to that scope and shadows any similarly named " @@ -245,30 +245,30 @@ msgid "" "uninitialized local variable and an error results." msgstr "" -#: ../../faq/programming.rst:153 +#: ../../faq/programming.rst:155 msgid "" "In the example above you can access the outer scope variable by declaring it " "global:" msgstr "" -#: ../../faq/programming.rst:165 +#: ../../faq/programming.rst:167 msgid "" "This explicit declaration is required in order to remind you that (unlike " "the superficially analogous situation with class and instance variables) you " "are actually modifying the value of the variable in the outer scope:" msgstr "" -#: ../../faq/programming.rst:172 +#: ../../faq/programming.rst:174 msgid "" "You can do a similar thing in a nested scope using the :keyword:`nonlocal` " "keyword:" msgstr "" -#: ../../faq/programming.rst:190 +#: ../../faq/programming.rst:192 msgid "What are the rules for local and global variables in Python?" msgstr "Python 的區域變數和全域變數有什麼規則?" -#: ../../faq/programming.rst:192 +#: ../../faq/programming.rst:194 msgid "" "In Python, variables that are only referenced inside a function are " "implicitly global. If a variable is assigned a value anywhere within the " @@ -276,7 +276,7 @@ msgid "" "global." msgstr "" -#: ../../faq/programming.rst:196 +#: ../../faq/programming.rst:198 msgid "" "Though a bit surprising at first, a moment's consideration explains this. " "On one hand, requiring :keyword:`global` for assigned variables provides a " @@ -287,19 +287,19 @@ msgid "" "of the ``global`` declaration for identifying side-effects." msgstr "" -#: ../../faq/programming.rst:206 +#: ../../faq/programming.rst:208 msgid "" "Why do lambdas defined in a loop with different values all return the same " "result?" msgstr "" -#: ../../faq/programming.rst:208 +#: ../../faq/programming.rst:210 msgid "" "Assume you use a for loop to define a few different lambdas (or even plain " "functions), e.g.::" msgstr "" -#: ../../faq/programming.rst:215 +#: ../../faq/programming.rst:217 msgid "" "This gives you a list that contains 5 lambdas that calculate ``x**2``. You " "might expect that, when called, they would return, respectively, ``0``, " @@ -307,7 +307,7 @@ msgid "" "see that they all return ``16``::" msgstr "" -#: ../../faq/programming.rst:225 +#: ../../faq/programming.rst:227 msgid "" "This happens because ``x`` is not local to the lambdas, but is defined in " "the outer scope, and it is accessed when the lambda is called --- not when " @@ -316,13 +316,13 @@ msgid "" "changing the value of ``x`` and see how the results of the lambdas change::" msgstr "" -#: ../../faq/programming.rst:235 +#: ../../faq/programming.rst:237 msgid "" "In order to avoid this, you need to save the values in variables local to " "the lambdas, so that they don't rely on the value of the global ``x``::" msgstr "" -#: ../../faq/programming.rst:242 +#: ../../faq/programming.rst:244 msgid "" "Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed " "when the lambda is defined so that it has the same value that ``x`` had at " @@ -331,17 +331,17 @@ msgid "" "Therefore each lambda will now return the correct result::" msgstr "" -#: ../../faq/programming.rst:253 +#: ../../faq/programming.rst:255 msgid "" "Note that this behaviour is not peculiar to lambdas, but applies to regular " "functions too." msgstr "" -#: ../../faq/programming.rst:258 +#: ../../faq/programming.rst:260 msgid "How do I share global variables across modules?" msgstr "" -#: ../../faq/programming.rst:260 +#: ../../faq/programming.rst:262 msgid "" "The canonical way to share information across modules within a single " "program is to create a special module (often called config or cfg). Just " @@ -351,45 +351,45 @@ msgid "" "everywhere. For example:" msgstr "" -#: ../../faq/programming.rst:266 +#: ../../faq/programming.rst:268 msgid "config.py::" msgstr "" "config.py:\n" "\n" "::" -#: ../../faq/programming.rst:270 +#: ../../faq/programming.rst:272 msgid "mod.py::" msgstr "" "mod.py:\n" "\n" "::" -#: ../../faq/programming.rst:275 +#: ../../faq/programming.rst:277 msgid "main.py::" msgstr "" "main.py:\n" "\n" "::" -#: ../../faq/programming.rst:281 +#: ../../faq/programming.rst:283 msgid "" "Note that using a module is also the basis for implementing the singleton " "design pattern, for the same reason." msgstr "" -#: ../../faq/programming.rst:286 +#: ../../faq/programming.rst:288 msgid "What are the \"best practices\" for using import in a module?" msgstr "" -#: ../../faq/programming.rst:288 +#: ../../faq/programming.rst:290 msgid "" "In general, don't use ``from modulename import *``. Doing so clutters the " "importer's namespace, and makes it much harder for linters to detect " "undefined names." msgstr "" -#: ../../faq/programming.rst:292 +#: ../../faq/programming.rst:294 msgid "" "Import modules at the top of a file. Doing so makes it clear what other " "modules your code requires and avoids questions of whether the module name " @@ -397,33 +397,33 @@ msgid "" "module imports, but using multiple imports per line uses less screen space." msgstr "" -#: ../../faq/programming.rst:297 +#: ../../faq/programming.rst:299 msgid "It's good practice if you import modules in the following order:" msgstr "" -#: ../../faq/programming.rst:299 +#: ../../faq/programming.rst:301 msgid "" "standard library modules -- e.g. :mod:`sys`, :mod:`os`, :mod:`argparse`, :" "mod:`re`" msgstr "" -#: ../../faq/programming.rst:300 +#: ../../faq/programming.rst:302 msgid "" "third-party library modules (anything installed in Python's site-packages " "directory) -- e.g. :mod:`!dateutil`, :mod:`!requests`, :mod:`!PIL.Image`" msgstr "" -#: ../../faq/programming.rst:302 +#: ../../faq/programming.rst:304 msgid "locally developed modules" msgstr "" -#: ../../faq/programming.rst:304 +#: ../../faq/programming.rst:306 msgid "" "It is sometimes necessary to move imports to a function or class to avoid " "problems with circular imports. Gordon McMillan says:" msgstr "" -#: ../../faq/programming.rst:307 +#: ../../faq/programming.rst:309 msgid "" "Circular imports are fine where both modules use the \"import \" " "form of import. They fail when the 2nd module wants to grab a name out of " @@ -432,7 +432,7 @@ msgid "" "module is busy importing the 2nd." msgstr "" -#: ../../faq/programming.rst:313 +#: ../../faq/programming.rst:315 msgid "" "In this case, if the second module is only used in one function, then the " "import can easily be moved into that function. By the time the import is " @@ -440,7 +440,7 @@ msgid "" "module can do its import." msgstr "" -#: ../../faq/programming.rst:318 +#: ../../faq/programming.rst:320 msgid "" "It may also be necessary to move imports out of the top level of code if " "some of the modules are platform-specific. In that case, it may not even be " @@ -449,7 +449,7 @@ msgid "" "a good option." msgstr "" -#: ../../faq/programming.rst:323 +#: ../../faq/programming.rst:325 msgid "" "Only move imports into a local scope, such as inside a function definition, " "if it's necessary to solve a problem such as avoiding a circular import or " @@ -463,24 +463,24 @@ msgid "" "of scope, the module is probably available in :data:`sys.modules`." msgstr "" -#: ../../faq/programming.rst:336 +#: ../../faq/programming.rst:338 msgid "Why are default values shared between objects?" msgstr "" -#: ../../faq/programming.rst:338 +#: ../../faq/programming.rst:340 msgid "" "This type of bug commonly bites neophyte programmers. Consider this " "function::" msgstr "" -#: ../../faq/programming.rst:345 +#: ../../faq/programming.rst:347 msgid "" "The first time you call this function, ``mydict`` contains a single item. " "The second time, ``mydict`` contains two items because when ``foo()`` begins " "executing, ``mydict`` starts out with an item already in it." msgstr "" -#: ../../faq/programming.rst:349 +#: ../../faq/programming.rst:351 msgid "" "It is often expected that a function call creates new objects for default " "values. This is not what happens. Default values are created exactly once, " @@ -489,14 +489,14 @@ msgid "" "this changed object." msgstr "" -#: ../../faq/programming.rst:354 +#: ../../faq/programming.rst:356 msgid "" "By definition, immutable objects such as numbers, strings, tuples, and " "``None``, are safe from change. Changes to mutable objects such as " "dictionaries, lists, and class instances can lead to confusion." msgstr "" -#: ../../faq/programming.rst:358 +#: ../../faq/programming.rst:360 msgid "" "Because of this feature, it is good programming practice to not use mutable " "objects as default values. Instead, use ``None`` as the default value and " @@ -504,14 +504,14 @@ msgid "" "list/dictionary/whatever if it is. For example, don't write::" msgstr "" -#: ../../faq/programming.rst:366 +#: ../../faq/programming.rst:368 msgid "but::" msgstr "" "但是:\n" "\n" "::" -#: ../../faq/programming.rst:372 +#: ../../faq/programming.rst:374 msgid "" "This feature can be useful. When you have a function that's time-consuming " "to compute, a common technique is to cache the parameters and the resulting " @@ -520,18 +520,18 @@ msgid "" "implemented like this::" msgstr "" -#: ../../faq/programming.rst:387 +#: ../../faq/programming.rst:389 msgid "" "You could use a global variable containing a dictionary instead of the " "default value; it's a matter of taste." msgstr "" -#: ../../faq/programming.rst:392 +#: ../../faq/programming.rst:394 msgid "" "How can I pass optional or keyword parameters from one function to another?" msgstr "" -#: ../../faq/programming.rst:394 +#: ../../faq/programming.rst:396 msgid "" "Collect the arguments using the ``*`` and ``**`` specifiers in the " "function's parameter list; this gives you the positional arguments as a " @@ -539,11 +539,11 @@ msgid "" "arguments when calling another function by using ``*`` and ``**``::" msgstr "" -#: ../../faq/programming.rst:413 +#: ../../faq/programming.rst:415 msgid "What is the difference between arguments and parameters?" msgstr "" -#: ../../faq/programming.rst:415 +#: ../../faq/programming.rst:417 msgid "" ":term:`Parameters ` are defined by the names that appear in a " "function definition, whereas :term:`arguments ` are the values " @@ -552,34 +552,34 @@ msgid "" "the function definition::" msgstr "" -#: ../../faq/programming.rst:424 +#: ../../faq/programming.rst:426 msgid "" "*foo*, *bar* and *kwargs* are parameters of ``func``. However, when calling " "``func``, for example::" msgstr "" -#: ../../faq/programming.rst:429 +#: ../../faq/programming.rst:431 msgid "the values ``42``, ``314``, and ``somevar`` are arguments." msgstr "" -#: ../../faq/programming.rst:433 +#: ../../faq/programming.rst:435 msgid "Why did changing list 'y' also change list 'x'?" msgstr "" -#: ../../faq/programming.rst:435 +#: ../../faq/programming.rst:437 msgid "If you wrote code like::" msgstr "" -#: ../../faq/programming.rst:445 +#: ../../faq/programming.rst:447 msgid "" "you might be wondering why appending an element to ``y`` changed ``x`` too." msgstr "" -#: ../../faq/programming.rst:447 +#: ../../faq/programming.rst:449 msgid "There are two factors that produce this result:" msgstr "" -#: ../../faq/programming.rst:449 +#: ../../faq/programming.rst:451 msgid "" "Variables are simply names that refer to objects. Doing ``y = x`` doesn't " "create a copy of the list -- it creates a new variable ``y`` that refers to " @@ -587,23 +587,23 @@ msgid "" "(the list), and both ``x`` and ``y`` refer to it." msgstr "" -#: ../../faq/programming.rst:453 +#: ../../faq/programming.rst:455 msgid "" "Lists are :term:`mutable`, which means that you can change their content." msgstr "" -#: ../../faq/programming.rst:455 +#: ../../faq/programming.rst:457 msgid "" "After the call to :meth:`~list.append`, the content of the mutable object " "has changed from ``[]`` to ``[10]``. Since both the variables refer to the " "same object, using either name accesses the modified value ``[10]``." msgstr "" -#: ../../faq/programming.rst:459 +#: ../../faq/programming.rst:461 msgid "If we instead assign an immutable object to ``x``::" msgstr "" -#: ../../faq/programming.rst:469 +#: ../../faq/programming.rst:471 msgid "" "we can see that in this case ``x`` and ``y`` are not equal anymore. This is " "because integers are :term:`immutable`, and when we do ``x = x + 1`` we are " @@ -614,7 +614,7 @@ msgid "" "(``x`` now refers to ``6`` but ``y`` still refers to ``5``)." msgstr "" -#: ../../faq/programming.rst:477 +#: ../../faq/programming.rst:479 msgid "" "Some operations (for example ``y.append(10)`` and ``y.sort()``) mutate the " "object, whereas superficially similar operations (for example ``y = y + " @@ -626,7 +626,7 @@ msgid "" "which will likely cause your program to generate an easily diagnosed error." msgstr "" -#: ../../faq/programming.rst:486 +#: ../../faq/programming.rst:488 msgid "" "However, there is one class of operations where the same operation sometimes " "has different behaviors with different types: the augmented assignment " @@ -636,18 +636,18 @@ msgid "" "1`` create new objects)." msgstr "" -#: ../../faq/programming.rst:493 +#: ../../faq/programming.rst:495 msgid "In other words:" msgstr "" -#: ../../faq/programming.rst:495 +#: ../../faq/programming.rst:497 msgid "" "If we have a mutable object (:class:`list`, :class:`dict`, :class:`set`, " "etc.), we can use some specific operations to mutate it and all the " "variables that refer to it will see the change." msgstr "" -#: ../../faq/programming.rst:498 +#: ../../faq/programming.rst:500 msgid "" "If we have an immutable object (:class:`str`, :class:`int`, :class:`tuple`, " "etc.), all the variables that refer to it will always see the same value, " @@ -655,17 +655,17 @@ msgid "" "new object." msgstr "" -#: ../../faq/programming.rst:503 +#: ../../faq/programming.rst:505 msgid "" "If you want to know if two variables refer to the same object or not, you " "can use the :keyword:`is` operator, or the built-in function :func:`id`." msgstr "" -#: ../../faq/programming.rst:508 +#: ../../faq/programming.rst:510 msgid "How do I write a function with output parameters (call by reference)?" msgstr "" -#: ../../faq/programming.rst:510 +#: ../../faq/programming.rst:512 msgid "" "Remember that arguments are passed by assignment in Python. Since " "assignment just creates references to objects, there's no alias between an " @@ -673,44 +673,44 @@ msgid "" "You can achieve the desired effect in a number of ways." msgstr "" -#: ../../faq/programming.rst:515 +#: ../../faq/programming.rst:517 msgid "By returning a tuple of the results::" msgstr "" -#: ../../faq/programming.rst:526 +#: ../../faq/programming.rst:528 msgid "This is almost always the clearest solution." msgstr "" -#: ../../faq/programming.rst:528 +#: ../../faq/programming.rst:530 msgid "" "By using global variables. This isn't thread-safe, and is not recommended." msgstr "" -#: ../../faq/programming.rst:530 +#: ../../faq/programming.rst:532 msgid "By passing a mutable (changeable in-place) object::" msgstr "" -#: ../../faq/programming.rst:541 +#: ../../faq/programming.rst:543 msgid "By passing in a dictionary that gets mutated::" msgstr "" -#: ../../faq/programming.rst:552 +#: ../../faq/programming.rst:554 msgid "Or bundle up values in a class instance::" msgstr "" -#: ../../faq/programming.rst:569 +#: ../../faq/programming.rst:571 msgid "There's almost never a good reason to get this complicated." msgstr "" -#: ../../faq/programming.rst:571 +#: ../../faq/programming.rst:573 msgid "Your best choice is to return a tuple containing the multiple results." msgstr "" -#: ../../faq/programming.rst:575 +#: ../../faq/programming.rst:577 msgid "How do you make a higher order function in Python?" msgstr "" -#: ../../faq/programming.rst:577 +#: ../../faq/programming.rst:579 msgid "" "You have two choices: you can use nested scopes or you can use callable " "objects. For example, suppose you wanted to define ``linear(a,b)`` which " @@ -718,71 +718,71 @@ msgid "" "scopes::" msgstr "" -#: ../../faq/programming.rst:586 +#: ../../faq/programming.rst:588 msgid "Or using a callable object::" msgstr "" -#: ../../faq/programming.rst:596 +#: ../../faq/programming.rst:598 msgid "In both cases, ::" msgstr "" -#: ../../faq/programming.rst:600 +#: ../../faq/programming.rst:602 msgid "gives a callable object where ``taxes(10e6) == 0.3 * 10e6 + 2``." msgstr "" -#: ../../faq/programming.rst:602 +#: ../../faq/programming.rst:604 msgid "" "The callable object approach has the disadvantage that it is a bit slower " "and results in slightly longer code. However, note that a collection of " "callables can share their signature via inheritance::" msgstr "" -#: ../../faq/programming.rst:611 +#: ../../faq/programming.rst:613 msgid "Object can encapsulate state for several methods::" msgstr "" -#: ../../faq/programming.rst:629 +#: ../../faq/programming.rst:631 msgid "" "Here ``inc()``, ``dec()`` and ``reset()`` act like functions which share the " "same counting variable." msgstr "" -#: ../../faq/programming.rst:634 +#: ../../faq/programming.rst:636 msgid "How do I copy an object in Python?" msgstr "" -#: ../../faq/programming.rst:636 +#: ../../faq/programming.rst:638 msgid "" "In general, try :func:`copy.copy` or :func:`copy.deepcopy` for the general " "case. Not all objects can be copied, but most can." msgstr "" -#: ../../faq/programming.rst:639 +#: ../../faq/programming.rst:641 msgid "" "Some objects can be copied more easily. Dictionaries have a :meth:`~dict." "copy` method::" msgstr "" -#: ../../faq/programming.rst:644 +#: ../../faq/programming.rst:646 msgid "Sequences can be copied by slicing::" msgstr "" -#: ../../faq/programming.rst:650 +#: ../../faq/programming.rst:652 msgid "How can I find the methods or attributes of an object?" msgstr "" -#: ../../faq/programming.rst:652 +#: ../../faq/programming.rst:654 msgid "" "For an instance ``x`` of a user-defined class, :func:`dir(x) ` returns " "an alphabetized list of the names containing the instance attributes and " "methods and attributes defined by its class." msgstr "" -#: ../../faq/programming.rst:658 +#: ../../faq/programming.rst:660 msgid "How can my code discover the name of an object?" msgstr "" -#: ../../faq/programming.rst:660 +#: ../../faq/programming.rst:662 msgid "" "Generally speaking, it can't, because objects don't really have names. " "Essentially, assignment always binds a name to a value; the same is true of " @@ -790,7 +790,7 @@ msgid "" "Consider the following code::" msgstr "" -#: ../../faq/programming.rst:676 +#: ../../faq/programming.rst:678 msgid "" "Arguably the class has a name: even though it is bound to two names and " "invoked through the name ``B`` the created instance is still reported as an " @@ -799,7 +799,7 @@ msgid "" "value." msgstr "" -#: ../../faq/programming.rst:681 +#: ../../faq/programming.rst:683 msgid "" "Generally speaking it should not be necessary for your code to \"know the " "names\" of particular values. Unless you are deliberately writing " @@ -807,13 +807,13 @@ msgid "" "approach might be beneficial." msgstr "" -#: ../../faq/programming.rst:686 +#: ../../faq/programming.rst:688 msgid "" "In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer " "to this question:" msgstr "" -#: ../../faq/programming.rst:689 +#: ../../faq/programming.rst:691 msgid "" "The same way as you get the name of that cat you found on your porch: the " "cat (object) itself cannot tell you its name, and it doesn't really care -- " @@ -821,78 +821,78 @@ msgid "" "(namespaces) if it's their cat (object)..." msgstr "" -#: ../../faq/programming.rst:694 +#: ../../faq/programming.rst:696 msgid "" "....and don't be surprised if you'll find that it's known by many names, or " "no name at all!" msgstr "" -#: ../../faq/programming.rst:699 +#: ../../faq/programming.rst:701 msgid "What's up with the comma operator's precedence?" msgstr "" -#: ../../faq/programming.rst:701 +#: ../../faq/programming.rst:703 msgid "Comma is not an operator in Python. Consider this session::" msgstr "" -#: ../../faq/programming.rst:706 +#: ../../faq/programming.rst:708 msgid "" "Since the comma is not an operator, but a separator between expressions the " "above is evaluated as if you had entered::" msgstr "" -#: ../../faq/programming.rst:711 +#: ../../faq/programming.rst:713 msgid "not::" msgstr "" -#: ../../faq/programming.rst:715 +#: ../../faq/programming.rst:717 msgid "" "The same is true of the various assignment operators (``=``, ``+=`` etc). " "They are not truly operators but syntactic delimiters in assignment " "statements." msgstr "" -#: ../../faq/programming.rst:720 +#: ../../faq/programming.rst:722 msgid "Is there an equivalent of C's \"?:\" ternary operator?" msgstr "" -#: ../../faq/programming.rst:722 +#: ../../faq/programming.rst:724 msgid "Yes, there is. The syntax is as follows::" msgstr "" -#: ../../faq/programming.rst:729 +#: ../../faq/programming.rst:731 msgid "" "Before this syntax was introduced in Python 2.5, a common idiom was to use " "logical operators::" msgstr "" -#: ../../faq/programming.rst:734 +#: ../../faq/programming.rst:736 msgid "" "However, this idiom is unsafe, as it can give wrong results when *on_true* " "has a false boolean value. Therefore, it is always better to use the ``... " "if ... else ...`` form." msgstr "" -#: ../../faq/programming.rst:740 +#: ../../faq/programming.rst:742 msgid "Is it possible to write obfuscated one-liners in Python?" msgstr "" -#: ../../faq/programming.rst:742 +#: ../../faq/programming.rst:744 msgid "" "Yes. Usually this is done by nesting :keyword:`lambda` within :keyword:`!" "lambda`. See the following three examples, slightly adapted from Ulf " "Bartelt::" msgstr "" -#: ../../faq/programming.rst:769 +#: ../../faq/programming.rst:771 msgid "Don't try this at home, kids!" msgstr "" -#: ../../faq/programming.rst:775 +#: ../../faq/programming.rst:777 msgid "What does the slash(/) in the parameter list of a function mean?" msgstr "" -#: ../../faq/programming.rst:777 +#: ../../faq/programming.rst:779 msgid "" "A slash in the argument list of a function denotes that the parameters prior " "to it are positional-only. Positional-only parameters are the ones without " @@ -902,53 +902,53 @@ msgid "" "only parameters. Its documentation looks like this::" msgstr "" -#: ../../faq/programming.rst:790 +#: ../../faq/programming.rst:792 msgid "" "The slash at the end of the parameter list means that both parameters are " "positional-only. Thus, calling :func:`divmod` with keyword arguments would " "lead to an error::" msgstr "" -#: ../../faq/programming.rst:801 +#: ../../faq/programming.rst:803 msgid "Numbers and strings" msgstr "" -#: ../../faq/programming.rst:804 +#: ../../faq/programming.rst:806 msgid "How do I specify hexadecimal and octal integers?" msgstr "" -#: ../../faq/programming.rst:806 +#: ../../faq/programming.rst:808 msgid "" "To specify an octal digit, precede the octal value with a zero, and then a " "lower or uppercase \"o\". For example, to set the variable \"a\" to the " "octal value \"10\" (8 in decimal), type::" msgstr "" -#: ../../faq/programming.rst:814 +#: ../../faq/programming.rst:816 msgid "" "Hexadecimal is just as easy. Simply precede the hexadecimal number with a " "zero, and then a lower or uppercase \"x\". Hexadecimal digits can be " "specified in lower or uppercase. For example, in the Python interpreter::" msgstr "" -#: ../../faq/programming.rst:827 +#: ../../faq/programming.rst:829 msgid "Why does -22 // 10 return -3?" msgstr "" -#: ../../faq/programming.rst:829 +#: ../../faq/programming.rst:831 msgid "" "It's primarily driven by the desire that ``i % j`` have the same sign as " "``j``. If you want that, and also want::" msgstr "" -#: ../../faq/programming.rst:834 +#: ../../faq/programming.rst:836 msgid "" "then integer division has to return the floor. C also requires that " "identity to hold, and then compilers that truncate ``i // j`` need to make " "``i % j`` have the same sign as ``i``." msgstr "" -#: ../../faq/programming.rst:838 +#: ../../faq/programming.rst:840 msgid "" "There are few real use cases for ``i % j`` when ``j`` is negative. When " "``j`` is positive, there are many, and in virtually all of them it's more " @@ -957,34 +957,34 @@ msgid "" "bug waiting to bite." msgstr "" -#: ../../faq/programming.rst:846 +#: ../../faq/programming.rst:848 msgid "How do I get int literal attribute instead of SyntaxError?" msgstr "" -#: ../../faq/programming.rst:848 +#: ../../faq/programming.rst:850 msgid "" "Trying to lookup an ``int`` literal attribute in the normal manner gives a :" "exc:`SyntaxError` because the period is seen as a decimal point::" msgstr "" -#: ../../faq/programming.rst:857 +#: ../../faq/programming.rst:859 msgid "" "The solution is to separate the literal from the period with either a space " "or parentheses." msgstr "" -#: ../../faq/programming.rst:867 +#: ../../faq/programming.rst:869 msgid "How do I convert a string to a number?" msgstr "" -#: ../../faq/programming.rst:869 +#: ../../faq/programming.rst:871 msgid "" "For integers, use the built-in :func:`int` type constructor, e.g. " "``int('144') == 144``. Similarly, :func:`float` converts to floating-point, " "e.g. ``float('144') == 144.0``." msgstr "" -#: ../../faq/programming.rst:873 +#: ../../faq/programming.rst:875 msgid "" "By default, these interpret the number as decimal, so that ``int('0144') == " "144`` holds true, and ``int('0x144')`` raises :exc:`ValueError`. " @@ -994,7 +994,7 @@ msgid "" "octal, and '0x' indicates a hex number." msgstr "" -#: ../../faq/programming.rst:880 +#: ../../faq/programming.rst:882 msgid "" "Do not use the built-in function :func:`eval` if all you need is to convert " "strings to numbers. :func:`eval` will be significantly slower and it " @@ -1004,18 +1004,18 @@ msgid "" "directory." msgstr "" -#: ../../faq/programming.rst:887 +#: ../../faq/programming.rst:889 msgid "" ":func:`eval` also has the effect of interpreting numbers as Python " "expressions, so that e.g. ``eval('09')`` gives a syntax error because Python " "does not allow leading '0' in a decimal number (except '0')." msgstr "" -#: ../../faq/programming.rst:893 +#: ../../faq/programming.rst:895 msgid "How do I convert a number to a string?" msgstr "" -#: ../../faq/programming.rst:895 +#: ../../faq/programming.rst:897 msgid "" "To convert, e.g., the number ``144`` to the string ``'144'``, use the built-" "in type constructor :func:`str`. If you want a hexadecimal or octal " @@ -1025,11 +1025,11 @@ msgid "" "format(1.0/3.0)`` yields ``'0.333'``." msgstr "" -#: ../../faq/programming.rst:904 +#: ../../faq/programming.rst:906 msgid "How do I modify a string in place?" msgstr "" -#: ../../faq/programming.rst:906 +#: ../../faq/programming.rst:908 msgid "" "You can't, because strings are immutable. In most situations, you should " "simply construct a new string from the various parts you want to assemble it " @@ -1038,15 +1038,15 @@ msgid "" "module::" msgstr "" -#: ../../faq/programming.rst:936 +#: ../../faq/programming.rst:938 msgid "How do I use strings to call functions/methods?" msgstr "" -#: ../../faq/programming.rst:938 +#: ../../faq/programming.rst:940 msgid "There are various techniques." msgstr "" -#: ../../faq/programming.rst:940 +#: ../../faq/programming.rst:942 msgid "" "The best is to use a dictionary that maps strings to functions. The primary " "advantage of this technique is that the strings do not need to match the " @@ -1054,31 +1054,31 @@ msgid "" "a case construct::" msgstr "" -#: ../../faq/programming.rst:955 +#: ../../faq/programming.rst:957 msgid "Use the built-in function :func:`getattr`::" msgstr "" -#: ../../faq/programming.rst:960 +#: ../../faq/programming.rst:962 msgid "" "Note that :func:`getattr` works on any object, including classes, class " "instances, modules, and so on." msgstr "" -#: ../../faq/programming.rst:963 +#: ../../faq/programming.rst:965 msgid "This is used in several places in the standard library, like this::" msgstr "" -#: ../../faq/programming.rst:976 +#: ../../faq/programming.rst:978 msgid "Use :func:`locals` to resolve the function name::" msgstr "" -#: ../../faq/programming.rst:988 +#: ../../faq/programming.rst:990 msgid "" "Is there an equivalent to Perl's chomp() for removing trailing newlines from " "strings?" msgstr "" -#: ../../faq/programming.rst:990 +#: ../../faq/programming.rst:992 msgid "" "You can use ``S.rstrip(\"\\r\\n\")`` to remove all occurrences of any line " "terminator from the end of the string ``S`` without removing other trailing " @@ -1087,21 +1087,21 @@ msgid "" "removed::" msgstr "" -#: ../../faq/programming.rst:1002 +#: ../../faq/programming.rst:1004 msgid "" "Since this is typically only desired when reading text one line at a time, " "using ``S.rstrip()`` this way works well." msgstr "" -#: ../../faq/programming.rst:1007 +#: ../../faq/programming.rst:1009 msgid "Is there a scanf() or sscanf() equivalent?" msgstr "" -#: ../../faq/programming.rst:1009 +#: ../../faq/programming.rst:1011 msgid "Not as such." msgstr "" -#: ../../faq/programming.rst:1011 +#: ../../faq/programming.rst:1013 msgid "" "For simple input parsing, the easiest approach is usually to split the line " "into whitespace-delimited words using the :meth:`~str.split` method of " @@ -1111,86 +1111,86 @@ msgid "" "as a separator." msgstr "" -#: ../../faq/programming.rst:1017 +#: ../../faq/programming.rst:1019 msgid "" "For more complicated input parsing, regular expressions are more powerful " "than C's ``sscanf`` and better suited for the task." msgstr "" -#: ../../faq/programming.rst:1022 +#: ../../faq/programming.rst:1024 msgid "What does 'UnicodeDecodeError' or 'UnicodeEncodeError' error mean?" msgstr "" -#: ../../faq/programming.rst:1024 +#: ../../faq/programming.rst:1026 msgid "See the :ref:`unicode-howto`." msgstr "" -#: ../../faq/programming.rst:1028 +#: ../../faq/programming.rst:1030 msgid "Performance" msgstr "" -#: ../../faq/programming.rst:1031 +#: ../../faq/programming.rst:1033 msgid "My program is too slow. How do I speed it up?" msgstr "" -#: ../../faq/programming.rst:1033 +#: ../../faq/programming.rst:1035 msgid "" "That's a tough one, in general. First, here are a list of things to " "remember before diving further:" msgstr "" -#: ../../faq/programming.rst:1036 +#: ../../faq/programming.rst:1038 msgid "" "Performance characteristics vary across Python implementations. This FAQ " "focuses on :term:`CPython`." msgstr "" -#: ../../faq/programming.rst:1038 +#: ../../faq/programming.rst:1040 msgid "" "Behaviour can vary across operating systems, especially when talking about I/" "O or multi-threading." msgstr "" -#: ../../faq/programming.rst:1040 +#: ../../faq/programming.rst:1042 msgid "" "You should always find the hot spots in your program *before* attempting to " "optimize any code (see the :mod:`profile` module)." msgstr "" -#: ../../faq/programming.rst:1042 +#: ../../faq/programming.rst:1044 msgid "" "Writing benchmark scripts will allow you to iterate quickly when searching " "for improvements (see the :mod:`timeit` module)." msgstr "" -#: ../../faq/programming.rst:1044 +#: ../../faq/programming.rst:1046 msgid "" "It is highly recommended to have good code coverage (through unit testing or " "any other technique) before potentially introducing regressions hidden in " "sophisticated optimizations." msgstr "" -#: ../../faq/programming.rst:1048 +#: ../../faq/programming.rst:1050 msgid "" "That being said, there are many tricks to speed up Python code. Here are " "some general principles which go a long way towards reaching acceptable " "performance levels:" msgstr "" -#: ../../faq/programming.rst:1052 +#: ../../faq/programming.rst:1054 msgid "" "Making your algorithms faster (or changing to faster ones) can yield much " "larger benefits than trying to sprinkle micro-optimization tricks all over " "your code." msgstr "" -#: ../../faq/programming.rst:1056 +#: ../../faq/programming.rst:1058 msgid "" "Use the right data structures. Study documentation for the :ref:`bltin-" "types` and the :mod:`collections` module." msgstr "" -#: ../../faq/programming.rst:1059 +#: ../../faq/programming.rst:1061 msgid "" "When the standard library provides a primitive for doing something, it is " "likely (although not guaranteed) to be faster than any alternative you may " @@ -1201,7 +1201,7 @@ msgid "" "advanced usage)." msgstr "" -#: ../../faq/programming.rst:1067 +#: ../../faq/programming.rst:1069 msgid "" "Abstractions tend to create indirections and force the interpreter to work " "more. If the levels of indirection outweigh the amount of useful work done, " @@ -1210,7 +1210,7 @@ msgid "" "detrimental to readability)." msgstr "" -#: ../../faq/programming.rst:1073 +#: ../../faq/programming.rst:1075 msgid "" "If you have reached the limit of what pure Python can allow, there are tools " "to take you further away. For example, `Cython `_ can " @@ -1222,17 +1222,17 @@ msgid "" "yourself." msgstr "" -#: ../../faq/programming.rst:1083 +#: ../../faq/programming.rst:1085 msgid "" "The wiki page devoted to `performance tips `_." msgstr "" -#: ../../faq/programming.rst:1089 +#: ../../faq/programming.rst:1091 msgid "What is the most efficient way to concatenate many strings together?" msgstr "" -#: ../../faq/programming.rst:1091 +#: ../../faq/programming.rst:1093 msgid "" ":class:`str` and :class:`bytes` objects are immutable, therefore " "concatenating many strings together is inefficient as each concatenation " @@ -1240,38 +1240,38 @@ msgid "" "quadratic in the total string length." msgstr "" -#: ../../faq/programming.rst:1096 +#: ../../faq/programming.rst:1098 msgid "" "To accumulate many :class:`str` objects, the recommended idiom is to place " "them into a list and call :meth:`str.join` at the end::" msgstr "" -#: ../../faq/programming.rst:1104 +#: ../../faq/programming.rst:1106 msgid "(another reasonably efficient idiom is to use :class:`io.StringIO`)" msgstr "" -#: ../../faq/programming.rst:1106 +#: ../../faq/programming.rst:1108 msgid "" "To accumulate many :class:`bytes` objects, the recommended idiom is to " "extend a :class:`bytearray` object using in-place concatenation (the ``+=`` " "operator)::" msgstr "" -#: ../../faq/programming.rst:1115 +#: ../../faq/programming.rst:1117 msgid "Sequences (Tuples/Lists)" msgstr "" -#: ../../faq/programming.rst:1118 +#: ../../faq/programming.rst:1120 msgid "How do I convert between tuples and lists?" msgstr "" -#: ../../faq/programming.rst:1120 +#: ../../faq/programming.rst:1122 msgid "" "The type constructor ``tuple(seq)`` converts any sequence (actually, any " "iterable) into a tuple with the same items in the same order." msgstr "" -#: ../../faq/programming.rst:1123 +#: ../../faq/programming.rst:1125 msgid "" "For example, ``tuple([1, 2, 3])`` yields ``(1, 2, 3)`` and ``tuple('abc')`` " "yields ``('a', 'b', 'c')``. If the argument is a tuple, it does not make a " @@ -1279,7 +1279,7 @@ msgid "" "you aren't sure that an object is already a tuple." msgstr "" -#: ../../faq/programming.rst:1128 +#: ../../faq/programming.rst:1130 msgid "" "The type constructor ``list(seq)`` converts any sequence or iterable into a " "list with the same items in the same order. For example, ``list((1, 2, " @@ -1287,11 +1287,11 @@ msgid "" "If the argument is a list, it makes a copy just like ``seq[:]`` would." msgstr "" -#: ../../faq/programming.rst:1135 +#: ../../faq/programming.rst:1137 msgid "What's a negative index?" msgstr "" -#: ../../faq/programming.rst:1137 +#: ../../faq/programming.rst:1139 msgid "" "Python sequences are indexed with positive numbers and negative numbers. " "For positive numbers 0 is the first index 1 is the second index and so " @@ -1300,62 +1300,62 @@ msgid "" "``seq[len(seq)-n]``." msgstr "" -#: ../../faq/programming.rst:1142 +#: ../../faq/programming.rst:1144 msgid "" "Using negative indices can be very convenient. For example ``S[:-1]`` is " "all of the string except for its last character, which is useful for " "removing the trailing newline from a string." msgstr "" -#: ../../faq/programming.rst:1148 +#: ../../faq/programming.rst:1150 msgid "How do I iterate over a sequence in reverse order?" msgstr "" -#: ../../faq/programming.rst:1150 +#: ../../faq/programming.rst:1152 msgid "Use the :func:`reversed` built-in function::" msgstr "" -#: ../../faq/programming.rst:1155 +#: ../../faq/programming.rst:1157 msgid "" "This won't touch your original sequence, but build a new copy with reversed " "order to iterate over." msgstr "" -#: ../../faq/programming.rst:1160 +#: ../../faq/programming.rst:1162 msgid "How do you remove duplicates from a list?" msgstr "" -#: ../../faq/programming.rst:1162 +#: ../../faq/programming.rst:1164 msgid "See the Python Cookbook for a long discussion of many ways to do this:" msgstr "" -#: ../../faq/programming.rst:1164 +#: ../../faq/programming.rst:1166 msgid "https://code.activestate.com/recipes/52560/" msgstr "https://code.activestate.com/recipes/52560/" -#: ../../faq/programming.rst:1166 +#: ../../faq/programming.rst:1168 msgid "" "If you don't mind reordering the list, sort it and then scan from the end of " "the list, deleting duplicates as you go::" msgstr "" -#: ../../faq/programming.rst:1178 +#: ../../faq/programming.rst:1180 msgid "" "If all elements of the list may be used as set keys (i.e. they are all :term:" "`hashable`) this is often faster ::" msgstr "" -#: ../../faq/programming.rst:1183 +#: ../../faq/programming.rst:1185 msgid "" "This converts the list into a set, thereby removing duplicates, and then " "back into a list." msgstr "" -#: ../../faq/programming.rst:1188 +#: ../../faq/programming.rst:1190 msgid "How do you remove multiple items from a list" msgstr "" -#: ../../faq/programming.rst:1190 +#: ../../faq/programming.rst:1192 msgid "" "As with removing duplicates, explicitly iterating in reverse with a delete " "condition is one possibility. However, it is easier and faster to use slice " @@ -1363,26 +1363,26 @@ msgid "" "variations.::" msgstr "" -#: ../../faq/programming.rst:1199 +#: ../../faq/programming.rst:1201 msgid "The list comprehension may be fastest." msgstr "" -#: ../../faq/programming.rst:1203 +#: ../../faq/programming.rst:1205 msgid "How do you make an array in Python?" msgstr "" -#: ../../faq/programming.rst:1205 +#: ../../faq/programming.rst:1207 msgid "Use a list::" msgstr "" -#: ../../faq/programming.rst:1209 +#: ../../faq/programming.rst:1211 msgid "" "Lists are equivalent to C or Pascal arrays in their time complexity; the " "primary difference is that a Python list can contain objects of many " "different types." msgstr "" -#: ../../faq/programming.rst:1212 +#: ../../faq/programming.rst:1214 msgid "" "The ``array`` module also provides methods for creating arrays of fixed " "types with compact representations, but they are slower to index than " @@ -1390,12 +1390,12 @@ msgid "" "packages define array-like structures with various characteristics as well." msgstr "" -#: ../../faq/programming.rst:1218 +#: ../../faq/programming.rst:1220 msgid "" "To get Lisp-style linked lists, you can emulate *cons cells* using tuples::" msgstr "" -#: ../../faq/programming.rst:1222 +#: ../../faq/programming.rst:1224 msgid "" "If mutability is desired, you could use lists instead of tuples. Here the " "analogue of a Lisp *car* is ``lisp_list[0]`` and the analogue of *cdr* is " @@ -1403,23 +1403,23 @@ msgid "" "it's usually a lot slower than using Python lists." msgstr "" -#: ../../faq/programming.rst:1231 +#: ../../faq/programming.rst:1233 msgid "How do I create a multidimensional list?" msgstr "" -#: ../../faq/programming.rst:1233 +#: ../../faq/programming.rst:1235 msgid "You probably tried to make a multidimensional array like this::" msgstr "" -#: ../../faq/programming.rst:1237 +#: ../../faq/programming.rst:1239 msgid "This looks correct if you print it:" msgstr "" -#: ../../faq/programming.rst:1248 +#: ../../faq/programming.rst:1250 msgid "But when you assign a value, it shows up in multiple places:" msgstr "" -#: ../../faq/programming.rst:1260 +#: ../../faq/programming.rst:1262 msgid "" "The reason is that replicating a list with ``*`` doesn't create copies, it " "only creates references to the existing objects. The ``*3`` creates a list " @@ -1427,64 +1427,64 @@ msgid "" "will show in all rows, which is almost certainly not what you want." msgstr "" -#: ../../faq/programming.rst:1265 +#: ../../faq/programming.rst:1267 msgid "" "The suggested approach is to create a list of the desired length first and " "then fill in each element with a newly created list::" msgstr "" -#: ../../faq/programming.rst:1272 +#: ../../faq/programming.rst:1274 msgid "" "This generates a list containing 3 different lists of length two. You can " "also use a list comprehension::" msgstr "" -#: ../../faq/programming.rst:1278 +#: ../../faq/programming.rst:1280 msgid "" "Or, you can use an extension that provides a matrix datatype; `NumPy " "`_ is the best known." msgstr "" -#: ../../faq/programming.rst:1283 +#: ../../faq/programming.rst:1285 msgid "How do I apply a method or function to a sequence of objects?" msgstr "" -#: ../../faq/programming.rst:1285 +#: ../../faq/programming.rst:1287 msgid "" "To call a method or function and accumulate the return values is a list, a :" "term:`list comprehension` is an elegant solution::" msgstr "" -#: ../../faq/programming.rst:1292 +#: ../../faq/programming.rst:1294 msgid "" "To just run the method or function without saving the return values, a " "plain :keyword:`for` loop will suffice::" msgstr "" -#: ../../faq/programming.rst:1304 +#: ../../faq/programming.rst:1306 msgid "" "Why does a_tuple[i] += ['item'] raise an exception when the addition works?" msgstr "" -#: ../../faq/programming.rst:1306 +#: ../../faq/programming.rst:1308 msgid "" "This is because of a combination of the fact that augmented assignment " "operators are *assignment* operators, and the difference between mutable and " "immutable objects in Python." msgstr "" -#: ../../faq/programming.rst:1310 +#: ../../faq/programming.rst:1312 msgid "" "This discussion applies in general when augmented assignment operators are " "applied to elements of a tuple that point to mutable objects, but we'll use " "a ``list`` and ``+=`` as our exemplar." msgstr "" -#: ../../faq/programming.rst:1314 +#: ../../faq/programming.rst:1316 msgid "If you wrote::" msgstr "" -#: ../../faq/programming.rst:1322 +#: ../../faq/programming.rst:1324 msgid "" "The reason for the exception should be immediately clear: ``1`` is added to " "the object ``a_tuple[0]`` points to (``1``), producing the result object, " @@ -1493,29 +1493,29 @@ msgid "" "an element of a tuple points to." msgstr "" -#: ../../faq/programming.rst:1328 +#: ../../faq/programming.rst:1330 msgid "" "Under the covers, what this augmented assignment statement is doing is " "approximately this::" msgstr "" -#: ../../faq/programming.rst:1337 +#: ../../faq/programming.rst:1339 msgid "" "It is the assignment part of the operation that produces the error, since a " "tuple is immutable." msgstr "" -#: ../../faq/programming.rst:1340 +#: ../../faq/programming.rst:1342 msgid "When you write something like::" msgstr "" -#: ../../faq/programming.rst:1348 +#: ../../faq/programming.rst:1350 msgid "" "The exception is a bit more surprising, and even more surprising is the fact " "that even though there was an error, the append worked::" msgstr "" -#: ../../faq/programming.rst:1354 +#: ../../faq/programming.rst:1356 msgid "" "To see why this happens, you need to know that (a) if an object implements " "an :meth:`~object.__iadd__` magic method, it gets called when the ``+=`` " @@ -1526,14 +1526,14 @@ msgid "" "extend`::" msgstr "" -#: ../../faq/programming.rst:1367 +#: ../../faq/programming.rst:1369 msgid "This is equivalent to::" msgstr "" "這等價於:\n" "\n" "::" -#: ../../faq/programming.rst:1372 +#: ../../faq/programming.rst:1374 msgid "" "The object pointed to by a_list has been mutated, and the pointer to the " "mutated object is assigned back to ``a_list``. The end result of the " @@ -1541,11 +1541,11 @@ msgid "" "``a_list`` was previously pointing to, but the assignment still happens." msgstr "" -#: ../../faq/programming.rst:1377 +#: ../../faq/programming.rst:1379 msgid "Thus, in our tuple example what is happening is equivalent to::" msgstr "" -#: ../../faq/programming.rst:1385 +#: ../../faq/programming.rst:1387 msgid "" "The :meth:`!__iadd__` succeeds, and thus the list is extended, but even " "though ``result`` points to the same object that ``a_tuple[0]`` already " @@ -1553,13 +1553,13 @@ msgid "" "are immutable." msgstr "" -#: ../../faq/programming.rst:1391 +#: ../../faq/programming.rst:1393 msgid "" "I want to do a complicated sort: can you do a Schwartzian Transform in " "Python?" msgstr "" -#: ../../faq/programming.rst:1393 +#: ../../faq/programming.rst:1395 msgid "" "The technique, attributed to Randal Schwartz of the Perl community, sorts " "the elements of a list by a metric which maps each element to its \"sort " @@ -1567,25 +1567,25 @@ msgid "" "method::" msgstr "" -#: ../../faq/programming.rst:1402 +#: ../../faq/programming.rst:1404 msgid "How can I sort one list by values from another list?" msgstr "" -#: ../../faq/programming.rst:1404 +#: ../../faq/programming.rst:1406 msgid "" "Merge them into an iterator of tuples, sort the resulting list, and then " "pick out the element you want. ::" msgstr "" -#: ../../faq/programming.rst:1419 +#: ../../faq/programming.rst:1421 msgid "Objects" msgstr "" -#: ../../faq/programming.rst:1422 +#: ../../faq/programming.rst:1424 msgid "What is a class?" msgstr "" -#: ../../faq/programming.rst:1424 +#: ../../faq/programming.rst:1426 msgid "" "A class is the particular object type created by executing a class " "statement. Class objects are used as templates to create instance objects, " @@ -1593,7 +1593,7 @@ msgid "" "datatype." msgstr "" -#: ../../faq/programming.rst:1428 +#: ../../faq/programming.rst:1430 msgid "" "A class can be based on one or more other classes, called its base " "class(es). It then inherits the attributes and methods of its base classes. " @@ -1603,22 +1603,22 @@ msgid "" "``OutlookMailbox`` that handle various specific mailbox formats." msgstr "" -#: ../../faq/programming.rst:1437 +#: ../../faq/programming.rst:1439 msgid "What is a method?" msgstr "" -#: ../../faq/programming.rst:1439 +#: ../../faq/programming.rst:1441 msgid "" "A method is a function on some object ``x`` that you normally call as ``x." "name(arguments...)``. Methods are defined as functions inside the class " "definition::" msgstr "" -#: ../../faq/programming.rst:1449 +#: ../../faq/programming.rst:1451 msgid "What is self?" msgstr "" -#: ../../faq/programming.rst:1451 +#: ../../faq/programming.rst:1453 msgid "" "Self is merely a conventional name for the first argument of a method. A " "method defined as ``meth(self, a, b, c)`` should be called as ``x.meth(a, b, " @@ -1626,17 +1626,17 @@ msgid "" "the called method will think it is called as ``meth(x, a, b, c)``." msgstr "" -#: ../../faq/programming.rst:1456 +#: ../../faq/programming.rst:1458 msgid "See also :ref:`why-self`." msgstr "另請參閱 :ref:`why-self`\\ 。" -#: ../../faq/programming.rst:1460 +#: ../../faq/programming.rst:1462 msgid "" "How do I check if an object is an instance of a given class or of a subclass " "of it?" msgstr "" -#: ../../faq/programming.rst:1462 +#: ../../faq/programming.rst:1464 msgid "" "Use the built-in function :func:`isinstance(obj, cls) `. You " "can check if an object is an instance of any of a number of classes by " @@ -1646,7 +1646,7 @@ msgid "" "float, complex))``." msgstr "" -#: ../../faq/programming.rst:1469 +#: ../../faq/programming.rst:1471 msgid "" "Note that :func:`isinstance` also checks for virtual inheritance from an :" "term:`abstract base class`. So, the test will return ``True`` for a " @@ -1654,7 +1654,7 @@ msgid "" "To test for \"true inheritance\", scan the :term:`MRO` of the class:" msgstr "" -#: ../../faq/programming.rst:1504 +#: ../../faq/programming.rst:1506 msgid "" "Note that most programs do not use :func:`isinstance` on user-defined " "classes very often. If you are developing the classes yourself, a more " @@ -1664,17 +1664,17 @@ msgid "" "have a function that does something::" msgstr "" -#: ../../faq/programming.rst:1518 +#: ../../faq/programming.rst:1520 msgid "" "A better approach is to define a ``search()`` method on all the classes and " "just call it::" msgstr "" -#: ../../faq/programming.rst:1533 +#: ../../faq/programming.rst:1535 msgid "What is delegation?" msgstr "" -#: ../../faq/programming.rst:1535 +#: ../../faq/programming.rst:1537 msgid "" "Delegation is an object oriented technique (also called a design pattern). " "Let's say you have an object ``x`` and want to change the behaviour of just " @@ -1683,14 +1683,14 @@ msgid "" "other methods to the corresponding method of ``x``." msgstr "" -#: ../../faq/programming.rst:1541 +#: ../../faq/programming.rst:1543 msgid "" "Python programmers can easily implement delegation. For example, the " "following class implements a class that behaves like a file but converts all " "written data to uppercase::" msgstr "" -#: ../../faq/programming.rst:1556 +#: ../../faq/programming.rst:1558 msgid "" "Here the ``UpperOut`` class redefines the ``write()`` method to convert the " "argument string to uppercase before calling the underlying ``self._outfile." @@ -1700,7 +1700,7 @@ msgid "" "access>` for more information about controlling attribute access." msgstr "" -#: ../../faq/programming.rst:1563 +#: ../../faq/programming.rst:1565 msgid "" "Note that for more general cases delegation can get trickier. When " "attributes must be set as well as retrieved, the class must define a :meth:" @@ -1709,24 +1709,24 @@ msgid "" "following::" msgstr "" -#: ../../faq/programming.rst:1574 +#: ../../faq/programming.rst:1576 msgid "" "Most :meth:`!__setattr__` implementations must modify :meth:`self.__dict__ " "` to store local state for self without causing an infinite " "recursion." msgstr "" -#: ../../faq/programming.rst:1580 +#: ../../faq/programming.rst:1582 msgid "" "How do I call a method defined in a base class from a derived class that " "extends it?" msgstr "" -#: ../../faq/programming.rst:1582 +#: ../../faq/programming.rst:1584 msgid "Use the built-in :func:`super` function::" msgstr "" -#: ../../faq/programming.rst:1588 +#: ../../faq/programming.rst:1590 msgid "" "In the example, :func:`super` will automatically determine the instance from " "which it was called (the ``self`` value), look up the :term:`method " @@ -1734,11 +1734,11 @@ msgid "" "line after ``Derived`` in the MRO: ``Base``." msgstr "" -#: ../../faq/programming.rst:1595 +#: ../../faq/programming.rst:1597 msgid "How can I organize my code to make it easier to change the base class?" msgstr "" -#: ../../faq/programming.rst:1597 +#: ../../faq/programming.rst:1599 msgid "" "You could assign the base class to an alias and derive from the alias. Then " "all you have to change is the value assigned to the alias. Incidentally, " @@ -1746,30 +1746,30 @@ msgid "" "on availability of resources) which base class to use. Example::" msgstr "" -#: ../../faq/programming.rst:1612 +#: ../../faq/programming.rst:1614 msgid "How do I create static class data and static class methods?" msgstr "" -#: ../../faq/programming.rst:1614 +#: ../../faq/programming.rst:1616 msgid "" "Both static data and static methods (in the sense of C++ or Java) are " "supported in Python." msgstr "" -#: ../../faq/programming.rst:1617 +#: ../../faq/programming.rst:1619 msgid "" "For static data, simply define a class attribute. To assign a new value to " "the attribute, you have to explicitly use the class name in the assignment::" msgstr "" -#: ../../faq/programming.rst:1629 +#: ../../faq/programming.rst:1631 msgid "" "``c.count`` also refers to ``C.count`` for any ``c`` such that " "``isinstance(c, C)`` holds, unless overridden by ``c`` itself or by some " "class on the base-class search path from ``c.__class__`` back to ``C``." msgstr "" -#: ../../faq/programming.rst:1633 +#: ../../faq/programming.rst:1635 msgid "" "Caution: within a method of C, an assignment like ``self.count = 42`` " "creates a new and unrelated instance named \"count\" in ``self``'s own " @@ -1777,59 +1777,59 @@ msgid "" "whether inside a method or not::" msgstr "" -#: ../../faq/programming.rst:1640 +#: ../../faq/programming.rst:1642 msgid "Static methods are possible::" msgstr "" -#: ../../faq/programming.rst:1648 +#: ../../faq/programming.rst:1650 msgid "" "However, a far more straightforward way to get the effect of a static method " "is via a simple module-level function::" msgstr "" -#: ../../faq/programming.rst:1654 +#: ../../faq/programming.rst:1656 msgid "" "If your code is structured so as to define one class (or tightly related " "class hierarchy) per module, this supplies the desired encapsulation." msgstr "" -#: ../../faq/programming.rst:1659 +#: ../../faq/programming.rst:1661 msgid "How can I overload constructors (or methods) in Python?" msgstr "" -#: ../../faq/programming.rst:1661 +#: ../../faq/programming.rst:1663 msgid "" "This answer actually applies to all methods, but the question usually comes " "up first in the context of constructors." msgstr "" -#: ../../faq/programming.rst:1664 +#: ../../faq/programming.rst:1666 msgid "In C++ you'd write" msgstr "" -#: ../../faq/programming.rst:1673 +#: ../../faq/programming.rst:1675 msgid "" "In Python you have to write a single constructor that catches all cases " "using default arguments. For example::" msgstr "" -#: ../../faq/programming.rst:1683 +#: ../../faq/programming.rst:1685 msgid "This is not entirely equivalent, but close enough in practice." msgstr "" -#: ../../faq/programming.rst:1685 +#: ../../faq/programming.rst:1687 msgid "You could also try a variable-length argument list, e.g. ::" msgstr "" -#: ../../faq/programming.rst:1690 +#: ../../faq/programming.rst:1692 msgid "The same approach works for all method definitions." msgstr "" -#: ../../faq/programming.rst:1694 +#: ../../faq/programming.rst:1696 msgid "I try to use __spam and I get an error about _SomeClassName__spam." msgstr "" -#: ../../faq/programming.rst:1696 +#: ../../faq/programming.rst:1698 msgid "" "Variable names with double leading underscores are \"mangled\" to provide a " "simple but effective way to define class private variables. Any identifier " @@ -1839,7 +1839,7 @@ msgid "" "stripped." msgstr "" -#: ../../faq/programming.rst:1702 +#: ../../faq/programming.rst:1704 msgid "" "This doesn't guarantee privacy: an outside user can still deliberately " "access the \"_classname__spam\" attribute, and private values are visible in " @@ -1847,22 +1847,22 @@ msgid "" "private variable names at all." msgstr "" -#: ../../faq/programming.rst:1709 +#: ../../faq/programming.rst:1711 msgid "My class defines __del__ but it is not called when I delete the object." msgstr "" -#: ../../faq/programming.rst:1711 +#: ../../faq/programming.rst:1713 msgid "There are several possible reasons for this." msgstr "" -#: ../../faq/programming.rst:1713 +#: ../../faq/programming.rst:1715 msgid "" "The :keyword:`del` statement does not necessarily call :meth:`~object." "__del__` -- it simply decrements the object's reference count, and if this " "reaches zero :meth:`!__del__` is called." msgstr "" -#: ../../faq/programming.rst:1717 +#: ../../faq/programming.rst:1719 msgid "" "If your data structures contain circular links (e.g. a tree where each child " "has a parent reference and each parent has a list of children) the reference " @@ -1876,7 +1876,7 @@ msgid "" "cases where objects will never be collected." msgstr "" -#: ../../faq/programming.rst:1728 +#: ../../faq/programming.rst:1730 msgid "" "Despite the cycle collector, it's still a good idea to define an explicit " "``close()`` method on objects to be called whenever you're done with them. " @@ -1886,7 +1886,7 @@ msgid "" "once for the same object." msgstr "" -#: ../../faq/programming.rst:1735 +#: ../../faq/programming.rst:1737 msgid "" "Another way to avoid cyclical references is to use the :mod:`weakref` " "module, which allows you to point to objects without incrementing their " @@ -1894,28 +1894,28 @@ msgid "" "references for their parent and sibling references (if they need them!)." msgstr "" -#: ../../faq/programming.rst:1748 +#: ../../faq/programming.rst:1750 msgid "" "Finally, if your :meth:`!__del__` method raises an exception, a warning " "message is printed to :data:`sys.stderr`." msgstr "" -#: ../../faq/programming.rst:1753 +#: ../../faq/programming.rst:1755 msgid "How do I get a list of all instances of a given class?" msgstr "" -#: ../../faq/programming.rst:1755 +#: ../../faq/programming.rst:1757 msgid "" "Python does not keep track of all instances of a class (or of a built-in " "type). You can program the class's constructor to keep track of all " "instances by keeping a list of weak references to each instance." msgstr "" -#: ../../faq/programming.rst:1761 +#: ../../faq/programming.rst:1763 msgid "Why does the result of ``id()`` appear to be not unique?" msgstr "" -#: ../../faq/programming.rst:1763 +#: ../../faq/programming.rst:1765 msgid "" "The :func:`id` builtin returns an integer that is guaranteed to be unique " "during the lifetime of the object. Since in CPython, this is the object's " @@ -1924,7 +1924,7 @@ msgid "" "memory. This is illustrated by this example:" msgstr "" -#: ../../faq/programming.rst:1774 +#: ../../faq/programming.rst:1776 msgid "" "The two ids belong to different integer objects that are created before, and " "deleted immediately after execution of the ``id()`` call. To be sure that " @@ -1932,17 +1932,17 @@ msgid "" "reference to the object:" msgstr "" -#: ../../faq/programming.rst:1787 +#: ../../faq/programming.rst:1789 msgid "When can I rely on identity tests with the *is* operator?" msgstr "" -#: ../../faq/programming.rst:1789 +#: ../../faq/programming.rst:1791 msgid "" "The ``is`` operator tests for object identity. The test ``a is b`` is " "equivalent to ``id(a) == id(b)``." msgstr "" -#: ../../faq/programming.rst:1792 +#: ../../faq/programming.rst:1794 msgid "" "The most important property of an identity test is that an object is always " "identical to itself, ``a is a`` always returns ``True``. Identity tests are " @@ -1950,34 +1950,34 @@ msgid "" "tests are guaranteed to return a boolean ``True`` or ``False``." msgstr "" -#: ../../faq/programming.rst:1797 +#: ../../faq/programming.rst:1799 msgid "" "However, identity tests can *only* be substituted for equality tests when " "object identity is assured. Generally, there are three circumstances where " "identity is guaranteed:" msgstr "" -#: ../../faq/programming.rst:1801 +#: ../../faq/programming.rst:1803 msgid "" "1) Assignments create new names but do not change object identity. After " "the assignment ``new = old``, it is guaranteed that ``new is old``." msgstr "" -#: ../../faq/programming.rst:1804 +#: ../../faq/programming.rst:1806 msgid "" "2) Putting an object in a container that stores object references does not " "change object identity. After the list assignment ``s[0] = x``, it is " "guaranteed that ``s[0] is x``." msgstr "" -#: ../../faq/programming.rst:1808 +#: ../../faq/programming.rst:1810 msgid "" "3) If an object is a singleton, it means that only one instance of that " "object can exist. After the assignments ``a = None`` and ``b = None``, it " "is guaranteed that ``a is b`` because ``None`` is a singleton." msgstr "" -#: ../../faq/programming.rst:1812 +#: ../../faq/programming.rst:1814 msgid "" "In most other circumstances, identity tests are inadvisable and equality " "tests are preferred. In particular, identity tests should not be used to " @@ -1985,17 +1985,17 @@ msgid "" "guaranteed to be singletons::" msgstr "" -#: ../../faq/programming.rst:1829 +#: ../../faq/programming.rst:1831 msgid "Likewise, new instances of mutable containers are never identical::" msgstr "" -#: ../../faq/programming.rst:1836 +#: ../../faq/programming.rst:1838 msgid "" "In the standard library code, you will see several common patterns for " "correctly using identity tests:" msgstr "" -#: ../../faq/programming.rst:1839 +#: ../../faq/programming.rst:1841 msgid "" "1) As recommended by :pep:`8`, an identity test is the preferred way to " "check for ``None``. This reads like plain English in code and avoids " @@ -2003,7 +2003,7 @@ msgid "" "false." msgstr "" -#: ../../faq/programming.rst:1843 +#: ../../faq/programming.rst:1845 msgid "" "2) Detecting optional arguments can be tricky when ``None`` is a valid input " "value. In those situations, you can create a singleton sentinel object " @@ -2011,25 +2011,25 @@ msgid "" "implement a method that behaves like :meth:`dict.pop`::" msgstr "" -#: ../../faq/programming.rst:1859 +#: ../../faq/programming.rst:1861 msgid "" "3) Container implementations sometimes need to augment equality tests with " "identity tests. This prevents the code from being confused by objects such " "as ``float('NaN')`` that are not equal to themselves." msgstr "" -#: ../../faq/programming.rst:1863 +#: ../../faq/programming.rst:1865 msgid "" "For example, here is the implementation of :meth:`collections.abc.Sequence." "__contains__`::" msgstr "" -#: ../../faq/programming.rst:1874 +#: ../../faq/programming.rst:1876 msgid "" "How can a subclass control what data is stored in an immutable instance?" msgstr "" -#: ../../faq/programming.rst:1876 +#: ../../faq/programming.rst:1878 msgid "" "When subclassing an immutable type, override the :meth:`~object.__new__` " "method instead of the :meth:`~object.__init__` method. The latter only runs " @@ -2037,35 +2037,35 @@ msgid "" "immutable instance." msgstr "" -#: ../../faq/programming.rst:1881 +#: ../../faq/programming.rst:1883 msgid "" "All of these immutable classes have a different signature than their parent " "class:" msgstr "" -#: ../../faq/programming.rst:1907 +#: ../../faq/programming.rst:1909 msgid "The classes can be used like this:" msgstr "" -#: ../../faq/programming.rst:1924 +#: ../../faq/programming.rst:1926 msgid "How do I cache method calls?" msgstr "" -#: ../../faq/programming.rst:1926 +#: ../../faq/programming.rst:1928 msgid "" "The two principal tools for caching methods are :func:`functools." "cached_property` and :func:`functools.lru_cache`. The former stores results " "at the instance level and the latter at the class level." msgstr "" -#: ../../faq/programming.rst:1931 +#: ../../faq/programming.rst:1933 msgid "" "The *cached_property* approach only works with methods that do not take any " "arguments. It does not create a reference to the instance. The cached " "method result will be kept only as long as the instance is alive." msgstr "" -#: ../../faq/programming.rst:1935 +#: ../../faq/programming.rst:1937 msgid "" "The advantage is that when an instance is no longer used, the cached method " "result will be released right away. The disadvantage is that if instances " @@ -2073,47 +2073,47 @@ msgid "" "without bound." msgstr "" -#: ../../faq/programming.rst:1940 +#: ../../faq/programming.rst:1942 msgid "" "The *lru_cache* approach works with methods that have hashable arguments. " "It creates a reference to the instance unless special efforts are made to " "pass in weak references." msgstr "" -#: ../../faq/programming.rst:1944 +#: ../../faq/programming.rst:1946 msgid "" "The advantage of the least recently used algorithm is that the cache is " "bounded by the specified *maxsize*. The disadvantage is that instances are " "kept alive until they age out of the cache or until the cache is cleared." msgstr "" -#: ../../faq/programming.rst:1949 +#: ../../faq/programming.rst:1951 msgid "This example shows the various techniques::" msgstr "" -#: ../../faq/programming.rst:1973 +#: ../../faq/programming.rst:1975 msgid "" "The above example assumes that the *station_id* never changes. If the " "relevant instance attributes are mutable, the *cached_property* approach " "can't be made to work because it cannot detect changes to the attributes." msgstr "" -#: ../../faq/programming.rst:1978 +#: ../../faq/programming.rst:1980 msgid "" "To make the *lru_cache* approach work when the *station_id* is mutable, the " "class needs to define the :meth:`~object.__eq__` and :meth:`~object." "__hash__` methods so that the cache can detect relevant attribute updates::" msgstr "" -#: ../../faq/programming.rst:2004 +#: ../../faq/programming.rst:2006 msgid "Modules" msgstr "模組" -#: ../../faq/programming.rst:2007 +#: ../../faq/programming.rst:2009 msgid "How do I create a .pyc file?" msgstr "" -#: ../../faq/programming.rst:2009 +#: ../../faq/programming.rst:2011 msgid "" "When a module is imported for the first time (or when the source file has " "changed since the current compiled file was created) a ``.pyc`` file " @@ -2124,7 +2124,7 @@ msgid "" "particular ``python`` binary that created it. (See :pep:`3147` for details.)" msgstr "" -#: ../../faq/programming.rst:2017 +#: ../../faq/programming.rst:2019 msgid "" "One reason that a ``.pyc`` file may not be created is a permissions problem " "with the directory containing the source file, meaning that the " @@ -2133,7 +2133,7 @@ msgid "" "testing with a web server." msgstr "" -#: ../../faq/programming.rst:2022 +#: ../../faq/programming.rst:2024 msgid "" "Unless the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable is set, " "creation of a .pyc file is automatic if you're importing a module and Python " @@ -2142,7 +2142,7 @@ msgid "" "subdirectory." msgstr "" -#: ../../faq/programming.rst:2027 +#: ../../faq/programming.rst:2029 msgid "" "Running Python on a top level script is not considered an import and no ``." "pyc`` will be created. For example, if you have a top-level module ``foo." @@ -2152,27 +2152,27 @@ msgid "" "for ``foo`` since ``foo.py`` isn't being imported." msgstr "" -#: ../../faq/programming.rst:2034 +#: ../../faq/programming.rst:2036 msgid "" "If you need to create a ``.pyc`` file for ``foo`` -- that is, to create a ``." "pyc`` file for a module that is not imported -- you can, using the :mod:" "`py_compile` and :mod:`compileall` modules." msgstr "" -#: ../../faq/programming.rst:2038 +#: ../../faq/programming.rst:2040 msgid "" "The :mod:`py_compile` module can manually compile any module. One way is to " "use the ``compile()`` function in that module interactively::" msgstr "" -#: ../../faq/programming.rst:2044 +#: ../../faq/programming.rst:2046 msgid "" "This will write the ``.pyc`` to a ``__pycache__`` subdirectory in the same " "location as ``foo.py`` (or you can override that with the optional parameter " "``cfile``)." msgstr "" -#: ../../faq/programming.rst:2048 +#: ../../faq/programming.rst:2050 msgid "" "You can also automatically compile all files in a directory or directories " "using the :mod:`compileall` module. You can do it from the shell prompt by " @@ -2180,11 +2180,11 @@ msgid "" "Python files to compile::" msgstr "" -#: ../../faq/programming.rst:2057 +#: ../../faq/programming.rst:2059 msgid "How do I find the current module name?" msgstr "" -#: ../../faq/programming.rst:2059 +#: ../../faq/programming.rst:2061 msgid "" "A module can find out its own module name by looking at the predefined " "global variable ``__name__``. If this has the value ``'__main__'``, the " @@ -2193,85 +2193,85 @@ msgid "" "only execute this code after checking ``__name__``::" msgstr "" -#: ../../faq/programming.rst:2074 +#: ../../faq/programming.rst:2076 msgid "How can I have modules that mutually import each other?" msgstr "" -#: ../../faq/programming.rst:2076 +#: ../../faq/programming.rst:2078 msgid "Suppose you have the following modules:" msgstr "" -#: ../../faq/programming.rst:2078 +#: ../../faq/programming.rst:2080 msgid ":file:`foo.py`::" msgstr "" ":file:`foo.py`:\n" "\n" "::" -#: ../../faq/programming.rst:2083 +#: ../../faq/programming.rst:2085 msgid ":file:`bar.py`::" msgstr "" ":file:`bar.py`:\n" "\n" "::" -#: ../../faq/programming.rst:2088 +#: ../../faq/programming.rst:2090 msgid "The problem is that the interpreter will perform the following steps:" msgstr "" -#: ../../faq/programming.rst:2090 +#: ../../faq/programming.rst:2092 msgid "main imports ``foo``" msgstr "" -#: ../../faq/programming.rst:2091 +#: ../../faq/programming.rst:2093 msgid "Empty globals for ``foo`` are created" msgstr "" -#: ../../faq/programming.rst:2092 +#: ../../faq/programming.rst:2094 msgid "``foo`` is compiled and starts executing" msgstr "" -#: ../../faq/programming.rst:2093 +#: ../../faq/programming.rst:2095 msgid "``foo`` imports ``bar``" msgstr "" -#: ../../faq/programming.rst:2094 +#: ../../faq/programming.rst:2096 msgid "Empty globals for ``bar`` are created" msgstr "" -#: ../../faq/programming.rst:2095 +#: ../../faq/programming.rst:2097 msgid "``bar`` is compiled and starts executing" msgstr "" -#: ../../faq/programming.rst:2096 +#: ../../faq/programming.rst:2098 msgid "" "``bar`` imports ``foo`` (which is a no-op since there already is a module " "named ``foo``)" msgstr "" -#: ../../faq/programming.rst:2097 +#: ../../faq/programming.rst:2099 msgid "" "The import mechanism tries to read ``foo_var`` from ``foo`` globals, to set " "``bar.foo_var = foo.foo_var``" msgstr "" -#: ../../faq/programming.rst:2099 +#: ../../faq/programming.rst:2101 msgid "" "The last step fails, because Python isn't done with interpreting ``foo`` yet " "and the global symbol dictionary for ``foo`` is still empty." msgstr "" -#: ../../faq/programming.rst:2102 +#: ../../faq/programming.rst:2104 msgid "" "The same thing happens when you use ``import foo``, and then try to access " "``foo.foo_var`` in global code." msgstr "" -#: ../../faq/programming.rst:2105 +#: ../../faq/programming.rst:2107 msgid "There are (at least) three possible workarounds for this problem." msgstr "" -#: ../../faq/programming.rst:2107 +#: ../../faq/programming.rst:2109 msgid "" "Guido van Rossum recommends avoiding all uses of ``from import ..." "``, and placing all code inside functions. Initializations of global " @@ -2280,59 +2280,59 @@ msgid "" "``.``." msgstr "" -#: ../../faq/programming.rst:2112 +#: ../../faq/programming.rst:2114 msgid "" "Jim Roskind suggests performing steps in the following order in each module:" msgstr "" -#: ../../faq/programming.rst:2114 +#: ../../faq/programming.rst:2116 msgid "" "exports (globals, functions, and classes that don't need imported base " "classes)" msgstr "" -#: ../../faq/programming.rst:2116 +#: ../../faq/programming.rst:2118 msgid "``import`` statements" msgstr "" -#: ../../faq/programming.rst:2117 +#: ../../faq/programming.rst:2119 msgid "" "active code (including globals that are initialized from imported values)." msgstr "" -#: ../../faq/programming.rst:2119 +#: ../../faq/programming.rst:2121 msgid "" "Van Rossum doesn't like this approach much because the imports appear in a " "strange place, but it does work." msgstr "" -#: ../../faq/programming.rst:2122 +#: ../../faq/programming.rst:2124 msgid "" "Matthias Urlichs recommends restructuring your code so that the recursive " "import is not necessary in the first place." msgstr "" -#: ../../faq/programming.rst:2125 +#: ../../faq/programming.rst:2127 msgid "These solutions are not mutually exclusive." msgstr "" -#: ../../faq/programming.rst:2129 +#: ../../faq/programming.rst:2131 msgid "__import__('x.y.z') returns ; how do I get z?" msgstr "" -#: ../../faq/programming.rst:2131 +#: ../../faq/programming.rst:2133 msgid "" "Consider using the convenience function :func:`~importlib.import_module` " "from :mod:`importlib` instead::" msgstr "" -#: ../../faq/programming.rst:2138 +#: ../../faq/programming.rst:2140 msgid "" "When I edit an imported module and reimport it, the changes don't show up. " "Why does this happen?" msgstr "" -#: ../../faq/programming.rst:2140 +#: ../../faq/programming.rst:2142 msgid "" "For reasons of efficiency as well as consistency, Python only reads the " "module file on the first time a module is imported. If it didn't, in a " @@ -2341,13 +2341,13 @@ msgid "" "re-reading of a changed module, do this::" msgstr "" -#: ../../faq/programming.rst:2150 +#: ../../faq/programming.rst:2152 msgid "" "Warning: this technique is not 100% fool-proof. In particular, modules " "containing statements like ::" msgstr "" -#: ../../faq/programming.rst:2155 +#: ../../faq/programming.rst:2157 msgid "" "will continue to work with the old version of the imported objects. If the " "module contains class definitions, existing class instances will *not* be " @@ -2355,7 +2355,7 @@ msgid "" "paradoxical behaviour::" msgstr "" -#: ../../faq/programming.rst:2168 +#: ../../faq/programming.rst:2170 msgid "" "The nature of the problem is made clear if you print out the \"identity\" of " "the class objects::" diff --git a/reference/executionmodel.po b/reference/executionmodel.po index 6ed873d0ef..1cae2001cb 100644 --- a/reference/executionmodel.po +++ b/reference/executionmodel.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-10-15 20:43+0000\n" +"POT-Creation-Date: 2022-12-23 00:16+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-" @@ -177,10 +177,11 @@ msgid "" "bound. This rule is subtle. Python lacks declarations and allows name " "binding operations to occur anywhere within a code block. The local " "variables of a code block can be determined by scanning the entire text of " -"the block for name binding operations." +"the block for name binding operations. See :ref:`the FAQ entry on " +"UnboundLocalError ` for examples." msgstr "" -#: ../../reference/executionmodel.rst:132 +#: ../../reference/executionmodel.rst:134 msgid "" "If the :keyword:`global` statement occurs within a block, all uses of the " "names specified in the statement refer to the bindings of those names in the " @@ -192,7 +193,7 @@ msgid "" "statement must precede all uses of the listed names." msgstr "" -#: ../../reference/executionmodel.rst:141 +#: ../../reference/executionmodel.rst:143 msgid "" "The :keyword:`global` statement has the same scope as a name binding " "operation in the same block. If the nearest enclosing scope for a free " @@ -200,7 +201,7 @@ msgid "" "global." msgstr "" -#: ../../reference/executionmodel.rst:147 +#: ../../reference/executionmodel.rst:149 msgid "" "The :keyword:`nonlocal` statement causes corresponding names to refer to " "previously bound variables in the nearest enclosing function scope. :exc:" @@ -208,13 +209,13 @@ msgid "" "any enclosing function scope." msgstr "" -#: ../../reference/executionmodel.rst:154 +#: ../../reference/executionmodel.rst:156 msgid "" "The namespace for a module is automatically created the first time a module " "is imported. The main module for a script is always called :mod:`__main__`." msgstr "" -#: ../../reference/executionmodel.rst:157 +#: ../../reference/executionmodel.rst:159 msgid "" "Class definition blocks and arguments to :func:`exec` and :func:`eval` are " "special in the context of name resolution. A class definition is an " @@ -228,11 +229,11 @@ msgid "" "that the following will fail::" msgstr "" -#: ../../reference/executionmodel.rst:175 +#: ../../reference/executionmodel.rst:177 msgid "Builtins and restricted execution" msgstr "" -#: ../../reference/executionmodel.rst:181 +#: ../../reference/executionmodel.rst:183 msgid "" "Users should not touch ``__builtins__``; it is strictly an implementation " "detail. Users wanting to override values in the builtins namespace should :" @@ -240,7 +241,7 @@ msgid "" "appropriately." msgstr "" -#: ../../reference/executionmodel.rst:186 +#: ../../reference/executionmodel.rst:188 msgid "" "The builtins namespace associated with the execution of a code block is " "actually found by looking up the name ``__builtins__`` in its global " @@ -251,17 +252,17 @@ msgid "" "`builtins` module itself." msgstr "" -#: ../../reference/executionmodel.rst:198 +#: ../../reference/executionmodel.rst:200 msgid "Interaction with dynamic features" msgstr "" -#: ../../reference/executionmodel.rst:200 +#: ../../reference/executionmodel.rst:202 msgid "" "Name resolution of free variables occurs at runtime, not at compile time. " "This means that the following code will print 42::" msgstr "" -#: ../../reference/executionmodel.rst:211 +#: ../../reference/executionmodel.rst:213 msgid "" "The :func:`eval` and :func:`exec` functions do not have access to the full " "environment for resolving names. Names may be resolved in the local and " @@ -272,11 +273,11 @@ msgid "" "for both." msgstr "" -#: ../../reference/executionmodel.rst:222 +#: ../../reference/executionmodel.rst:224 msgid "Exceptions" msgstr "例外" -#: ../../reference/executionmodel.rst:233 +#: ../../reference/executionmodel.rst:235 msgid "" "Exceptions are a means of breaking out of the normal flow of control of a " "code block in order to handle errors or other exceptional conditions. An " @@ -285,7 +286,7 @@ msgid "" "or indirectly invoked the code block where the error occurred." msgstr "" -#: ../../reference/executionmodel.rst:239 +#: ../../reference/executionmodel.rst:241 msgid "" "The Python interpreter raises an exception when it detects a run-time error " "(such as division by zero). A Python program can also explicitly raise an " @@ -296,7 +297,7 @@ msgid "" "exception occurred or not in the preceding code." msgstr "" -#: ../../reference/executionmodel.rst:249 +#: ../../reference/executionmodel.rst:251 msgid "" "Python uses the \"termination\" model of error handling: an exception " "handler can find out what happened and continue execution at an outer level, " @@ -304,7 +305,7 @@ msgid "" "(except by re-entering the offending piece of code from the top)." msgstr "" -#: ../../reference/executionmodel.rst:256 +#: ../../reference/executionmodel.rst:258 msgid "" "When an exception is not handled at all, the interpreter terminates " "execution of the program, or returns to its interactive main loop. In " @@ -312,7 +313,7 @@ msgid "" "`SystemExit`." msgstr "" -#: ../../reference/executionmodel.rst:260 +#: ../../reference/executionmodel.rst:262 msgid "" "Exceptions are identified by class instances. The :keyword:`except` clause " "is selected depending on the class of the instance: it must reference the " @@ -321,7 +322,7 @@ msgid "" "additional information about the exceptional condition." msgstr "" -#: ../../reference/executionmodel.rst:268 +#: ../../reference/executionmodel.rst:270 msgid "" "Exception messages are not part of the Python API. Their contents may " "change from one version of Python to the next without warning and should not " @@ -329,17 +330,17 @@ msgid "" "interpreter." msgstr "" -#: ../../reference/executionmodel.rst:272 +#: ../../reference/executionmodel.rst:274 msgid "" "See also the description of the :keyword:`try` statement in section :ref:" "`try` and :keyword:`raise` statement in section :ref:`raise`." msgstr "" -#: ../../reference/executionmodel.rst:277 +#: ../../reference/executionmodel.rst:279 msgid "Footnotes" msgstr "註解" -#: ../../reference/executionmodel.rst:278 +#: ../../reference/executionmodel.rst:280 msgid "" "This limitation occurs because the code that is executed by these operations " "is not available at the time the module is compiled."