diff --git a/library/importlib.metadata.po b/library/importlib.metadata.po index d16c580a71..bbd3388ab1 100644 --- a/library/importlib.metadata.po +++ b/library/importlib.metadata.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-10-31 00:09+0000\n" +"POT-Creation-Date: 2022-03-08 14:58+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -339,6 +339,5 @@ msgid "" "method." msgstr "" -#: ../../library/importlib.metadata.rst:340 -msgid "Footnotes" -msgstr "註解" +#~ msgid "Footnotes" +#~ msgstr "註解" diff --git a/library/io.po b/library/io.po index 4b398490d3..7bca2f2cb4 100644 --- a/library/io.po +++ b/library/io.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-12-27 00:19+0000\n" +"POT-Creation-Date: 2022-03-04 18:37+0000\n" "PO-Revision-Date: 2018-05-23 16:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -63,7 +63,7 @@ msgid "" "since :exc:`IOError` is now an alias of :exc:`OSError`." msgstr "" -#: ../../library/io.rst:51 ../../library/io.rst:850 ../../library/io.rst:1112 +#: ../../library/io.rst:51 ../../library/io.rst:848 ../../library/io.rst:1109 msgid "Text I/O" msgstr "" @@ -92,7 +92,7 @@ msgid "" "`TextIOBase`." msgstr "" -#: ../../library/io.rst:72 ../../library/io.rst:1100 +#: ../../library/io.rst:72 ../../library/io.rst:1097 msgid "Binary I/O" msgstr "" @@ -449,19 +449,17 @@ msgid "I/O Base Classes" msgstr "" #: ../../library/io.rst:309 -msgid "" -"The abstract base class for all I/O classes, acting on streams of bytes. " -"There is no public constructor." +msgid "The abstract base class for all I/O classes." msgstr "" -#: ../../library/io.rst:312 +#: ../../library/io.rst:311 msgid "" "This class provides empty abstract implementations for many methods that " "derived classes can override selectively; the default implementations " "represent a file that cannot be read, written or seeked." msgstr "" -#: ../../library/io.rst:317 +#: ../../library/io.rst:316 msgid "" "Even though :class:`IOBase` does not declare :meth:`read` or :meth:`write` " "because their signatures will vary, implementations and clients should " @@ -470,20 +468,20 @@ msgid "" "they do not support are called." msgstr "" -#: ../../library/io.rst:323 +#: ../../library/io.rst:322 msgid "" "The basic type used for binary data read from or written to a file is :class:" "`bytes`. Other :term:`bytes-like objects ` are accepted " "as method arguments too. Text I/O classes work with :class:`str` data." msgstr "" -#: ../../library/io.rst:327 +#: ../../library/io.rst:326 msgid "" "Note that calling any method (even inquiries) on a closed stream is " "undefined. Implementations may raise :exc:`ValueError` in this case." msgstr "" -#: ../../library/io.rst:330 +#: ../../library/io.rst:329 msgid "" ":class:`IOBase` (and its subclasses) supports the iterator protocol, meaning " "that an :class:`IOBase` object can be iterated over yielding the lines in a " @@ -492,140 +490,140 @@ msgid "" "character strings). See :meth:`~IOBase.readline` below." msgstr "" -#: ../../library/io.rst:336 +#: ../../library/io.rst:335 msgid "" ":class:`IOBase` is also a context manager and therefore supports the :" "keyword:`with` statement. In this example, *file* is closed after the :" "keyword:`!with` statement's suite is finished---even if an exception occurs::" msgstr "" -#: ../../library/io.rst:343 +#: ../../library/io.rst:342 msgid ":class:`IOBase` provides these data attributes and methods:" msgstr "" -#: ../../library/io.rst:347 +#: ../../library/io.rst:346 msgid "" "Flush and close this stream. This method has no effect if the file is " "already closed. Once the file is closed, any operation on the file (e.g. " "reading or writing) will raise a :exc:`ValueError`." msgstr "" -#: ../../library/io.rst:351 +#: ../../library/io.rst:350 msgid "" "As a convenience, it is allowed to call this method more than once; only the " "first call, however, will have an effect." msgstr "" -#: ../../library/io.rst:356 +#: ../../library/io.rst:355 msgid "``True`` if the stream is closed." msgstr "" -#: ../../library/io.rst:360 +#: ../../library/io.rst:359 msgid "" "Return the underlying file descriptor (an integer) of the stream if it " "exists. An :exc:`OSError` is raised if the IO object does not use a file " "descriptor." msgstr "" -#: ../../library/io.rst:366 +#: ../../library/io.rst:365 msgid "" "Flush the write buffers of the stream if applicable. This does nothing for " "read-only and non-blocking streams." msgstr "" -#: ../../library/io.rst:371 +#: ../../library/io.rst:370 msgid "" "Return ``True`` if the stream is interactive (i.e., connected to a terminal/" "tty device)." msgstr "" -#: ../../library/io.rst:376 +#: ../../library/io.rst:375 msgid "" "Return ``True`` if the stream can be read from. If ``False``, :meth:`read` " "will raise :exc:`OSError`." msgstr "" -#: ../../library/io.rst:381 +#: ../../library/io.rst:380 msgid "" "Read and return one line from the stream. If *size* is specified, at most " "*size* bytes will be read." msgstr "" -#: ../../library/io.rst:384 +#: ../../library/io.rst:383 msgid "" "The line terminator is always ``b'\\n'`` for binary files; for text files, " "the *newline* argument to :func:`open` can be used to select the line " "terminator(s) recognized." msgstr "" -#: ../../library/io.rst:390 +#: ../../library/io.rst:389 msgid "" "Read and return a list of lines from the stream. *hint* can be specified to " "control the number of lines read: no more lines will be read if the total " "size (in bytes/characters) of all lines so far exceeds *hint*." msgstr "" -#: ../../library/io.rst:394 +#: ../../library/io.rst:393 msgid "" "*hint* values of ``0`` or less, as well as ``None``, are treated as no hint." msgstr "" -#: ../../library/io.rst:397 +#: ../../library/io.rst:396 msgid "" "Note that it's already possible to iterate on file objects using ``for line " "in file: ...`` without calling ``file.readlines()``." msgstr "" -#: ../../library/io.rst:402 +#: ../../library/io.rst:401 msgid "" "Change the stream position to the given byte *offset*. *offset* is " "interpreted relative to the position indicated by *whence*. The default " "value for *whence* is :data:`SEEK_SET`. Values for *whence* are:" msgstr "" -#: ../../library/io.rst:406 +#: ../../library/io.rst:405 msgid "" ":data:`SEEK_SET` or ``0`` -- start of the stream (the default); *offset* " "should be zero or positive" msgstr "" -#: ../../library/io.rst:408 +#: ../../library/io.rst:407 msgid "" ":data:`SEEK_CUR` or ``1`` -- current stream position; *offset* may be " "negative" msgstr "" -#: ../../library/io.rst:410 +#: ../../library/io.rst:409 msgid "" ":data:`SEEK_END` or ``2`` -- end of the stream; *offset* is usually negative" msgstr "" -#: ../../library/io.rst:413 +#: ../../library/io.rst:412 msgid "Return the new absolute position." msgstr "" -#: ../../library/io.rst:415 ../../library/io.rst:926 +#: ../../library/io.rst:414 ../../library/io.rst:923 msgid "The ``SEEK_*`` constants." msgstr "" -#: ../../library/io.rst:418 +#: ../../library/io.rst:417 msgid "" "Some operating systems could support additional values, like :data:`os." "SEEK_HOLE` or :data:`os.SEEK_DATA`. The valid values for a file could depend " "on it being open in text or binary mode." msgstr "" -#: ../../library/io.rst:425 +#: ../../library/io.rst:424 msgid "" "Return ``True`` if the stream supports random access. If ``False``, :meth:" "`seek`, :meth:`tell` and :meth:`truncate` will raise :exc:`OSError`." msgstr "" -#: ../../library/io.rst:430 +#: ../../library/io.rst:429 msgid "Return the current stream position." msgstr "" -#: ../../library/io.rst:434 +#: ../../library/io.rst:433 msgid "" "Resize the stream to the given *size* in bytes (or the current position if " "*size* is not specified). The current stream position isn't changed. This " @@ -634,36 +632,34 @@ msgid "" "additional bytes are zero-filled). The new file size is returned." msgstr "" -#: ../../library/io.rst:441 +#: ../../library/io.rst:440 msgid "Windows will now zero-fill files when extending." msgstr "" -#: ../../library/io.rst:446 +#: ../../library/io.rst:445 msgid "" "Return ``True`` if the stream supports writing. If ``False``, :meth:`write` " "and :meth:`truncate` will raise :exc:`OSError`." msgstr "" -#: ../../library/io.rst:451 +#: ../../library/io.rst:450 msgid "" "Write a list of lines to the stream. Line separators are not added, so it " "is usual for each of the lines provided to have a line separator at the end." msgstr "" -#: ../../library/io.rst:457 +#: ../../library/io.rst:456 msgid "" "Prepare for object destruction. :class:`IOBase` provides a default " "implementation of this method that calls the instance's :meth:`~IOBase." "close` method." msgstr "" -#: ../../library/io.rst:464 -msgid "" -"Base class for raw binary streams. It inherits :class:`IOBase`. There is " -"no public constructor." +#: ../../library/io.rst:463 +msgid "Base class for raw binary streams. It inherits :class:`IOBase`." msgstr "" -#: ../../library/io.rst:467 +#: ../../library/io.rst:465 msgid "" "Raw binary streams typically provide low-level access to an underlying OS " "device or API, and do not try to encapsulate it in high-level primitives " @@ -671,13 +667,13 @@ msgid "" "text streams, described later in this page)." msgstr "" -#: ../../library/io.rst:472 +#: ../../library/io.rst:470 msgid "" ":class:`RawIOBase` provides these methods in addition to those from :class:" "`IOBase`:" msgstr "" -#: ../../library/io.rst:477 +#: ../../library/io.rst:475 msgid "" "Read up to *size* bytes from the object and return them. As a convenience, " "if *size* is unspecified or -1, all bytes until EOF are returned. Otherwise, " @@ -685,25 +681,25 @@ msgid "" "if the operating system call returns fewer than *size* bytes." msgstr "" -#: ../../library/io.rst:482 +#: ../../library/io.rst:480 msgid "" "If 0 bytes are returned, and *size* was not 0, this indicates end of file. " "If the object is in non-blocking mode and no bytes are available, ``None`` " "is returned." msgstr "" -#: ../../library/io.rst:486 +#: ../../library/io.rst:484 msgid "" "The default implementation defers to :meth:`readall` and :meth:`readinto`." msgstr "" -#: ../../library/io.rst:491 +#: ../../library/io.rst:489 msgid "" "Read and return all the bytes from the stream until EOF, using multiple " "calls to the stream if necessary." msgstr "" -#: ../../library/io.rst:496 +#: ../../library/io.rst:494 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b*, and " "return the number of bytes read. For example, *b* might be a :class:" @@ -711,7 +707,7 @@ msgid "" "available, ``None`` is returned." msgstr "" -#: ../../library/io.rst:504 +#: ../../library/io.rst:502 msgid "" "Write the given :term:`bytes-like object`, *b*, to the underlying raw " "stream, and return the number of bytes written. This can be less than the " @@ -722,13 +718,13 @@ msgid "" "the implementation should only access *b* during the method call." msgstr "" -#: ../../library/io.rst:517 +#: ../../library/io.rst:515 msgid "" "Base class for binary streams that support some kind of buffering. It " -"inherits :class:`IOBase`. There is no public constructor." +"inherits :class:`IOBase`." msgstr "" -#: ../../library/io.rst:520 +#: ../../library/io.rst:518 msgid "" "The main difference with :class:`RawIOBase` is that methods :meth:`read`, :" "meth:`readinto` and :meth:`write` will try (respectively) to read as much " @@ -736,7 +732,7 @@ msgid "" "perhaps more than one system call." msgstr "" -#: ../../library/io.rst:525 +#: ../../library/io.rst:523 msgid "" "In addition, those methods can raise :exc:`BlockingIOError` if the " "underlying raw stream is in non-blocking mode and cannot take or give enough " @@ -744,55 +740,55 @@ msgid "" "``None``." msgstr "" -#: ../../library/io.rst:530 +#: ../../library/io.rst:528 msgid "" "Besides, the :meth:`read` method does not have a default implementation that " "defers to :meth:`readinto`." msgstr "" -#: ../../library/io.rst:533 +#: ../../library/io.rst:531 msgid "" "A typical :class:`BufferedIOBase` implementation should not inherit from a :" "class:`RawIOBase` implementation, but wrap one, like :class:`BufferedWriter` " "and :class:`BufferedReader` do." msgstr "" -#: ../../library/io.rst:537 +#: ../../library/io.rst:535 msgid "" ":class:`BufferedIOBase` provides or overrides these data attributes and " "methods in addition to those from :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:542 +#: ../../library/io.rst:540 msgid "" "The underlying raw stream (a :class:`RawIOBase` instance) that :class:" "`BufferedIOBase` deals with. This is not part of the :class:" "`BufferedIOBase` API and may not exist on some implementations." msgstr "" -#: ../../library/io.rst:548 +#: ../../library/io.rst:546 msgid "Separate the underlying raw stream from the buffer and return it." msgstr "" -#: ../../library/io.rst:550 +#: ../../library/io.rst:548 msgid "" "After the raw stream has been detached, the buffer is in an unusable state." msgstr "" -#: ../../library/io.rst:553 +#: ../../library/io.rst:551 msgid "" "Some buffers, like :class:`BytesIO`, do not have the concept of a single raw " "stream to return from this method. They raise :exc:`UnsupportedOperation`." msgstr "" -#: ../../library/io.rst:561 +#: ../../library/io.rst:559 msgid "" "Read and return up to *size* bytes. If the argument is omitted, ``None``, " "or negative, data is read and returned until EOF is reached. An empty :" "class:`bytes` object is returned if the stream is already at EOF." msgstr "" -#: ../../library/io.rst:565 +#: ../../library/io.rst:563 msgid "" "If the argument is positive, and the underlying raw stream is not " "interactive, multiple raw reads may be issued to satisfy the byte count " @@ -801,13 +797,13 @@ msgid "" "imminent." msgstr "" -#: ../../library/io.rst:571 ../../library/io.rst:594 ../../library/io.rst:604 +#: ../../library/io.rst:569 ../../library/io.rst:592 ../../library/io.rst:602 msgid "" "A :exc:`BlockingIOError` is raised if the underlying raw stream is in non " "blocking-mode, and has no data available at the moment." msgstr "" -#: ../../library/io.rst:576 +#: ../../library/io.rst:574 msgid "" "Read and return up to *size* bytes, with at most one call to the underlying " "raw stream's :meth:`~RawIOBase.read` (or :meth:`~RawIOBase.readinto`) " @@ -815,26 +811,26 @@ msgid "" "top of a :class:`BufferedIOBase` object." msgstr "" -#: ../../library/io.rst:582 +#: ../../library/io.rst:580 msgid "" "If *size* is ``-1`` (the default), an arbitrary number of bytes are returned " "(more than zero unless EOF is reached)." msgstr "" -#: ../../library/io.rst:587 +#: ../../library/io.rst:585 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b* and " "return the number of bytes read. For example, *b* might be a :class:" "`bytearray`." msgstr "" -#: ../../library/io.rst:591 +#: ../../library/io.rst:589 msgid "" "Like :meth:`read`, multiple reads may be issued to the underlying raw " "stream, unless the latter is interactive." msgstr "" -#: ../../library/io.rst:599 +#: ../../library/io.rst:597 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b*, " "using at most one call to the underlying raw stream's :meth:`~RawIOBase." @@ -842,7 +838,7 @@ msgid "" "read." msgstr "" -#: ../../library/io.rst:611 +#: ../../library/io.rst:609 msgid "" "Write the given :term:`bytes-like object`, *b*, and return the number of " "bytes written (always equal to the length of *b* in bytes, since if the " @@ -851,41 +847,41 @@ msgid "" "or held in a buffer for performance and latency reasons." msgstr "" -#: ../../library/io.rst:618 +#: ../../library/io.rst:616 msgid "" "When in non-blocking mode, a :exc:`BlockingIOError` is raised if the data " "needed to be written to the raw stream but it couldn't accept all the data " "without blocking." msgstr "" -#: ../../library/io.rst:622 +#: ../../library/io.rst:620 msgid "" "The caller may release or mutate *b* after this method returns, so the " "implementation should only access *b* during the method call." msgstr "" -#: ../../library/io.rst:627 +#: ../../library/io.rst:625 msgid "Raw File I/O" msgstr "" -#: ../../library/io.rst:631 +#: ../../library/io.rst:629 msgid "" "A raw binary stream representing an OS-level file containing bytes data. It " "inherits :class:`RawIOBase`." msgstr "" -#: ../../library/io.rst:634 +#: ../../library/io.rst:632 msgid "The *name* can be one of two things:" msgstr "" -#: ../../library/io.rst:636 +#: ../../library/io.rst:634 msgid "" "a character string or :class:`bytes` object representing the path to the " "file which will be opened. In this case closefd must be ``True`` (the " "default) otherwise an error will be raised." msgstr "" -#: ../../library/io.rst:639 +#: ../../library/io.rst:637 msgid "" "an integer representing the number of an existing OS-level file descriptor " "to which the resulting :class:`FileIO` object will give access. When the " @@ -893,7 +889,7 @@ msgid "" "set to ``False``." msgstr "" -#: ../../library/io.rst:644 +#: ../../library/io.rst:642 msgid "" "The *mode* can be ``'r'``, ``'w'``, ``'x'`` or ``'a'`` for reading " "(default), writing, exclusive creation or appending. The file will be " @@ -904,13 +900,13 @@ msgid "" "``'+'`` to the mode to allow simultaneous reading and writing." msgstr "" -#: ../../library/io.rst:652 +#: ../../library/io.rst:650 msgid "" "The :meth:`read` (when called with a positive argument), :meth:`readinto` " "and :meth:`write` methods on this class will only make one system call." msgstr "" -#: ../../library/io.rst:655 +#: ../../library/io.rst:653 msgid "" "A custom opener can be used by passing a callable as *opener*. The " "underlying file descriptor for the file object is then obtained by calling " @@ -919,372 +915,371 @@ msgid "" "similar to passing ``None``)." msgstr "" -#: ../../library/io.rst:661 +#: ../../library/io.rst:659 msgid "The newly created file is :ref:`non-inheritable `." msgstr "" -#: ../../library/io.rst:663 +#: ../../library/io.rst:661 msgid "" "See the :func:`open` built-in function for examples on using the *opener* " "parameter." msgstr "" -#: ../../library/io.rst:666 +#: ../../library/io.rst:664 msgid "The *opener* parameter was added. The ``'x'`` mode was added." msgstr "" -#: ../../library/io.rst:670 +#: ../../library/io.rst:668 msgid "The file is now non-inheritable." msgstr "" -#: ../../library/io.rst:673 +#: ../../library/io.rst:671 msgid "" ":class:`FileIO` provides these data attributes in addition to those from :" "class:`RawIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:678 +#: ../../library/io.rst:676 msgid "The mode as given in the constructor." msgstr "" -#: ../../library/io.rst:682 +#: ../../library/io.rst:680 msgid "" "The file name. This is the file descriptor of the file when no name is " "given in the constructor." msgstr "" -#: ../../library/io.rst:687 +#: ../../library/io.rst:685 msgid "Buffered Streams" msgstr "" -#: ../../library/io.rst:689 +#: ../../library/io.rst:687 msgid "" "Buffered I/O streams provide a higher-level interface to an I/O device than " "raw I/O does." msgstr "" -#: ../../library/io.rst:694 +#: ../../library/io.rst:692 msgid "" "A binary stream using an in-memory bytes buffer. It inherits :class:" "`BufferedIOBase`. The buffer is discarded when the :meth:`~IOBase.close` " "method is called." msgstr "" -#: ../../library/io.rst:698 +#: ../../library/io.rst:696 msgid "" "The optional argument *initial_bytes* is a :term:`bytes-like object` that " "contains initial data." msgstr "" -#: ../../library/io.rst:701 +#: ../../library/io.rst:699 msgid "" ":class:`BytesIO` provides or overrides these methods in addition to those " "from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:706 +#: ../../library/io.rst:704 msgid "" "Return a readable and writable view over the contents of the buffer without " "copying them. Also, mutating the view will transparently update the " "contents of the buffer::" msgstr "" -#: ../../library/io.rst:717 +#: ../../library/io.rst:715 msgid "" "As long as the view exists, the :class:`BytesIO` object cannot be resized or " "closed." msgstr "" -#: ../../library/io.rst:724 +#: ../../library/io.rst:722 msgid "Return :class:`bytes` containing the entire contents of the buffer." msgstr "" -#: ../../library/io.rst:729 +#: ../../library/io.rst:727 msgid "In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.read`." msgstr "" -#: ../../library/io.rst:731 ../../library/io.rst:774 +#: ../../library/io.rst:729 ../../library/io.rst:772 msgid "The *size* argument is now optional." msgstr "" -#: ../../library/io.rst:736 +#: ../../library/io.rst:734 msgid "" "In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.readinto`." msgstr "" -#: ../../library/io.rst:742 +#: ../../library/io.rst:740 msgid "" "A buffered binary stream providing higher-level access to a readable, non " "seekable :class:`RawIOBase` raw binary stream. It inherits :class:" "`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:746 +#: ../../library/io.rst:744 msgid "" "When reading data from this object, a larger amount of data may be requested " "from the underlying raw stream, and kept in an internal buffer. The buffered " "data can then be returned directly on subsequent reads." msgstr "" -#: ../../library/io.rst:750 +#: ../../library/io.rst:748 msgid "" "The constructor creates a :class:`BufferedReader` for the given readable " "*raw* stream and *buffer_size*. If *buffer_size* is omitted, :data:" "`DEFAULT_BUFFER_SIZE` is used." msgstr "" -#: ../../library/io.rst:754 +#: ../../library/io.rst:752 msgid "" ":class:`BufferedReader` provides or overrides these methods in addition to " "those from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:759 +#: ../../library/io.rst:757 msgid "" "Return bytes from the stream without advancing the position. At most one " "single read on the raw stream is done to satisfy the call. The number of " "bytes returned may be less or more than requested." msgstr "" -#: ../../library/io.rst:765 +#: ../../library/io.rst:763 msgid "" "Read and return *size* bytes, or if *size* is not given or negative, until " "EOF or if the read call would block in non-blocking mode." msgstr "" -#: ../../library/io.rst:770 +#: ../../library/io.rst:768 msgid "" "Read and return up to *size* bytes with only one call on the raw stream. If " "at least one byte is buffered, only buffered bytes are returned. Otherwise, " "one raw stream read call is made." msgstr "" -#: ../../library/io.rst:780 +#: ../../library/io.rst:778 msgid "" "A buffered binary stream providing higher-level access to a writeable, non " "seekable :class:`RawIOBase` raw binary stream. It inherits :class:" "`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:784 +#: ../../library/io.rst:782 msgid "" "When writing to this object, data is normally placed into an internal " "buffer. The buffer will be written out to the underlying :class:`RawIOBase` " "object under various conditions, including:" msgstr "" -#: ../../library/io.rst:788 +#: ../../library/io.rst:786 msgid "when the buffer gets too small for all pending data;" msgstr "" -#: ../../library/io.rst:789 +#: ../../library/io.rst:787 msgid "when :meth:`flush()` is called;" msgstr "" -#: ../../library/io.rst:790 +#: ../../library/io.rst:788 msgid "" "when a :meth:`seek()` is requested (for :class:`BufferedRandom` objects);" msgstr "" -#: ../../library/io.rst:791 +#: ../../library/io.rst:789 msgid "when the :class:`BufferedWriter` object is closed or destroyed." msgstr "" -#: ../../library/io.rst:793 +#: ../../library/io.rst:791 msgid "" "The constructor creates a :class:`BufferedWriter` for the given writeable " "*raw* stream. If the *buffer_size* is not given, it defaults to :data:" "`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:797 +#: ../../library/io.rst:795 msgid "" ":class:`BufferedWriter` provides or overrides these methods in addition to " "those from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:802 +#: ../../library/io.rst:800 msgid "" "Force bytes held in the buffer into the raw stream. A :exc:" "`BlockingIOError` should be raised if the raw stream blocks." msgstr "" -#: ../../library/io.rst:807 +#: ../../library/io.rst:805 msgid "" "Write the :term:`bytes-like object`, *b*, and return the number of bytes " "written. When in non-blocking mode, a :exc:`BlockingIOError` is raised if " "the buffer needs to be written out but the raw stream blocks." msgstr "" -#: ../../library/io.rst:815 +#: ../../library/io.rst:813 msgid "" "A buffered binary stream providing higher-level access to a seekable :class:" "`RawIOBase` raw binary stream. It inherits :class:`BufferedReader` and :" "class:`BufferedWriter`." msgstr "" -#: ../../library/io.rst:819 +#: ../../library/io.rst:817 msgid "" "The constructor creates a reader and writer for a seekable raw stream, given " "in the first argument. If the *buffer_size* is omitted it defaults to :data:" "`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:823 +#: ../../library/io.rst:821 msgid "" ":class:`BufferedRandom` is capable of anything :class:`BufferedReader` or :" "class:`BufferedWriter` can do. In addition, :meth:`seek` and :meth:`tell` " "are guaranteed to be implemented." msgstr "" -#: ../../library/io.rst:830 +#: ../../library/io.rst:828 msgid "" "A buffered binary stream providing higher-level access to two non seekable :" "class:`RawIOBase` raw binary streams---one readable, the other writeable. It " "inherits :class:`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:834 +#: ../../library/io.rst:832 msgid "" "*reader* and *writer* are :class:`RawIOBase` objects that are readable and " "writeable respectively. If the *buffer_size* is omitted it defaults to :" "data:`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:838 +#: ../../library/io.rst:836 msgid "" ":class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\\'s " "methods except for :meth:`~BufferedIOBase.detach`, which raises :exc:" "`UnsupportedOperation`." msgstr "" -#: ../../library/io.rst:844 +#: ../../library/io.rst:842 msgid "" ":class:`BufferedRWPair` does not attempt to synchronize accesses to its " "underlying raw streams. You should not pass it the same object as reader " "and writer; use :class:`BufferedRandom` instead." msgstr "" -#: ../../library/io.rst:854 +#: ../../library/io.rst:852 msgid "" "Base class for text streams. This class provides a character and line based " -"interface to stream I/O. It inherits :class:`IOBase`. There is no public " -"constructor." +"interface to stream I/O. It inherits :class:`IOBase`." msgstr "" -#: ../../library/io.rst:858 +#: ../../library/io.rst:855 msgid "" ":class:`TextIOBase` provides or overrides these data attributes and methods " "in addition to those from :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:863 +#: ../../library/io.rst:860 msgid "" "The name of the encoding used to decode the stream's bytes into strings, and " "to encode strings into bytes." msgstr "" -#: ../../library/io.rst:868 +#: ../../library/io.rst:865 msgid "The error setting of the decoder or encoder." msgstr "" -#: ../../library/io.rst:872 +#: ../../library/io.rst:869 msgid "" "A string, a tuple of strings, or ``None``, indicating the newlines " "translated so far. Depending on the implementation and the initial " "constructor flags, this may not be available." msgstr "" -#: ../../library/io.rst:878 +#: ../../library/io.rst:875 msgid "" "The underlying binary buffer (a :class:`BufferedIOBase` instance) that :" "class:`TextIOBase` deals with. This is not part of the :class:`TextIOBase` " "API and may not exist in some implementations." msgstr "" -#: ../../library/io.rst:884 +#: ../../library/io.rst:881 msgid "" "Separate the underlying binary buffer from the :class:`TextIOBase` and " "return it." msgstr "" -#: ../../library/io.rst:887 +#: ../../library/io.rst:884 msgid "" "After the underlying buffer has been detached, the :class:`TextIOBase` is in " "an unusable state." msgstr "" -#: ../../library/io.rst:890 +#: ../../library/io.rst:887 msgid "" "Some :class:`TextIOBase` implementations, like :class:`StringIO`, may not " "have the concept of an underlying buffer and calling this method will raise :" "exc:`UnsupportedOperation`." msgstr "" -#: ../../library/io.rst:898 +#: ../../library/io.rst:895 msgid "" "Read and return at most *size* characters from the stream as a single :class:" "`str`. If *size* is negative or ``None``, reads until EOF." msgstr "" -#: ../../library/io.rst:903 +#: ../../library/io.rst:900 msgid "" "Read until newline or EOF and return a single ``str``. If the stream is " "already at EOF, an empty string is returned." msgstr "" -#: ../../library/io.rst:906 +#: ../../library/io.rst:903 msgid "If *size* is specified, at most *size* characters will be read." msgstr "" -#: ../../library/io.rst:910 +#: ../../library/io.rst:907 msgid "" "Change the stream position to the given *offset*. Behaviour depends on the " "*whence* parameter. The default value for *whence* is :data:`SEEK_SET`." msgstr "" -#: ../../library/io.rst:914 +#: ../../library/io.rst:911 msgid "" ":data:`SEEK_SET` or ``0``: seek from the start of the stream (the default); " "*offset* must either be a number returned by :meth:`TextIOBase.tell`, or " "zero. Any other *offset* value produces undefined behaviour." msgstr "" -#: ../../library/io.rst:918 +#: ../../library/io.rst:915 msgid "" ":data:`SEEK_CUR` or ``1``: \"seek\" to the current position; *offset* must " "be zero, which is a no-operation (all other values are unsupported)." msgstr "" -#: ../../library/io.rst:921 +#: ../../library/io.rst:918 msgid "" ":data:`SEEK_END` or ``2``: seek to the end of the stream; *offset* must be " "zero (all other values are unsupported)." msgstr "" -#: ../../library/io.rst:924 +#: ../../library/io.rst:921 msgid "Return the new absolute position as an opaque number." msgstr "" -#: ../../library/io.rst:931 +#: ../../library/io.rst:928 msgid "" "Return the current stream position as an opaque number. The number does not " "usually represent a number of bytes in the underlying binary storage." msgstr "" -#: ../../library/io.rst:937 +#: ../../library/io.rst:934 msgid "" "Write the string *s* to the stream and return the number of characters " "written." msgstr "" -#: ../../library/io.rst:944 +#: ../../library/io.rst:941 msgid "" "A buffered text stream providing higher-level access to a :class:" "`BufferedIOBase` buffered binary stream. It inherits :class:`TextIOBase`." msgstr "" -#: ../../library/io.rst:948 +#: ../../library/io.rst:945 msgid "" "*encoding* gives the name of the encoding that the stream will be decoded or " "encoded with. It defaults to :func:`locale.getpreferredencoding(False) " @@ -1293,7 +1288,7 @@ msgid "" "encoding` for more information." msgstr "" -#: ../../library/io.rst:954 +#: ../../library/io.rst:951 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError` " @@ -1308,13 +1303,13 @@ msgid "" "that has been registered with :func:`codecs.register_error` is also valid." msgstr "" -#: ../../library/io.rst:970 +#: ../../library/io.rst:967 msgid "" "*newline* controls how line endings are handled. It can be ``None``, " "``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as follows:" msgstr "" -#: ../../library/io.rst:973 +#: ../../library/io.rst:970 msgid "" "When reading input from the stream, if *newline* is ``None``, :term:" "`universal newlines` mode is enabled. Lines in the input can end in " @@ -1326,7 +1321,7 @@ msgid "" "returned to the caller untranslated." msgstr "" -#: ../../library/io.rst:982 +#: ../../library/io.rst:979 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line separator, :" @@ -1335,24 +1330,24 @@ msgid "" "characters written are translated to the given string." msgstr "" -#: ../../library/io.rst:988 +#: ../../library/io.rst:985 msgid "" "If *line_buffering* is ``True``, :meth:`flush` is implied when a call to " "write contains a newline character or a carriage return." msgstr "" -#: ../../library/io.rst:991 +#: ../../library/io.rst:988 msgid "" "If *write_through* is ``True``, calls to :meth:`write` are guaranteed not to " "be buffered: any data written on the :class:`TextIOWrapper` object is " "immediately handled to its underlying binary *buffer*." msgstr "" -#: ../../library/io.rst:995 +#: ../../library/io.rst:992 msgid "The *write_through* argument has been added." msgstr "" -#: ../../library/io.rst:998 +#: ../../library/io.rst:995 msgid "" "The default *encoding* is now ``locale.getpreferredencoding(False)`` instead " "of ``locale.getpreferredencoding()``. Don't change temporary the locale " @@ -1360,111 +1355,111 @@ msgid "" "instead of the user preferred encoding." msgstr "" -#: ../../library/io.rst:1004 +#: ../../library/io.rst:1001 msgid "" "The *encoding* argument now supports the ``\"locale\"`` dummy encoding name." msgstr "" -#: ../../library/io.rst:1007 +#: ../../library/io.rst:1004 msgid "" ":class:`TextIOWrapper` provides these data attributes and methods in " "addition to those from :class:`TextIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:1012 +#: ../../library/io.rst:1009 msgid "Whether line buffering is enabled." msgstr "" -#: ../../library/io.rst:1016 +#: ../../library/io.rst:1013 msgid "Whether writes are passed immediately to the underlying binary buffer." msgstr "" -#: ../../library/io.rst:1024 +#: ../../library/io.rst:1021 msgid "" "Reconfigure this text stream using new settings for *encoding*, *errors*, " "*newline*, *line_buffering* and *write_through*." msgstr "" -#: ../../library/io.rst:1027 +#: ../../library/io.rst:1024 msgid "" "Parameters not specified keep current settings, except ``errors='strict'`` " "is used when *encoding* is specified but *errors* is not specified." msgstr "" -#: ../../library/io.rst:1031 +#: ../../library/io.rst:1028 msgid "" "It is not possible to change the encoding or newline if some data has " "already been read from the stream. On the other hand, changing encoding " "after write is possible." msgstr "" -#: ../../library/io.rst:1035 +#: ../../library/io.rst:1032 msgid "" "This method does an implicit stream flush before setting the new parameters." msgstr "" -#: ../../library/io.rst:1043 +#: ../../library/io.rst:1040 msgid "" "A text stream using an in-memory text buffer. It inherits :class:" "`TextIOBase`." msgstr "" -#: ../../library/io.rst:1046 +#: ../../library/io.rst:1043 msgid "" "The text buffer is discarded when the :meth:`~IOBase.close` method is called." msgstr "" -#: ../../library/io.rst:1049 +#: ../../library/io.rst:1046 msgid "" "The initial value of the buffer can be set by providing *initial_value*. If " "newline translation is enabled, newlines will be encoded as if by :meth:" "`~TextIOBase.write`. The stream is positioned at the start of the buffer." msgstr "" -#: ../../library/io.rst:1054 +#: ../../library/io.rst:1051 msgid "" "The *newline* argument works like that of :class:`TextIOWrapper`, except " "that when writing output to the stream, if *newline* is ``None``, newlines " "are written as ``\\n`` on all platforms." msgstr "" -#: ../../library/io.rst:1058 +#: ../../library/io.rst:1055 msgid "" ":class:`StringIO` provides this method in addition to those from :class:" "`TextIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:1063 +#: ../../library/io.rst:1060 msgid "" "Return a ``str`` containing the entire contents of the buffer. Newlines are " "decoded as if by :meth:`~TextIOBase.read`, although the stream position is " "not changed." msgstr "" -#: ../../library/io.rst:1067 +#: ../../library/io.rst:1064 msgid "Example usage::" msgstr "" "使用範例:\n" "\n" "::" -#: ../../library/io.rst:1089 +#: ../../library/io.rst:1086 msgid "" "A helper codec that decodes newlines for :term:`universal newlines` mode. It " "inherits :class:`codecs.IncrementalDecoder`." msgstr "" -#: ../../library/io.rst:1094 +#: ../../library/io.rst:1091 msgid "Performance" msgstr "" -#: ../../library/io.rst:1096 +#: ../../library/io.rst:1093 msgid "" "This section discusses the performance of the provided concrete I/O " "implementations." msgstr "" -#: ../../library/io.rst:1102 +#: ../../library/io.rst:1099 msgid "" "By reading and writing only large chunks of data even when the user asks for " "a single byte, buffered I/O hides any inefficiency in calling and executing " @@ -1477,7 +1472,7 @@ msgid "" "data." msgstr "" -#: ../../library/io.rst:1114 +#: ../../library/io.rst:1111 msgid "" "Text I/O over a binary storage (such as a file) is significantly slower than " "binary I/O over the same storage, because it requires conversions between " @@ -1487,23 +1482,23 @@ msgid "" "to the reconstruction algorithm used." msgstr "" -#: ../../library/io.rst:1121 +#: ../../library/io.rst:1118 msgid "" ":class:`StringIO`, however, is a native in-memory unicode container and will " "exhibit similar speed to :class:`BytesIO`." msgstr "" -#: ../../library/io.rst:1125 +#: ../../library/io.rst:1122 msgid "Multi-threading" msgstr "" -#: ../../library/io.rst:1127 +#: ../../library/io.rst:1124 msgid "" ":class:`FileIO` objects are thread-safe to the extent that the operating " "system calls (such as ``read(2)`` under Unix) they wrap are thread-safe too." msgstr "" -#: ../../library/io.rst:1130 +#: ../../library/io.rst:1127 msgid "" "Binary buffered objects (instances of :class:`BufferedReader`, :class:" "`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`) " @@ -1511,15 +1506,15 @@ msgid "" "them from multiple threads at once." msgstr "" -#: ../../library/io.rst:1135 +#: ../../library/io.rst:1132 msgid ":class:`TextIOWrapper` objects are not thread-safe." msgstr "" -#: ../../library/io.rst:1138 +#: ../../library/io.rst:1135 msgid "Reentrancy" msgstr "" -#: ../../library/io.rst:1140 +#: ../../library/io.rst:1137 msgid "" "Binary buffered objects (instances of :class:`BufferedReader`, :class:" "`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`) are " @@ -1530,7 +1525,7 @@ msgid "" "from entering the buffered object." msgstr "" -#: ../../library/io.rst:1148 +#: ../../library/io.rst:1145 msgid "" "The above implicitly extends to text files, since the :func:`open()` " "function will wrap a buffered object inside a :class:`TextIOWrapper`. This " diff --git a/library/threading.po b/library/threading.po index 7d3e48ecc4..82ad0fd7eb 100644 --- a/library/threading.po +++ b/library/threading.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-10-26 16:47+0000\n" +"POT-Creation-Date: 2022-03-05 00:12+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -551,12 +551,12 @@ msgstr "" #: ../../library/threading.rst:431 msgid "" -"A boolean value indicating whether this thread is a daemon thread (True) or " -"not (False). This must be set before :meth:`~Thread.start` is called, " -"otherwise :exc:`RuntimeError` is raised. Its initial value is inherited " -"from the creating thread; the main thread is not a daemon thread and " -"therefore all threads created in the main thread default to :attr:`~Thread." -"daemon` = ``False``." +"A boolean value indicating whether this thread is a daemon thread (``True``) " +"or not (``False``). This must be set before :meth:`~Thread.start` is " +"called, otherwise :exc:`RuntimeError` is raised. Its initial value is " +"inherited from the creating thread; the main thread is not a daemon thread " +"and therefore all threads created in the main thread default to :attr:" +"`~Thread.daemon` = ``False``." msgstr "" #: ../../library/threading.rst:438 @@ -649,7 +649,7 @@ msgid "" "value, block for at most the number of seconds specified by *timeout* and as " "long as the lock cannot be acquired. A *timeout* argument of ``-1`` " "specifies an unbounded wait. It is forbidden to specify a *timeout* when " -"*blocking* is false." +"*blocking* is ``False``." msgstr "" #: ../../library/threading.rst:508 @@ -691,7 +691,7 @@ msgid "There is no return value." msgstr "" #: ../../library/threading.rst:534 -msgid "Return true if the lock is acquired." +msgid "Return ``True`` if the lock is acquired." msgstr "" #: ../../library/threading.rst:541 @@ -752,14 +752,14 @@ msgstr "" #: ../../library/threading.rst:583 msgid "" -"When invoked with the *blocking* argument set to true, do the same thing as " -"when called without arguments, and return ``True``." +"When invoked with the *blocking* argument set to ``True``, do the same thing " +"as when called without arguments, and return ``True``." msgstr "" #: ../../library/threading.rst:586 msgid "" -"When invoked with the *blocking* argument set to false, do not block. If a " -"call without an argument would block, return ``False`` immediately; " +"When invoked with the *blocking* argument set to ``False``, do not block. " +"If a call without an argument would block, return ``False`` immediately; " "otherwise, do the same thing as when called without arguments, and return " "``True``." msgstr "" @@ -769,7 +769,7 @@ msgid "" "When invoked with the floating-point *timeout* argument set to a positive " "value, block for at most the number of seconds specified by *timeout* and as " "long as the lock cannot be acquired. Return ``True`` if the lock has been " -"acquired, false if the timeout has elapsed." +"acquired, ``False`` if the timeout has elapsed." msgstr "" #: ../../library/threading.rst:601 @@ -1072,9 +1072,9 @@ msgstr "" #: ../../library/threading.rst:834 msgid "" -"When invoked with *blocking* set to false, do not block. If a call without " -"an argument would block, return ``False`` immediately; otherwise, do the " -"same thing as when called without arguments, and return ``True``." +"When invoked with *blocking* set to ``False``, do not block. If a call " +"without an argument would block, return ``False`` immediately; otherwise, do " +"the same thing as when called without arguments, and return ``True``." msgstr "" #: ../../library/threading.rst:838 diff --git a/library/typing.po b/library/typing.po index 17dd62a869..873eae31c5 100644 --- a/library/typing.po +++ b/library/typing.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-12-30 00:10+0000\n" +"POT-Creation-Date: 2022-03-08 14:58+0000\n" "PO-Revision-Date: 2018-05-23 16:14+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -53,151 +53,158 @@ msgid "" "arguments." msgstr "" -#: ../../library/typing.rst:38 +#: ../../library/typing.rst:35 +msgid "" +"New features are frequently added to the ``typing`` module. The " +"`typing_extensions `_ package " +"provides backports of these new features to older versions of Python." +msgstr "" + +#: ../../library/typing.rst:42 msgid "Relevant PEPs" msgstr "" -#: ../../library/typing.rst:40 +#: ../../library/typing.rst:44 msgid "" "Since the initial introduction of type hints in :pep:`484` and :pep:`483`, a " "number of PEPs have modified and enhanced Python's framework for type " "annotations. These include:" msgstr "" -#: ../../library/typing.rst:45 +#: ../../library/typing.rst:49 msgid ":pep:`526`: Syntax for Variable Annotations" msgstr "" -#: ../../library/typing.rst:45 +#: ../../library/typing.rst:49 msgid "" "*Introducing* syntax for annotating variables outside of function " "definitions, and :data:`ClassVar`" msgstr "" -#: ../../library/typing.rst:48 +#: ../../library/typing.rst:52 msgid ":pep:`544`: Protocols: Structural subtyping (static duck typing)" msgstr "" -#: ../../library/typing.rst:48 +#: ../../library/typing.rst:52 msgid "" "*Introducing* :class:`Protocol` and the :func:" "`@runtime_checkable` decorator" msgstr "" -#: ../../library/typing.rst:51 +#: ../../library/typing.rst:55 msgid ":pep:`585`: Type Hinting Generics In Standard Collections" msgstr "" -#: ../../library/typing.rst:51 +#: ../../library/typing.rst:55 msgid "" "*Introducing* :class:`types.GenericAlias` and the ability to use standard " "library classes as :ref:`generic types`" msgstr "" -#: ../../library/typing.rst:53 +#: ../../library/typing.rst:57 msgid ":pep:`586`: Literal Types" msgstr "" -#: ../../library/typing.rst:54 +#: ../../library/typing.rst:58 msgid "*Introducing* :data:`Literal`" msgstr "" -#: ../../library/typing.rst:55 +#: ../../library/typing.rst:59 msgid "" ":pep:`589`: TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys" msgstr "" -#: ../../library/typing.rst:56 +#: ../../library/typing.rst:60 msgid "*Introducing* :class:`TypedDict`" msgstr "" -#: ../../library/typing.rst:57 +#: ../../library/typing.rst:61 msgid ":pep:`591`: Adding a final qualifier to typing" msgstr "" -#: ../../library/typing.rst:58 +#: ../../library/typing.rst:62 msgid "*Introducing* :data:`Final` and the :func:`@final` decorator" msgstr "" -#: ../../library/typing.rst:59 +#: ../../library/typing.rst:63 msgid ":pep:`593`: Flexible function and variable annotations" msgstr "" -#: ../../library/typing.rst:60 +#: ../../library/typing.rst:64 msgid "*Introducing* :data:`Annotated`" msgstr "" -#: ../../library/typing.rst:63 +#: ../../library/typing.rst:67 msgid ":pep:`604`: Allow writing union types as ``X | Y``" msgstr "" -#: ../../library/typing.rst:62 +#: ../../library/typing.rst:66 msgid "" "*Introducing* :data:`types.UnionType` and the ability to use the binary-or " "operator ``|`` to signify a :ref:`union of types`" msgstr "" -#: ../../library/typing.rst:65 +#: ../../library/typing.rst:69 msgid ":pep:`612`: Parameter Specification Variables" msgstr "" -#: ../../library/typing.rst:66 +#: ../../library/typing.rst:70 msgid "*Introducing* :class:`ParamSpec` and :data:`Concatenate`" msgstr "" -#: ../../library/typing.rst:67 +#: ../../library/typing.rst:71 msgid ":pep:`613`: Explicit Type Aliases" msgstr "" -#: ../../library/typing.rst:68 +#: ../../library/typing.rst:72 msgid "*Introducing* :data:`TypeAlias`" msgstr "" -#: ../../library/typing.rst:70 +#: ../../library/typing.rst:74 msgid ":pep:`647`: User-Defined Type Guards" msgstr "" -#: ../../library/typing.rst:70 +#: ../../library/typing.rst:74 msgid "*Introducing* :data:`TypeGuard`" msgstr "" -#: ../../library/typing.rst:75 +#: ../../library/typing.rst:79 msgid "Type aliases" msgstr "" -#: ../../library/typing.rst:77 +#: ../../library/typing.rst:81 msgid "" "A type alias is defined by assigning the type to the alias. In this example, " "``Vector`` and ``list[float]`` will be treated as interchangeable synonyms::" msgstr "" -#: ../../library/typing.rst:88 +#: ../../library/typing.rst:92 msgid "" "Type aliases are useful for simplifying complex type signatures. For " "example::" msgstr "" -#: ../../library/typing.rst:106 +#: ../../library/typing.rst:110 msgid "" "Note that ``None`` as a type hint is a special case and is replaced by " "``type(None)``." msgstr "" -#: ../../library/typing.rst:112 +#: ../../library/typing.rst:116 msgid "NewType" msgstr "NewType" -#: ../../library/typing.rst:114 +#: ../../library/typing.rst:118 msgid "Use the :class:`NewType` helper class to create distinct types::" msgstr "" -#: ../../library/typing.rst:121 +#: ../../library/typing.rst:125 msgid "" "The static type checker will treat the new type as if it were a subclass of " "the original type. This is useful in helping catch logical errors::" msgstr "" -#: ../../library/typing.rst:133 +#: ../../library/typing.rst:137 msgid "" "You may still perform all ``int`` operations on a variable of type " "``UserId``, but the result will always be of type ``int``. This lets you " @@ -205,7 +212,7 @@ msgid "" "you from accidentally creating a ``UserId`` in an invalid way::" msgstr "" -#: ../../library/typing.rst:141 +#: ../../library/typing.rst:145 msgid "" "Note that these checks are enforced only by the static type checker. At " "runtime, the statement ``Derived = NewType('Derived', Base)`` will make " @@ -214,31 +221,31 @@ msgid "" "class or introduce much overhead beyond that of a regular function call." msgstr "" -#: ../../library/typing.rst:147 +#: ../../library/typing.rst:151 msgid "" "More precisely, the expression ``some_value is Derived(some_value)`` is " "always true at runtime." msgstr "" -#: ../../library/typing.rst:150 +#: ../../library/typing.rst:154 msgid "It is invalid to create a subtype of ``Derived``::" msgstr "" -#: ../../library/typing.rst:159 +#: ../../library/typing.rst:163 msgid "" "However, it is possible to create a :class:`NewType` based on a 'derived' " "``NewType``::" msgstr "" -#: ../../library/typing.rst:167 +#: ../../library/typing.rst:171 msgid "and typechecking for ``ProUserId`` will work as expected." msgstr "" -#: ../../library/typing.rst:169 +#: ../../library/typing.rst:173 msgid "See :pep:`484` for more details." msgstr "更多細節請見 :pep:`484`\\ 。" -#: ../../library/typing.rst:173 +#: ../../library/typing.rst:177 msgid "" "Recall that the use of a type alias declares two types to be *equivalent* to " "one another. Doing ``Alias = Original`` will make the static type checker " @@ -246,7 +253,7 @@ msgid "" "This is useful when you want to simplify complex type signatures." msgstr "" -#: ../../library/typing.rst:178 +#: ../../library/typing.rst:182 msgid "" "In contrast, ``NewType`` declares one type to be a *subtype* of another. " "Doing ``Derived = NewType('Derived', Original)`` will make the static type " @@ -256,39 +263,39 @@ msgid "" "errors with minimal runtime cost." msgstr "" -#: ../../library/typing.rst:187 +#: ../../library/typing.rst:191 msgid "" "``NewType`` is now a class rather than a function. There is some additional " "runtime cost when calling ``NewType`` over a regular function. However, " "this cost will be reduced in 3.11.0." msgstr "" -#: ../../library/typing.rst:194 +#: ../../library/typing.rst:198 msgid "Callable" msgstr "" -#: ../../library/typing.rst:196 +#: ../../library/typing.rst:200 msgid "" "Frameworks expecting callback functions of specific signatures might be type " "hinted using ``Callable[[Arg1Type, Arg2Type], ReturnType]``." msgstr "" -#: ../../library/typing.rst:199 ../../library/typing.rst:1011 -#: ../../library/typing.rst:2088 +#: ../../library/typing.rst:203 ../../library/typing.rst:1015 +#: ../../library/typing.rst:2092 msgid "For example::" msgstr "" "舉例來說:\n" "\n" "::" -#: ../../library/typing.rst:210 +#: ../../library/typing.rst:214 msgid "" "It is possible to declare the return type of a callable without specifying " "the call signature by substituting a literal ellipsis for the list of " "arguments in the type hint: ``Callable[..., ReturnType]``." msgstr "" -#: ../../library/typing.rst:214 ../../library/typing.rst:701 +#: ../../library/typing.rst:218 ../../library/typing.rst:705 msgid "" "Callables which take other callables as arguments may indicate that their " "parameter types are dependent on each other using :class:`ParamSpec`. " @@ -299,97 +306,97 @@ msgid "" "ReturnType]`` respectively." msgstr "" -#: ../../library/typing.rst:222 ../../library/typing.rst:713 +#: ../../library/typing.rst:226 ../../library/typing.rst:717 msgid "" "``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. See :" "pep:`612` for more information." msgstr "" -#: ../../library/typing.rst:227 +#: ../../library/typing.rst:231 msgid "" "The documentation for :class:`ParamSpec` and :class:`Concatenate` provide " "examples of usage in ``Callable``." msgstr "" -#: ../../library/typing.rst:233 +#: ../../library/typing.rst:237 msgid "Generics" msgstr "" -#: ../../library/typing.rst:235 +#: ../../library/typing.rst:239 msgid "" "Since type information about objects kept in containers cannot be statically " "inferred in a generic way, abstract base classes have been extended to " "support subscription to denote expected types for container elements." msgstr "" -#: ../../library/typing.rst:246 +#: ../../library/typing.rst:250 msgid "" "Generics can be parameterized by using a new factory available in typing " "called :class:`TypeVar`." msgstr "" -#: ../../library/typing.rst:262 +#: ../../library/typing.rst:266 msgid "User-defined generic types" msgstr "" -#: ../../library/typing.rst:264 +#: ../../library/typing.rst:268 msgid "A user-defined class can be defined as a generic class." msgstr "" -#: ../../library/typing.rst:290 +#: ../../library/typing.rst:294 msgid "" "``Generic[T]`` as a base class defines that the class ``LoggedVar`` takes a " "single type parameter ``T`` . This also makes ``T`` valid as a type within " "the class body." msgstr "" -#: ../../library/typing.rst:294 +#: ../../library/typing.rst:298 msgid "" "The :class:`Generic` base class defines :meth:`~object.__class_getitem__` so " "that ``LoggedVar[t]`` is valid as a type::" msgstr "" -#: ../../library/typing.rst:303 +#: ../../library/typing.rst:307 msgid "" "A generic type can have any number of type variables, and type variables may " "be constrained::" msgstr "" -#: ../../library/typing.rst:315 +#: ../../library/typing.rst:319 msgid "" "Each type variable argument to :class:`Generic` must be distinct. This is " "thus invalid::" msgstr "" -#: ../../library/typing.rst:326 +#: ../../library/typing.rst:330 msgid "You can use multiple inheritance with :class:`Generic`::" msgstr "" -#: ../../library/typing.rst:336 +#: ../../library/typing.rst:340 msgid "" "When inheriting from generic classes, some type variables could be fixed::" msgstr "" -#: ../../library/typing.rst:346 +#: ../../library/typing.rst:350 msgid "In this case ``MyDict`` has a single parameter, ``T``." msgstr "" -#: ../../library/typing.rst:348 +#: ../../library/typing.rst:352 msgid "" "Using a generic class without specifying type parameters assumes :data:`Any` " "for each position. In the following example, ``MyIterable`` is not generic " "but implicitly inherits from ``Iterable[Any]``::" msgstr "" -#: ../../library/typing.rst:356 +#: ../../library/typing.rst:360 msgid "User defined generic type aliases are also supported. Examples::" msgstr "" -#: ../../library/typing.rst:373 +#: ../../library/typing.rst:377 msgid ":class:`Generic` no longer has a custom metaclass." msgstr "" -#: ../../library/typing.rst:376 +#: ../../library/typing.rst:380 msgid "" "User-defined generics for parameter expressions are also supported via " "parameter specification variables in the form ``Generic[P]``. The behavior " @@ -399,7 +406,7 @@ msgid "" "used to substitute a :class:`ParamSpec`::" msgstr "" -#: ../../library/typing.rst:393 +#: ../../library/typing.rst:397 msgid "" "Furthermore, a generic with only one parameter specification variable will " "accept parameter lists in the forms ``X[[Type1, Type2, ...]]`` and also " @@ -407,20 +414,20 @@ msgid "" "converted to the former and are thus equivalent::" msgstr "" -#: ../../library/typing.rst:405 +#: ../../library/typing.rst:409 msgid "" "Do note that generics with :class:`ParamSpec` may not have correct " "``__parameters__`` after substitution in some cases because they are " "intended primarily for static type checking." msgstr "" -#: ../../library/typing.rst:409 +#: ../../library/typing.rst:413 msgid "" ":class:`Generic` can now be parameterized over parameter expressions. See :" "class:`ParamSpec` and :pep:`612` for more details." msgstr "" -#: ../../library/typing.rst:413 +#: ../../library/typing.rst:417 msgid "" "A user-defined generic class can have ABCs as base classes without a " "metaclass conflict. Generic metaclasses are not supported. The outcome of " @@ -428,24 +435,24 @@ msgid "" "hashable and comparable for equality." msgstr "" -#: ../../library/typing.rst:420 +#: ../../library/typing.rst:424 msgid "The :data:`Any` type" msgstr ":data:`Any` 型別" -#: ../../library/typing.rst:422 +#: ../../library/typing.rst:426 msgid "" "A special kind of type is :data:`Any`. A static type checker will treat " "every type as being compatible with :data:`Any` and :data:`Any` as being " "compatible with every type." msgstr "" -#: ../../library/typing.rst:426 +#: ../../library/typing.rst:430 msgid "" "This means that it is possible to perform any operation or method call on a " "value of type :data:`Any` and assign it to any variable::" msgstr "" -#: ../../library/typing.rst:444 +#: ../../library/typing.rst:448 msgid "" "Notice that no typechecking is performed when assigning a value of type :" "data:`Any` to a more precise type. For example, the static type checker did " @@ -454,19 +461,19 @@ msgid "" "runtime!" msgstr "" -#: ../../library/typing.rst:450 +#: ../../library/typing.rst:454 msgid "" "Furthermore, all functions without a return type or parameter types will " "implicitly default to using :data:`Any`::" msgstr "" -#: ../../library/typing.rst:463 +#: ../../library/typing.rst:467 msgid "" "This behavior allows :data:`Any` to be used as an *escape hatch* when you " "need to mix dynamically and statically typed code." msgstr "" -#: ../../library/typing.rst:466 +#: ../../library/typing.rst:470 msgid "" "Contrast the behavior of :data:`Any` with the behavior of :class:`object`. " "Similar to :data:`Any`, every type is a subtype of :class:`object`. However, " @@ -474,7 +481,7 @@ msgid "" "subtype of every other type." msgstr "" -#: ../../library/typing.rst:471 +#: ../../library/typing.rst:475 msgid "" "That means when the type of a value is :class:`object`, a type checker will " "reject almost all operations on it, and assigning it to a variable (or using " @@ -482,24 +489,24 @@ msgid "" "example::" msgstr "" -#: ../../library/typing.rst:493 +#: ../../library/typing.rst:497 msgid "" "Use :class:`object` to indicate that a value could be any type in a typesafe " "manner. Use :data:`Any` to indicate that a value is dynamically typed." msgstr "" -#: ../../library/typing.rst:498 +#: ../../library/typing.rst:502 msgid "Nominal vs structural subtyping" msgstr "" -#: ../../library/typing.rst:500 +#: ../../library/typing.rst:504 msgid "" "Initially :pep:`484` defined Python static type system as using *nominal " "subtyping*. This means that a class ``A`` is allowed where a class ``B`` is " "expected if and only if ``A`` is a subclass of ``B``." msgstr "" -#: ../../library/typing.rst:504 +#: ../../library/typing.rst:508 msgid "" "This requirement previously also applied to abstract base classes, such as :" "class:`~collections.abc.Iterable`. The problem with this approach is that a " @@ -508,7 +515,7 @@ msgid "" "code. For example, this conforms to :pep:`484`::" msgstr "" -#: ../../library/typing.rst:517 +#: ../../library/typing.rst:521 msgid "" ":pep:`544` allows to solve this problem by allowing users to write the above " "code without explicit base classes in the class definition, allowing " @@ -517,22 +524,22 @@ msgid "" "subtyping* (or static duck-typing)::" msgstr "" -#: ../../library/typing.rst:533 +#: ../../library/typing.rst:537 msgid "" "Moreover, by subclassing a special class :class:`Protocol`, a user can " "define new custom protocols to fully enjoy structural subtyping (see " "examples below)." msgstr "" -#: ../../library/typing.rst:538 +#: ../../library/typing.rst:542 msgid "Module contents" msgstr "模組內容" -#: ../../library/typing.rst:540 +#: ../../library/typing.rst:544 msgid "The module defines the following classes, functions and decorators." msgstr "" -#: ../../library/typing.rst:544 +#: ../../library/typing.rst:548 msgid "" "This module defines several types that are subclasses of pre-existing " "standard library classes which also extend :class:`Generic` to support type " @@ -540,7 +547,7 @@ msgid "" "corresponding pre-existing classes were enhanced to support ``[]``." msgstr "" -#: ../../library/typing.rst:550 +#: ../../library/typing.rst:554 msgid "" "The redundant types are deprecated as of Python 3.9 but no deprecation " "warnings will be issued by the interpreter. It is expected that type " @@ -548,147 +555,147 @@ msgid "" "Python 3.9 or newer." msgstr "" -#: ../../library/typing.rst:555 +#: ../../library/typing.rst:559 msgid "" "The deprecated types will be removed from the :mod:`typing` module in the " "first Python version released 5 years after the release of Python 3.9.0. See " "details in :pep:`585`—*Type Hinting Generics In Standard Collections*." msgstr "" -#: ../../library/typing.rst:561 +#: ../../library/typing.rst:565 msgid "Special typing primitives" msgstr "" -#: ../../library/typing.rst:564 +#: ../../library/typing.rst:568 msgid "Special types" msgstr "" -#: ../../library/typing.rst:566 +#: ../../library/typing.rst:570 msgid "These can be used as types in annotations and do not support ``[]``." msgstr "" -#: ../../library/typing.rst:570 +#: ../../library/typing.rst:574 msgid "Special type indicating an unconstrained type." msgstr "" -#: ../../library/typing.rst:572 +#: ../../library/typing.rst:576 msgid "Every type is compatible with :data:`Any`." msgstr "" -#: ../../library/typing.rst:573 +#: ../../library/typing.rst:577 msgid ":data:`Any` is compatible with every type." msgstr "" -#: ../../library/typing.rst:577 +#: ../../library/typing.rst:581 msgid "Special type indicating that a function never returns. For example::" msgstr "" -#: ../../library/typing.rst:590 +#: ../../library/typing.rst:594 msgid "" "Special annotation for explicitly declaring a :ref:`type alias `. For example::" msgstr "" -#: ../../library/typing.rst:597 +#: ../../library/typing.rst:601 msgid "See :pep:`613` for more details about explicit type aliases." msgstr "" -#: ../../library/typing.rst:602 +#: ../../library/typing.rst:606 msgid "Special forms" msgstr "" -#: ../../library/typing.rst:604 +#: ../../library/typing.rst:608 msgid "" "These can be used as types in annotations using ``[]``, each having a unique " "syntax." msgstr "" -#: ../../library/typing.rst:608 +#: ../../library/typing.rst:612 msgid "" "Tuple type; ``Tuple[X, Y]`` is the type of a tuple of two items with the " "first item of type X and the second of type Y. The type of the empty tuple " "can be written as ``Tuple[()]``." msgstr "" -#: ../../library/typing.rst:612 +#: ../../library/typing.rst:616 msgid "" "Example: ``Tuple[T1, T2]`` is a tuple of two elements corresponding to type " "variables T1 and T2. ``Tuple[int, float, str]`` is a tuple of an int, a " "float and a string." msgstr "" -#: ../../library/typing.rst:616 +#: ../../library/typing.rst:620 msgid "" "To specify a variable-length tuple of homogeneous type, use literal " "ellipsis, e.g. ``Tuple[int, ...]``. A plain :data:`Tuple` is equivalent to " "``Tuple[Any, ...]``, and in turn to :class:`tuple`." msgstr "" -#: ../../library/typing.rst:620 +#: ../../library/typing.rst:624 msgid "" ":class:`builtins.tuple ` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:626 +#: ../../library/typing.rst:630 msgid "" "Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or " "Y." msgstr "" -#: ../../library/typing.rst:628 +#: ../../library/typing.rst:632 msgid "" "To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | " "str``. Using that shorthand is recommended. Details:" msgstr "" -#: ../../library/typing.rst:630 +#: ../../library/typing.rst:634 msgid "The arguments must be types and there must be at least one." msgstr "" -#: ../../library/typing.rst:632 +#: ../../library/typing.rst:636 msgid "Unions of unions are flattened, e.g.::" msgstr "" -#: ../../library/typing.rst:636 +#: ../../library/typing.rst:640 msgid "Unions of a single argument vanish, e.g.::" msgstr "" -#: ../../library/typing.rst:640 +#: ../../library/typing.rst:644 msgid "Redundant arguments are skipped, e.g.::" msgstr "" -#: ../../library/typing.rst:644 +#: ../../library/typing.rst:648 msgid "When comparing unions, the argument order is ignored, e.g.::" msgstr "" -#: ../../library/typing.rst:648 +#: ../../library/typing.rst:652 msgid "You cannot subclass or instantiate a ``Union``." msgstr "" -#: ../../library/typing.rst:650 +#: ../../library/typing.rst:654 msgid "You cannot write ``Union[X][Y]``." msgstr "" -#: ../../library/typing.rst:652 +#: ../../library/typing.rst:656 msgid "Don't remove explicit subclasses from unions at runtime." msgstr "" -#: ../../library/typing.rst:655 +#: ../../library/typing.rst:659 msgid "" "Unions can now be written as ``X | Y``. See :ref:`union type " "expressions`." msgstr "" -#: ../../library/typing.rst:661 +#: ../../library/typing.rst:665 msgid "Optional type." msgstr "" -#: ../../library/typing.rst:663 +#: ../../library/typing.rst:667 msgid "``Optional[X]`` is equivalent to ``X | None`` (or ``Union[X, None]``)." msgstr "" -#: ../../library/typing.rst:665 +#: ../../library/typing.rst:669 msgid "" "Note that this is not the same concept as an optional argument, which is one " "that has a default. An optional argument with a default does not require " @@ -696,31 +703,31 @@ msgid "" "optional. For example::" msgstr "" -#: ../../library/typing.rst:673 +#: ../../library/typing.rst:677 msgid "" "On the other hand, if an explicit value of ``None`` is allowed, the use of " "``Optional`` is appropriate, whether the argument is optional or not. For " "example::" msgstr "" -#: ../../library/typing.rst:680 +#: ../../library/typing.rst:684 msgid "" "Optional can now be written as ``X | None``. See :ref:`union type " "expressions`." msgstr "" -#: ../../library/typing.rst:686 +#: ../../library/typing.rst:690 msgid "Callable type; ``Callable[[int], str]`` is a function of (int) -> str." msgstr "" -#: ../../library/typing.rst:688 +#: ../../library/typing.rst:692 msgid "" "The subscription syntax must always be used with exactly two values: the " "argument list and the return type. The argument list must be a list of " "types or an ellipsis; the return type must be a single type." msgstr "" -#: ../../library/typing.rst:693 +#: ../../library/typing.rst:697 msgid "" "There is no syntax to indicate optional or keyword arguments; such function " "types are rarely used as callback types. ``Callable[..., ReturnType]`` " @@ -730,19 +737,19 @@ msgid "" "Callable`." msgstr "" -#: ../../library/typing.rst:709 +#: ../../library/typing.rst:713 msgid "" ":class:`collections.abc.Callable` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:718 +#: ../../library/typing.rst:722 msgid "" "The documentation for :class:`ParamSpec` and :class:`Concatenate` provide " "examples of usage with ``Callable``." msgstr "" -#: ../../library/typing.rst:723 +#: ../../library/typing.rst:727 msgid "" "Used with :data:`Callable` and :class:`ParamSpec` to type annotate a higher " "order callable which adds, removes, or transforms parameters of another " @@ -752,7 +759,7 @@ msgid "" "``Concatenate`` must be a :class:`ParamSpec`." msgstr "" -#: ../../library/typing.rst:730 +#: ../../library/typing.rst:734 msgid "" "For example, to annotate a decorator ``with_lock`` which provides a :class:" "`threading.Lock` to the decorated function, ``Concatenate`` can be used to " @@ -763,17 +770,17 @@ msgid "" "passed in::" msgstr "" -#: ../../library/typing.rst:770 ../../library/typing.rst:1190 +#: ../../library/typing.rst:774 ../../library/typing.rst:1194 msgid "" ":pep:`612` -- Parameter Specification Variables (the PEP which introduced " "``ParamSpec`` and ``Concatenate``)." msgstr "" -#: ../../library/typing.rst:772 +#: ../../library/typing.rst:776 msgid ":class:`ParamSpec` and :class:`Callable`." msgstr ":class:`ParamSpec` 和 :class:`Callable`\\ 。" -#: ../../library/typing.rst:777 +#: ../../library/typing.rst:781 msgid "" "A variable annotated with ``C`` may accept a value of type ``C``. In " "contrast, a variable annotated with ``Type[C]`` may accept values that are " @@ -781,11 +788,11 @@ msgid "" "``C``. For example::" msgstr "" -#: ../../library/typing.rst:786 +#: ../../library/typing.rst:790 msgid "Note that ``Type[C]`` is covariant::" msgstr "" -#: ../../library/typing.rst:798 +#: ../../library/typing.rst:802 msgid "" "The fact that ``Type[C]`` is covariant implies that all subclasses of ``C`` " "should implement the same constructor signature and class method signatures " @@ -795,39 +802,39 @@ msgid "" "particular case may change in future revisions of :pep:`484`." msgstr "" -#: ../../library/typing.rst:806 +#: ../../library/typing.rst:810 msgid "" "The only legal parameters for :class:`Type` are classes, :data:`Any`, :ref:" "`type variables `, and unions of any of these types. For example::" msgstr "" -#: ../../library/typing.rst:812 +#: ../../library/typing.rst:816 msgid "" "``Type[Any]`` is equivalent to ``Type`` which in turn is equivalent to " "``type``, which is the root of Python's metaclass hierarchy." msgstr "" -#: ../../library/typing.rst:817 +#: ../../library/typing.rst:821 msgid "" ":class:`builtins.type ` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:823 +#: ../../library/typing.rst:827 msgid "" "A type that can be used to indicate to type checkers that the corresponding " "variable or function parameter has a value equivalent to the provided " "literal (or one of several literals). For example::" msgstr "" -#: ../../library/typing.rst:837 +#: ../../library/typing.rst:841 msgid "" "``Literal[...]`` cannot be subclassed. At runtime, an arbitrary value is " "allowed as type argument to ``Literal[...]``, but type checkers may impose " "restrictions. See :pep:`586` for more details about literal types." msgstr "" -#: ../../library/typing.rst:843 +#: ../../library/typing.rst:847 msgid "" "``Literal`` now de-duplicates parameters. Equality comparisons of " "``Literal`` objects are no longer order dependent. ``Literal`` objects will " @@ -835,22 +842,22 @@ msgid "" "their parameters are not :term:`hashable`." msgstr "" -#: ../../library/typing.rst:851 +#: ../../library/typing.rst:855 msgid "Special type construct to mark class variables." msgstr "" -#: ../../library/typing.rst:853 +#: ../../library/typing.rst:857 msgid "" "As introduced in :pep:`526`, a variable annotation wrapped in ClassVar " "indicates that a given attribute is intended to be used as a class variable " "and should not be set on instances of that class. Usage::" msgstr "" -#: ../../library/typing.rst:861 +#: ../../library/typing.rst:865 msgid ":data:`ClassVar` accepts only types and cannot be further subscribed." msgstr "" -#: ../../library/typing.rst:863 +#: ../../library/typing.rst:867 msgid "" ":data:`ClassVar` is not a class itself, and should not be used with :func:" "`isinstance` or :func:`issubclass`. :data:`ClassVar` does not change Python " @@ -858,19 +865,19 @@ msgid "" "example, a type checker might flag the following code as an error::" msgstr "" -#: ../../library/typing.rst:877 +#: ../../library/typing.rst:881 msgid "" "A special typing construct to indicate to type checkers that a name cannot " "be re-assigned or overridden in a subclass. For example::" msgstr "" -#: ../../library/typing.rst:889 ../../library/typing.rst:1983 +#: ../../library/typing.rst:893 ../../library/typing.rst:1987 msgid "" "There is no runtime checking of these properties. See :pep:`591` for more " "details." msgstr "" -#: ../../library/typing.rst:896 +#: ../../library/typing.rst:900 msgid "" "A type, introduced in :pep:`593` (``Flexible function and variable " "annotations``), to decorate existing types with context-specific metadata " @@ -887,7 +894,7 @@ msgid "" "``x`` within a specific application." msgstr "" -#: ../../library/typing.rst:910 +#: ../../library/typing.rst:914 msgid "" "Ultimately, the responsibility of how to interpret the annotations (if at " "all) is the responsibility of the tool or library encountering the " @@ -896,21 +903,21 @@ msgid "" "using ``isinstance()``)." msgstr "" -#: ../../library/typing.rst:916 +#: ../../library/typing.rst:920 msgid "" "When a tool or a library does not support annotations or encounters an " "unknown annotation it should just ignore it and treat annotated type as the " "underlying type." msgstr "" -#: ../../library/typing.rst:920 +#: ../../library/typing.rst:924 msgid "" "It's up to the tool consuming the annotations to decide whether the client " "is allowed to have several annotations on one type and how to merge those " "annotations." msgstr "" -#: ../../library/typing.rst:924 +#: ../../library/typing.rst:928 msgid "" "Since the ``Annotated`` type allows you to put several annotations of the " "same (or different) type(s) on any node, the tools or libraries consuming " @@ -918,59 +925,59 @@ msgid "" "example, if you are doing value range analysis you might allow this::" msgstr "" -#: ../../library/typing.rst:933 +#: ../../library/typing.rst:937 msgid "" "Passing ``include_extras=True`` to :func:`get_type_hints` lets one access " "the extra annotations at runtime." msgstr "" -#: ../../library/typing.rst:936 +#: ../../library/typing.rst:940 msgid "The details of the syntax:" msgstr "" -#: ../../library/typing.rst:938 +#: ../../library/typing.rst:942 msgid "The first argument to ``Annotated`` must be a valid type" msgstr "" -#: ../../library/typing.rst:940 +#: ../../library/typing.rst:944 msgid "" "Multiple type annotations are supported (``Annotated`` supports variadic " "arguments)::" msgstr "" -#: ../../library/typing.rst:945 +#: ../../library/typing.rst:949 msgid "" "``Annotated`` must be called with at least two arguments " "( ``Annotated[int]`` is not valid)" msgstr "" -#: ../../library/typing.rst:948 +#: ../../library/typing.rst:952 msgid "" "The order of the annotations is preserved and matters for equality checks::" msgstr "" -#: ../../library/typing.rst:955 +#: ../../library/typing.rst:959 msgid "" "Nested ``Annotated`` types are flattened, with metadata ordered starting " "with the innermost annotation::" msgstr "" -#: ../../library/typing.rst:962 +#: ../../library/typing.rst:966 msgid "Duplicated annotations are not removed::" msgstr "" -#: ../../library/typing.rst:968 +#: ../../library/typing.rst:972 msgid "``Annotated`` can be used with nested and generic aliases::" msgstr "" -#: ../../library/typing.rst:981 +#: ../../library/typing.rst:985 msgid "" "Special typing form used to annotate the return type of a user-defined type " "guard function. ``TypeGuard`` only accepts a single type argument. At " "runtime, functions marked this way should return a boolean." msgstr "" -#: ../../library/typing.rst:985 +#: ../../library/typing.rst:989 msgid "" "``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static " "type checkers to determine a more precise type of an expression within a " @@ -979,44 +986,44 @@ msgid "" "conditional expression here is sometimes referred to as a \"type guard\"::" msgstr "" -#: ../../library/typing.rst:1000 +#: ../../library/typing.rst:1004 msgid "" "Sometimes it would be convenient to use a user-defined boolean function as a " "type guard. Such a function should use ``TypeGuard[...]`` as its return " "type to alert static type checkers to this intention." msgstr "" -#: ../../library/typing.rst:1004 +#: ../../library/typing.rst:1008 msgid "" "Using ``-> TypeGuard`` tells the static type checker that for a given " "function:" msgstr "" -#: ../../library/typing.rst:1007 +#: ../../library/typing.rst:1011 msgid "The return value is a boolean." msgstr "" -#: ../../library/typing.rst:1008 +#: ../../library/typing.rst:1012 msgid "" "If the return value is ``True``, the type of its argument is the type inside " "``TypeGuard``." msgstr "" -#: ../../library/typing.rst:1025 +#: ../../library/typing.rst:1029 msgid "" "If ``is_str_list`` is a class or instance method, then the type in " "``TypeGuard`` maps to the type of the second parameter after ``cls`` or " "``self``." msgstr "" -#: ../../library/typing.rst:1029 +#: ../../library/typing.rst:1033 msgid "" "In short, the form ``def foo(arg: TypeA) -> TypeGuard[TypeB]: ...``, means " "that if ``foo(arg)`` returns ``True``, then ``arg`` narrows from ``TypeA`` " "to ``TypeB``." msgstr "" -#: ../../library/typing.rst:1035 +#: ../../library/typing.rst:1039 msgid "" "``TypeB`` need not be a narrower form of ``TypeA`` -- it can even be a wider " "form. The main reason is to allow for things like narrowing ``List[object]`` " @@ -1025,50 +1032,50 @@ msgid "" "guards is left to the user." msgstr "" -#: ../../library/typing.rst:1041 +#: ../../library/typing.rst:1045 msgid "" "``TypeGuard`` also works with type variables. For more information, see :" "pep:`647` (User-Defined Type Guards)." msgstr "" -#: ../../library/typing.rst:1048 +#: ../../library/typing.rst:1052 msgid "Building generic types" msgstr "" -#: ../../library/typing.rst:1050 +#: ../../library/typing.rst:1054 msgid "" "These are not used in annotations. They are building blocks for creating " "generic types." msgstr "" -#: ../../library/typing.rst:1054 +#: ../../library/typing.rst:1058 msgid "Abstract base class for generic types." msgstr "" -#: ../../library/typing.rst:1056 +#: ../../library/typing.rst:1060 msgid "" "A generic type is typically declared by inheriting from an instantiation of " "this class with one or more type variables. For example, a generic mapping " "type might be defined as::" msgstr "" -#: ../../library/typing.rst:1065 +#: ../../library/typing.rst:1069 msgid "This class can then be used as follows::" msgstr "" -#: ../../library/typing.rst:1078 +#: ../../library/typing.rst:1082 msgid "Type variable." msgstr "" -#: ../../library/typing.rst:1080 ../../library/typing.rst:1119 -#: ../../library/typing.rst:1296 +#: ../../library/typing.rst:1084 ../../library/typing.rst:1123 +#: ../../library/typing.rst:1300 msgid "Usage::" msgstr "" "用法:\n" "\n" "::" -#: ../../library/typing.rst:1085 +#: ../../library/typing.rst:1089 msgid "" "Type variables exist primarily for the benefit of static type checkers. " "They serve as the parameters for generic types as well as for generic " @@ -1076,7 +1083,7 @@ msgid "" "types. Generic functions work as follows::" msgstr "" -#: ../../library/typing.rst:1098 +#: ../../library/typing.rst:1102 msgid "" "The latter example's signature is essentially the overloading of ``(str, " "str) -> str`` and ``(bytes, bytes) -> bytes``. Also note that if the " @@ -1084,13 +1091,13 @@ msgid "" "still plain :class:`str`." msgstr "" -#: ../../library/typing.rst:1103 +#: ../../library/typing.rst:1107 msgid "" "At runtime, ``isinstance(x, T)`` will raise :exc:`TypeError`. In general, :" "func:`isinstance` and :func:`issubclass` should not be used with types." msgstr "" -#: ../../library/typing.rst:1106 +#: ../../library/typing.rst:1110 msgid "" "Type variables may be marked covariant or contravariant by passing " "``covariant=True`` or ``contravariant=True``. See :pep:`484` for more " @@ -1100,13 +1107,13 @@ msgid "" "must be a subclass of the boundary type, see :pep:`484`." msgstr "" -#: ../../library/typing.rst:1116 +#: ../../library/typing.rst:1120 msgid "" "Parameter specification variable. A specialized version of :class:`type " "variables `." msgstr "" -#: ../../library/typing.rst:1123 +#: ../../library/typing.rst:1127 msgid "" "Parameter specification variables exist primarily for the benefit of static " "type checkers. They are used to forward the parameter types of one callable " @@ -1116,7 +1123,7 @@ msgid "" "See :class:`Generic` for more information on generic types." msgstr "" -#: ../../library/typing.rst:1130 +#: ../../library/typing.rst:1134 msgid "" "For example, to add basic logging to a function, one can create a decorator " "``add_logging`` to log function calls. The parameter specification variable " @@ -1124,27 +1131,27 @@ msgid "" "new callable returned by it have inter-dependent type parameters::" msgstr "" -#: ../../library/typing.rst:1154 +#: ../../library/typing.rst:1158 msgid "" "Without ``ParamSpec``, the simplest way to annotate this previously was to " "use a :class:`TypeVar` with bound ``Callable[..., Any]``. However this " "causes two problems:" msgstr "" -#: ../../library/typing.rst:1158 +#: ../../library/typing.rst:1162 msgid "" "The type checker can't type check the ``inner`` function because ``*args`` " "and ``**kwargs`` have to be typed :data:`Any`." msgstr "" -#: ../../library/typing.rst:1160 +#: ../../library/typing.rst:1164 msgid "" ":func:`~cast` may be required in the body of the ``add_logging`` decorator " "when returning the ``inner`` function, or the static type checker must be " "told to ignore the ``return inner``." msgstr "" -#: ../../library/typing.rst:1167 +#: ../../library/typing.rst:1171 msgid "" "Since ``ParamSpec`` captures both positional and keyword parameters, ``P." "args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its " @@ -1157,7 +1164,7 @@ msgid "" "`ParamSpecKwargs`." msgstr "" -#: ../../library/typing.rst:1177 +#: ../../library/typing.rst:1181 msgid "" "Parameter specification variables created with ``covariant=True`` or " "``contravariant=True`` can be used to declare covariant or contravariant " @@ -1166,17 +1173,17 @@ msgid "" "decided." msgstr "" -#: ../../library/typing.rst:1186 +#: ../../library/typing.rst:1190 msgid "" "Only parameter specification variables defined in global scope can be " "pickled." msgstr "" -#: ../../library/typing.rst:1192 +#: ../../library/typing.rst:1196 msgid ":class:`Callable` and :class:`Concatenate`." msgstr ":class:`Callable` 和 :class:`Concatenate`\\ 。" -#: ../../library/typing.rst:1197 +#: ../../library/typing.rst:1201 msgid "" "Arguments and keyword arguments attributes of a :class:`ParamSpec`. The ``P." "args`` attribute of a ``ParamSpec`` is an instance of ``ParamSpecArgs``, and " @@ -1184,36 +1191,36 @@ msgid "" "runtime introspection and have no special meaning to static type checkers." msgstr "" -#: ../../library/typing.rst:1202 +#: ../../library/typing.rst:1206 msgid "" "Calling :func:`get_origin` on either of these objects will return the " "original ``ParamSpec``::" msgstr "" -#: ../../library/typing.rst:1214 +#: ../../library/typing.rst:1218 msgid "" "``AnyStr`` is a type variable defined as ``AnyStr = TypeVar('AnyStr', str, " "bytes)``." msgstr "" -#: ../../library/typing.rst:1217 +#: ../../library/typing.rst:1221 msgid "" "It is meant to be used for functions that may accept any kind of string " "without allowing different kinds of strings to mix. For example::" msgstr "" -#: ../../library/typing.rst:1229 +#: ../../library/typing.rst:1233 msgid "" "Base class for protocol classes. Protocol classes are defined like this::" msgstr "" -#: ../../library/typing.rst:1235 +#: ../../library/typing.rst:1239 msgid "" "Such classes are primarily used with static type checkers that recognize " "structural subtyping (static duck-typing), for example::" msgstr "" -#: ../../library/typing.rst:1247 +#: ../../library/typing.rst:1251 msgid "" "See :pep:`544` for details. Protocol classes decorated with :func:" "`runtime_checkable` (described later) act as simple-minded runtime protocols " @@ -1221,15 +1228,15 @@ msgid "" "signatures." msgstr "" -#: ../../library/typing.rst:1252 +#: ../../library/typing.rst:1256 msgid "Protocol classes can be generic, for example::" msgstr "" -#: ../../library/typing.rst:1262 +#: ../../library/typing.rst:1266 msgid "Mark a protocol class as a runtime protocol." msgstr "" -#: ../../library/typing.rst:1264 +#: ../../library/typing.rst:1268 msgid "" "Such a protocol can be used with :func:`isinstance` and :func:`issubclass`. " "This raises :exc:`TypeError` when applied to a non-protocol class. This " @@ -1238,7 +1245,7 @@ msgid "" "For example::" msgstr "" -#: ../../library/typing.rst:1277 +#: ../../library/typing.rst:1281 msgid "" ":func:`runtime_checkable` will check only the presence of the required " "methods, not their type signatures. For example, :class:`ssl.SSLObject` is a " @@ -1248,38 +1255,38 @@ msgid "" "making it impossible to call (instantiate) :class:`ssl.SSLObject`." msgstr "" -#: ../../library/typing.rst:1288 +#: ../../library/typing.rst:1292 msgid "Other special directives" msgstr "" -#: ../../library/typing.rst:1290 +#: ../../library/typing.rst:1294 msgid "" "These are not used in annotations. They are building blocks for declaring " "types." msgstr "" -#: ../../library/typing.rst:1294 +#: ../../library/typing.rst:1298 msgid "Typed version of :func:`collections.namedtuple`." msgstr "" -#: ../../library/typing.rst:1302 +#: ../../library/typing.rst:1306 msgid "This is equivalent to::" msgstr "" "這等價於:\n" "\n" "::" -#: ../../library/typing.rst:1306 +#: ../../library/typing.rst:1310 msgid "" "To give a field a default value, you can assign to it in the class body::" msgstr "" -#: ../../library/typing.rst:1315 +#: ../../library/typing.rst:1319 msgid "" "Fields with a default value must come after any fields without a default." msgstr "" -#: ../../library/typing.rst:1317 +#: ../../library/typing.rst:1321 msgid "" "The resulting class has an extra attribute ``__annotations__`` giving a dict " "that maps the field names to the field types. (The field names are in the " @@ -1287,52 +1294,52 @@ msgid "" "attribute both of which are part of the namedtuple API.)" msgstr "" -#: ../../library/typing.rst:1323 +#: ../../library/typing.rst:1327 msgid "``NamedTuple`` subclasses can also have docstrings and methods::" msgstr "" -#: ../../library/typing.rst:1333 +#: ../../library/typing.rst:1337 msgid "Backward-compatible usage::" msgstr "" -#: ../../library/typing.rst:1337 +#: ../../library/typing.rst:1341 msgid "Added support for :pep:`526` variable annotation syntax." msgstr "" -#: ../../library/typing.rst:1340 +#: ../../library/typing.rst:1344 msgid "Added support for default values, methods, and docstrings." msgstr "" -#: ../../library/typing.rst:1343 +#: ../../library/typing.rst:1347 msgid "" "The ``_field_types`` and ``__annotations__`` attributes are now regular " "dictionaries instead of instances of ``OrderedDict``." msgstr "" -#: ../../library/typing.rst:1347 +#: ../../library/typing.rst:1351 msgid "" "Removed the ``_field_types`` attribute in favor of the more standard " "``__annotations__`` attribute which has the same information." msgstr "" -#: ../../library/typing.rst:1353 +#: ../../library/typing.rst:1357 msgid "" "A helper class to indicate a distinct type to a typechecker, see :ref:" "`distinct`. At runtime it returns an object that returns its argument when " "called. Usage::" msgstr "" -#: ../../library/typing.rst:1363 +#: ../../library/typing.rst:1367 msgid "``NewType`` is now a class rather than a function." msgstr "" -#: ../../library/typing.rst:1368 +#: ../../library/typing.rst:1372 msgid "" "Special construct to add type hints to a dictionary. At runtime it is a " "plain :class:`dict`." msgstr "" -#: ../../library/typing.rst:1371 +#: ../../library/typing.rst:1375 msgid "" "``TypedDict`` declares a dictionary type that expects all of its instances " "to have a certain set of keys, where each key is associated with a value of " @@ -1340,7 +1347,7 @@ msgid "" "enforced by type checkers. Usage::" msgstr "" -#: ../../library/typing.rst:1387 +#: ../../library/typing.rst:1391 msgid "" "The type info for introspection can be accessed via ``Point2D." "__annotations__``, ``Point2D.__total__``, ``Point2D.__required_keys__``, and " @@ -1349,13 +1356,13 @@ msgid "" "two additional equivalent syntactic forms::" msgstr "" -#: ../../library/typing.rst:1397 +#: ../../library/typing.rst:1401 msgid "" "By default, all keys must be present in a ``TypedDict``. It is possible to " "override this by specifying totality. Usage::" msgstr "" -#: ../../library/typing.rst:1405 +#: ../../library/typing.rst:1409 msgid "" "This means that a ``Point2D`` ``TypedDict`` can have any of the keys " "omitted. A type checker is only expected to support a literal ``False`` or " @@ -1363,152 +1370,152 @@ msgid "" "and makes all items defined in the class body required." msgstr "" -#: ../../library/typing.rst:1410 +#: ../../library/typing.rst:1414 msgid "" "See :pep:`589` for more examples and detailed rules of using ``TypedDict``." msgstr "" -#: ../../library/typing.rst:1415 +#: ../../library/typing.rst:1419 msgid "Generic concrete collections" msgstr "" -#: ../../library/typing.rst:1418 +#: ../../library/typing.rst:1422 msgid "Corresponding to built-in types" msgstr "" -#: ../../library/typing.rst:1422 +#: ../../library/typing.rst:1426 msgid "" "A generic version of :class:`dict`. Useful for annotating return types. To " "annotate arguments it is preferred to use an abstract collection type such " "as :class:`Mapping`." msgstr "" -#: ../../library/typing.rst:1426 +#: ../../library/typing.rst:1430 msgid "This type can be used as follows::" msgstr "" -#: ../../library/typing.rst:1431 +#: ../../library/typing.rst:1435 msgid "" ":class:`builtins.dict ` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1437 +#: ../../library/typing.rst:1441 msgid "" "Generic version of :class:`list`. Useful for annotating return types. To " "annotate arguments it is preferred to use an abstract collection type such " "as :class:`Sequence` or :class:`Iterable`." msgstr "" -#: ../../library/typing.rst:1442 +#: ../../library/typing.rst:1446 msgid "This type may be used as follows::" msgstr "" -#: ../../library/typing.rst:1452 +#: ../../library/typing.rst:1456 msgid "" ":class:`builtins.list ` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1458 +#: ../../library/typing.rst:1462 msgid "" "A generic version of :class:`builtins.set `. Useful for annotating " "return types. To annotate arguments it is preferred to use an abstract " "collection type such as :class:`AbstractSet`." msgstr "" -#: ../../library/typing.rst:1462 +#: ../../library/typing.rst:1466 msgid "" ":class:`builtins.set ` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1468 +#: ../../library/typing.rst:1472 msgid "A generic version of :class:`builtins.frozenset `." msgstr "" -#: ../../library/typing.rst:1470 +#: ../../library/typing.rst:1474 msgid "" ":class:`builtins.frozenset ` now supports ``[]``. See :pep:`585` " "and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1474 +#: ../../library/typing.rst:1478 msgid ":data:`Tuple` is a special form." msgstr "" -#: ../../library/typing.rst:1477 +#: ../../library/typing.rst:1481 msgid "Corresponding to types in :mod:`collections`" msgstr "" -#: ../../library/typing.rst:1481 +#: ../../library/typing.rst:1485 msgid "A generic version of :class:`collections.defaultdict`." msgstr "" -#: ../../library/typing.rst:1485 +#: ../../library/typing.rst:1489 msgid "" ":class:`collections.defaultdict` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1491 +#: ../../library/typing.rst:1495 msgid "A generic version of :class:`collections.OrderedDict`." msgstr "" -#: ../../library/typing.rst:1495 +#: ../../library/typing.rst:1499 msgid "" ":class:`collections.OrderedDict` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1501 +#: ../../library/typing.rst:1505 msgid "A generic version of :class:`collections.ChainMap`." msgstr "" -#: ../../library/typing.rst:1506 +#: ../../library/typing.rst:1510 msgid "" ":class:`collections.ChainMap` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1512 +#: ../../library/typing.rst:1516 msgid "A generic version of :class:`collections.Counter`." msgstr "" -#: ../../library/typing.rst:1517 +#: ../../library/typing.rst:1521 msgid "" ":class:`collections.Counter` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1523 +#: ../../library/typing.rst:1527 msgid "A generic version of :class:`collections.deque`." msgstr "" -#: ../../library/typing.rst:1528 +#: ../../library/typing.rst:1532 msgid "" ":class:`collections.deque` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1533 +#: ../../library/typing.rst:1537 msgid "Other concrete types" msgstr "" -#: ../../library/typing.rst:1539 +#: ../../library/typing.rst:1543 msgid "" "Generic type ``IO[AnyStr]`` and its subclasses ``TextIO(IO[str])`` and " "``BinaryIO(IO[bytes])`` represent the types of I/O streams such as returned " "by :func:`open`." msgstr "" -#: ../../library/typing.rst:1546 +#: ../../library/typing.rst:1550 msgid "" "The ``typing.io`` namespace is deprecated and will be removed. These types " "should be directly imported from ``typing`` instead." msgstr "" -#: ../../library/typing.rst:1551 +#: ../../library/typing.rst:1555 msgid "" "These type aliases correspond to the return types from :func:`re.compile` " "and :func:`re.match`. These types (and the corresponding functions) are " @@ -1516,413 +1523,413 @@ msgid "" "``Pattern[bytes]``, ``Match[str]``, or ``Match[bytes]``." msgstr "" -#: ../../library/typing.rst:1561 +#: ../../library/typing.rst:1565 msgid "" "The ``typing.re`` namespace is deprecated and will be removed. These types " "should be directly imported from ``typing`` instead." msgstr "" -#: ../../library/typing.rst:1562 +#: ../../library/typing.rst:1566 msgid "" "Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1568 +#: ../../library/typing.rst:1572 msgid "" "``Text`` is an alias for ``str``. It is provided to supply a forward " "compatible path for Python 2 code: in Python 2, ``Text`` is an alias for " "``unicode``." msgstr "" -#: ../../library/typing.rst:1572 +#: ../../library/typing.rst:1576 msgid "" "Use ``Text`` to indicate that a value must contain a unicode string in a " "manner that is compatible with both Python 2 and Python 3::" msgstr "" -#: ../../library/typing.rst:1581 +#: ../../library/typing.rst:1585 msgid "Abstract Base Classes" msgstr "" -#: ../../library/typing.rst:1584 +#: ../../library/typing.rst:1588 msgid "Corresponding to collections in :mod:`collections.abc`" msgstr "" -#: ../../library/typing.rst:1588 +#: ../../library/typing.rst:1592 msgid "A generic version of :class:`collections.abc.Set`." msgstr "" -#: ../../library/typing.rst:1590 +#: ../../library/typing.rst:1594 msgid "" ":class:`collections.abc.Set` now supports ``[]``. See :pep:`585` and :ref:" "`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1596 +#: ../../library/typing.rst:1600 msgid "A generic version of :class:`collections.abc.ByteString`." msgstr "" -#: ../../library/typing.rst:1598 +#: ../../library/typing.rst:1602 msgid "" "This type represents the types :class:`bytes`, :class:`bytearray`, and :" "class:`memoryview` of byte sequences." msgstr "" -#: ../../library/typing.rst:1601 +#: ../../library/typing.rst:1605 msgid "" "As a shorthand for this type, :class:`bytes` can be used to annotate " "arguments of any of the types mentioned above." msgstr "" -#: ../../library/typing.rst:1604 +#: ../../library/typing.rst:1608 msgid "" ":class:`collections.abc.ByteString` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1610 +#: ../../library/typing.rst:1614 msgid "A generic version of :class:`collections.abc.Collection`" msgstr "" -#: ../../library/typing.rst:1614 +#: ../../library/typing.rst:1618 msgid "" ":class:`collections.abc.Collection` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1620 +#: ../../library/typing.rst:1624 msgid "A generic version of :class:`collections.abc.Container`." msgstr "" -#: ../../library/typing.rst:1622 +#: ../../library/typing.rst:1626 msgid "" ":class:`collections.abc.Container` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1628 +#: ../../library/typing.rst:1632 msgid "A generic version of :class:`collections.abc.ItemsView`." msgstr "" -#: ../../library/typing.rst:1630 +#: ../../library/typing.rst:1634 msgid "" ":class:`collections.abc.ItemsView` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1636 +#: ../../library/typing.rst:1640 msgid "A generic version of :class:`collections.abc.KeysView`." msgstr "" -#: ../../library/typing.rst:1638 +#: ../../library/typing.rst:1642 msgid "" ":class:`collections.abc.KeysView` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1644 +#: ../../library/typing.rst:1648 msgid "" "A generic version of :class:`collections.abc.Mapping`. This type can be used " "as follows::" msgstr "" -#: ../../library/typing.rst:1650 +#: ../../library/typing.rst:1654 msgid "" ":class:`collections.abc.Mapping` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1656 +#: ../../library/typing.rst:1660 msgid "A generic version of :class:`collections.abc.MappingView`." msgstr "" -#: ../../library/typing.rst:1658 +#: ../../library/typing.rst:1662 msgid "" ":class:`collections.abc.MappingView` now supports ``[]``. See :pep:`585` " "and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1664 +#: ../../library/typing.rst:1668 msgid "A generic version of :class:`collections.abc.MutableMapping`." msgstr "" -#: ../../library/typing.rst:1666 +#: ../../library/typing.rst:1670 msgid "" ":class:`collections.abc.MutableMapping` now supports ``[]``. See :pep:`585` " "and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1672 +#: ../../library/typing.rst:1676 msgid "A generic version of :class:`collections.abc.MutableSequence`." msgstr "" -#: ../../library/typing.rst:1674 +#: ../../library/typing.rst:1678 msgid "" ":class:`collections.abc.MutableSequence` now supports ``[]``. See :pep:`585` " "and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1680 +#: ../../library/typing.rst:1684 msgid "A generic version of :class:`collections.abc.MutableSet`." msgstr "" -#: ../../library/typing.rst:1682 +#: ../../library/typing.rst:1686 msgid "" ":class:`collections.abc.MutableSet` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1688 +#: ../../library/typing.rst:1692 msgid "A generic version of :class:`collections.abc.Sequence`." msgstr "" -#: ../../library/typing.rst:1690 +#: ../../library/typing.rst:1694 msgid "" ":class:`collections.abc.Sequence` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1696 +#: ../../library/typing.rst:1700 msgid "A generic version of :class:`collections.abc.ValuesView`." msgstr "" -#: ../../library/typing.rst:1698 +#: ../../library/typing.rst:1702 msgid "" ":class:`collections.abc.ValuesView` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1703 +#: ../../library/typing.rst:1707 msgid "Corresponding to other types in :mod:`collections.abc`" msgstr "" -#: ../../library/typing.rst:1707 +#: ../../library/typing.rst:1711 msgid "A generic version of :class:`collections.abc.Iterable`." msgstr "" -#: ../../library/typing.rst:1709 +#: ../../library/typing.rst:1713 msgid "" ":class:`collections.abc.Iterable` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1715 +#: ../../library/typing.rst:1719 msgid "A generic version of :class:`collections.abc.Iterator`." msgstr "" -#: ../../library/typing.rst:1717 +#: ../../library/typing.rst:1721 msgid "" ":class:`collections.abc.Iterator` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1723 +#: ../../library/typing.rst:1727 msgid "" "A generator can be annotated by the generic type ``Generator[YieldType, " "SendType, ReturnType]``. For example::" msgstr "" -#: ../../library/typing.rst:1732 +#: ../../library/typing.rst:1736 msgid "" "Note that unlike many other generics in the typing module, the ``SendType`` " "of :class:`Generator` behaves contravariantly, not covariantly or " "invariantly." msgstr "" -#: ../../library/typing.rst:1736 +#: ../../library/typing.rst:1740 msgid "" "If your generator will only yield values, set the ``SendType`` and " "``ReturnType`` to ``None``::" msgstr "" -#: ../../library/typing.rst:1744 +#: ../../library/typing.rst:1748 msgid "" "Alternatively, annotate your generator as having a return type of either " "``Iterable[YieldType]`` or ``Iterator[YieldType]``::" msgstr "" -#: ../../library/typing.rst:1752 +#: ../../library/typing.rst:1756 msgid "" ":class:`collections.abc.Generator` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1758 +#: ../../library/typing.rst:1762 msgid "An alias to :class:`collections.abc.Hashable`" msgstr "" -#: ../../library/typing.rst:1762 +#: ../../library/typing.rst:1766 msgid "A generic version of :class:`collections.abc.Reversible`." msgstr "" -#: ../../library/typing.rst:1764 +#: ../../library/typing.rst:1768 msgid "" ":class:`collections.abc.Reversible` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1770 +#: ../../library/typing.rst:1774 msgid "An alias to :class:`collections.abc.Sized`" msgstr "" -#: ../../library/typing.rst:1773 +#: ../../library/typing.rst:1777 msgid "Asynchronous programming" msgstr "" -#: ../../library/typing.rst:1777 +#: ../../library/typing.rst:1781 msgid "" "A generic version of :class:`collections.abc.Coroutine`. The variance and " "order of type variables correspond to those of :class:`Generator`, for " "example::" msgstr "" -#: ../../library/typing.rst:1789 +#: ../../library/typing.rst:1793 msgid "" ":class:`collections.abc.Coroutine` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1795 +#: ../../library/typing.rst:1799 msgid "" "An async generator can be annotated by the generic type " "``AsyncGenerator[YieldType, SendType]``. For example::" msgstr "" -#: ../../library/typing.rst:1804 +#: ../../library/typing.rst:1808 msgid "" "Unlike normal generators, async generators cannot return a value, so there " "is no ``ReturnType`` type parameter. As with :class:`Generator`, the " "``SendType`` behaves contravariantly." msgstr "" -#: ../../library/typing.rst:1808 +#: ../../library/typing.rst:1812 msgid "" "If your generator will only yield values, set the ``SendType`` to ``None``::" msgstr "" -#: ../../library/typing.rst:1816 +#: ../../library/typing.rst:1820 msgid "" "Alternatively, annotate your generator as having a return type of either " "``AsyncIterable[YieldType]`` or ``AsyncIterator[YieldType]``::" msgstr "" -#: ../../library/typing.rst:1826 +#: ../../library/typing.rst:1830 msgid "" ":class:`collections.abc.AsyncGenerator` now supports ``[]``. See :pep:`585` " "and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1832 +#: ../../library/typing.rst:1836 msgid "A generic version of :class:`collections.abc.AsyncIterable`." msgstr "" -#: ../../library/typing.rst:1836 +#: ../../library/typing.rst:1840 msgid "" ":class:`collections.abc.AsyncIterable` now supports ``[]``. See :pep:`585` " "and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1842 +#: ../../library/typing.rst:1846 msgid "A generic version of :class:`collections.abc.AsyncIterator`." msgstr "" -#: ../../library/typing.rst:1846 +#: ../../library/typing.rst:1850 msgid "" ":class:`collections.abc.AsyncIterator` now supports ``[]``. See :pep:`585` " "and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1852 +#: ../../library/typing.rst:1856 msgid "A generic version of :class:`collections.abc.Awaitable`." msgstr "" -#: ../../library/typing.rst:1856 +#: ../../library/typing.rst:1860 msgid "" ":class:`collections.abc.Awaitable` now supports ``[]``. See :pep:`585` and :" "ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1862 +#: ../../library/typing.rst:1866 msgid "Context manager types" msgstr "" -#: ../../library/typing.rst:1866 +#: ../../library/typing.rst:1870 msgid "A generic version of :class:`contextlib.AbstractContextManager`." msgstr "" -#: ../../library/typing.rst:1871 +#: ../../library/typing.rst:1875 msgid "" ":class:`contextlib.AbstractContextManager` now supports ``[]``. See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1877 +#: ../../library/typing.rst:1881 msgid "A generic version of :class:`contextlib.AbstractAsyncContextManager`." msgstr "" -#: ../../library/typing.rst:1882 +#: ../../library/typing.rst:1886 msgid "" ":class:`contextlib.AbstractAsyncContextManager` now supports ``[]``. See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:1887 +#: ../../library/typing.rst:1891 msgid "Protocols" msgstr "" -#: ../../library/typing.rst:1889 +#: ../../library/typing.rst:1893 msgid "These protocols are decorated with :func:`runtime_checkable`." msgstr "" -#: ../../library/typing.rst:1893 +#: ../../library/typing.rst:1897 msgid "" "An ABC with one abstract method ``__abs__`` that is covariant in its return " "type." msgstr "" -#: ../../library/typing.rst:1898 +#: ../../library/typing.rst:1902 msgid "An ABC with one abstract method ``__bytes__``." msgstr "" -#: ../../library/typing.rst:1902 +#: ../../library/typing.rst:1906 msgid "An ABC with one abstract method ``__complex__``." msgstr "" -#: ../../library/typing.rst:1906 +#: ../../library/typing.rst:1910 msgid "An ABC with one abstract method ``__float__``." msgstr "" -#: ../../library/typing.rst:1910 +#: ../../library/typing.rst:1914 msgid "An ABC with one abstract method ``__index__``." msgstr "" -#: ../../library/typing.rst:1916 +#: ../../library/typing.rst:1920 msgid "An ABC with one abstract method ``__int__``." msgstr "" -#: ../../library/typing.rst:1920 +#: ../../library/typing.rst:1924 msgid "" "An ABC with one abstract method ``__round__`` that is covariant in its " "return type." msgstr "" -#: ../../library/typing.rst:1924 +#: ../../library/typing.rst:1928 msgid "Functions and decorators" msgstr "函式與裝飾器" -#: ../../library/typing.rst:1928 +#: ../../library/typing.rst:1932 msgid "Cast a value to a type." msgstr "" -#: ../../library/typing.rst:1930 +#: ../../library/typing.rst:1934 msgid "" "This returns the value unchanged. To the type checker this signals that the " "return value has the designated type, but at runtime we intentionally don't " "check anything (we want this to be as fast as possible)." msgstr "" -#: ../../library/typing.rst:1937 +#: ../../library/typing.rst:1941 msgid "" "The ``@overload`` decorator allows describing functions and methods that " "support multiple different combinations of argument types. A series of " @@ -1937,69 +1944,69 @@ msgid "" "variable::" msgstr "" -#: ../../library/typing.rst:1961 +#: ../../library/typing.rst:1965 msgid "See :pep:`484` for details and comparison with other typing semantics." msgstr "" -#: ../../library/typing.rst:1965 +#: ../../library/typing.rst:1969 msgid "" "A decorator to indicate to type checkers that the decorated method cannot be " "overridden, and the decorated class cannot be subclassed. For example::" msgstr "" -#: ../../library/typing.rst:1990 +#: ../../library/typing.rst:1994 msgid "Decorator to indicate that annotations are not type hints." msgstr "" -#: ../../library/typing.rst:1992 +#: ../../library/typing.rst:1996 msgid "" "This works as class or function :term:`decorator`. With a class, it applies " "recursively to all methods defined in that class (but not to methods defined " "in its superclasses or subclasses)." msgstr "" -#: ../../library/typing.rst:1996 +#: ../../library/typing.rst:2000 msgid "This mutates the function(s) in place." msgstr "" -#: ../../library/typing.rst:2000 +#: ../../library/typing.rst:2004 msgid "Decorator to give another decorator the :func:`no_type_check` effect." msgstr "" -#: ../../library/typing.rst:2002 +#: ../../library/typing.rst:2006 msgid "" "This wraps the decorator with something that wraps the decorated function " "in :func:`no_type_check`." msgstr "" -#: ../../library/typing.rst:2007 +#: ../../library/typing.rst:2011 msgid "Decorator to mark a class or function to be unavailable at runtime." msgstr "" -#: ../../library/typing.rst:2009 +#: ../../library/typing.rst:2013 msgid "" "This decorator is itself not available at runtime. It is mainly intended to " "mark classes that are defined in type stub files if an implementation " "returns an instance of a private class::" msgstr "" -#: ../../library/typing.rst:2020 +#: ../../library/typing.rst:2024 msgid "" "Note that returning instances of private classes is not recommended. It is " "usually preferable to make such classes public." msgstr "" -#: ../../library/typing.rst:2024 +#: ../../library/typing.rst:2028 msgid "Introspection helpers" msgstr "" -#: ../../library/typing.rst:2028 +#: ../../library/typing.rst:2032 msgid "" "Return a dictionary containing type hints for a function, method, module or " "class object." msgstr "" -#: ../../library/typing.rst:2031 +#: ../../library/typing.rst:2035 msgid "" "This is often the same as ``obj.__annotations__``. In addition, forward " "references encoded as string literals are handled by evaluating them in " @@ -2009,29 +2016,29 @@ msgid "" "merging all the ``__annotations__`` along ``C.__mro__`` in reverse order." msgstr "" -#: ../../library/typing.rst:2039 +#: ../../library/typing.rst:2043 msgid "" "The function recursively replaces all ``Annotated[T, ...]`` with ``T``, " "unless ``include_extras`` is set to ``True`` (see :class:`Annotated` for " "more information). For example::" msgstr "" -#: ../../library/typing.rst:2054 +#: ../../library/typing.rst:2058 msgid "" ":func:`get_type_hints` does not work with imported :ref:`type aliases ` that include forward references. Enabling postponed evaluation of " "annotations (:pep:`563`) may remove the need for most forward references." msgstr "" -#: ../../library/typing.rst:2059 +#: ../../library/typing.rst:2063 msgid "Added ``include_extras`` parameter as part of :pep:`593`." msgstr "新增 ``include_extras`` 參數(如 :pep:`593` 中所述)。" -#: ../../library/typing.rst:2065 +#: ../../library/typing.rst:2069 msgid "Provide basic introspection for generic types and special typing forms." msgstr "" -#: ../../library/typing.rst:2067 +#: ../../library/typing.rst:2071 msgid "" "For a typing object of the form ``X[Y, Z, ...]`` these functions return " "``X`` and ``(Y, Z, ...)``. If ``X`` is a generic alias for a builtin or :mod:" @@ -2042,11 +2049,11 @@ msgid "" "and ``()`` correspondingly. Examples::" msgstr "" -#: ../../library/typing.rst:2086 +#: ../../library/typing.rst:2090 msgid "Check if a type is a :class:`TypedDict`." msgstr "" -#: ../../library/typing.rst:2101 +#: ../../library/typing.rst:2105 msgid "" "A class used for internal typing representation of string forward " "references. For example, ``List[\"SomeClass\"]`` is implicitly transformed " @@ -2054,24 +2061,24 @@ msgid "" "instantiated by a user, but may be used by introspection tools." msgstr "" -#: ../../library/typing.rst:2107 +#: ../../library/typing.rst:2111 msgid "" ":pep:`585` generic types such as ``list[\"SomeClass\"]`` will not be " "implicitly transformed into ``list[ForwardRef(\"SomeClass\")]`` and thus " "will not automatically resolve to ``list[SomeClass]``." msgstr "" -#: ../../library/typing.rst:2114 +#: ../../library/typing.rst:2118 msgid "Constant" msgstr "常數" -#: ../../library/typing.rst:2118 +#: ../../library/typing.rst:2122 msgid "" "A special constant that is assumed to be ``True`` by 3rd party static type " "checkers. It is ``False`` at runtime. Usage::" msgstr "" -#: ../../library/typing.rst:2127 +#: ../../library/typing.rst:2131 msgid "" "The first type annotation must be enclosed in quotes, making it a \"forward " "reference\", to hide the ``expensive_mod`` reference from the interpreter " @@ -2079,7 +2086,7 @@ msgid "" "second annotation does not need to be enclosed in quotes." msgstr "" -#: ../../library/typing.rst:2134 +#: ../../library/typing.rst:2138 msgid "" "If ``from __future__ import annotations`` is used in Python 3.7 or later, " "annotations are not evaluated at function definition time. Instead, they are " diff --git a/reference/datamodel.po b/reference/datamodel.po index 8f815775c4..270ee657fb 100644 --- a/reference/datamodel.po +++ b/reference/datamodel.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-12-20 00:10+0000\n" +"POT-Creation-Date: 2022-03-08 14:58+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-" @@ -2298,8 +2298,8 @@ msgstr "" #: ../../reference/datamodel.rst:1906 msgid "" "Whenever a class inherits from another class, :meth:`~object." -"__init_subclass__` is called on that class. This way, it is possible to " -"write classes which change the behavior of subclasses. This is closely " +"__init_subclass__` is called on the parent class. This way, it is possible " +"to write classes which change the behavior of subclasses. This is closely " "related to class decorators, but where class decorators only affect the " "specific class they're applied to, ``__init_subclass__`` solely applies to " "future subclasses of the class defining the method." diff --git a/reference/expressions.po b/reference/expressions.po index c883077c6a..52dbbd541c 100644 --- a/reference/expressions.po +++ b/reference/expressions.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-08 00:09+0000\n" +"POT-Creation-Date: 2022-03-08 14:58+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-" @@ -842,76 +842,90 @@ msgstr "" #: ../../reference/expressions.rst:813 msgid "" -"Subscription of a sequence (string, tuple or list) or mapping (dictionary) " -"object usually selects an item from the collection:" +"The subscription of an instance of a :ref:`container class ` " +"will generally select an element from the container. The subscription of a :" +"term:`generic class ` will generally return a :ref:" +"`GenericAlias ` object." msgstr "" -#: ../../reference/expressions.rst:819 +#: ../../reference/expressions.rst:821 msgid "" -"The primary must evaluate to an object that supports subscription (lists or " -"dictionaries for example). User-defined objects can support subscription by " -"defining a :meth:`__getitem__` method." +"When an object is subscripted, the interpreter will evaluate the primary and " +"the expression list." msgstr "" -#: ../../reference/expressions.rst:823 +#: ../../reference/expressions.rst:824 msgid "" -"For built-in objects, there are two types of objects that support " -"subscription:" +"The primary must evaluate to an object that supports subscription. An object " +"may support subscription through defining one or both of :meth:`~object." +"__getitem__` and :meth:`~object.__class_getitem__`. When the primary is " +"subscripted, the evaluated result of the expression list will be passed to " +"one of these methods. For more details on when ``__class_getitem__`` is " +"called instead of ``__getitem__``, see :ref:`classgetitem-versus-getitem`." msgstr "" -#: ../../reference/expressions.rst:825 +#: ../../reference/expressions.rst:831 msgid "" -"If the primary is a mapping, the expression list must evaluate to an object " -"whose value is one of the keys of the mapping, and the subscription selects " -"the value in the mapping that corresponds to that key. (The expression list " -"is a tuple except if it has exactly one item.)" +"If the expression list contains at least one comma, it will evaluate to a :" +"class:`tuple` containing the items of the expression list. Otherwise, the " +"expression list will evaluate to the value of the list's sole member." msgstr "" -#: ../../reference/expressions.rst:830 +#: ../../reference/expressions.rst:835 msgid "" -"If the primary is a sequence, the expression list must evaluate to an " -"integer or a slice (as discussed in the following section)." +"For built-in objects, there are two types of objects that support " +"subscription via :meth:`~object.__getitem__`:" msgstr "" -#: ../../reference/expressions.rst:833 +#: ../../reference/expressions.rst:838 msgid "" -"The formal syntax makes no special provision for negative indices in " -"sequences; however, built-in sequences all provide a :meth:`__getitem__` " -"method that interprets negative indices by adding the length of the sequence " -"to the index (so that ``x[-1]`` selects the last item of ``x``). The " -"resulting value must be a nonnegative integer less than the number of items " -"in the sequence, and the subscription selects the item whose index is that " -"value (counting from zero). Since the support for negative indices and " -"slicing occurs in the object's :meth:`__getitem__` method, subclasses " -"overriding this method will need to explicitly add that support." +"Mappings. If the primary is a :term:`mapping`, the expression list must " +"evaluate to an object whose value is one of the keys of the mapping, and the " +"subscription selects the value in the mapping that corresponds to that key. " +"An example of a builtin mapping class is the :class:`dict` class." +msgstr "" + +#: ../../reference/expressions.rst:842 +msgid "" +"Sequences. If the primary is a :term:`sequence`, the expression list must " +"evaluate to an :class:`int` or a :class:`slice` (as discussed in the " +"following section). Examples of builtin sequence classes include the :class:" +"`str`, :class:`list` and :class:`tuple` classes." msgstr "" #: ../../reference/expressions.rst:847 msgid "" -"A string's items are characters. A character is not a separate data type " -"but a string of exactly one character." +"The formal syntax makes no special provision for negative indices in :term:" +"`sequences `. However, built-in sequences all provide a :meth:" +"`~object.__getitem__` method that interprets negative indices by adding the " +"length of the sequence to the index so that, for example, ``x[-1]`` selects " +"the last item of ``x``. The resulting value must be a nonnegative integer " +"less than the number of items in the sequence, and the subscription selects " +"the item whose index is that value (counting from zero). Since the support " +"for negative indices and slicing occurs in the object's :meth:`__getitem__` " +"method, subclasses overriding this method will need to explicitly add that " +"support." msgstr "" -#: ../../reference/expressions.rst:850 +#: ../../reference/expressions.rst:861 msgid "" -"Subscription of certain :term:`classes ` or :term:`types ` " -"creates a :ref:`generic alias `. In this case, user-" -"defined classes can support subscription by providing a :meth:" -"`__class_getitem__` classmethod." +"A :class:`string ` is a special kind of sequence whose items are " +"*characters*. A character is not a separate data type but a string of " +"exactly one character." msgstr "" -#: ../../reference/expressions.rst:859 +#: ../../reference/expressions.rst:869 msgid "Slicings" msgstr "" -#: ../../reference/expressions.rst:873 +#: ../../reference/expressions.rst:883 msgid "" "A slicing selects a range of items in a sequence object (e.g., a string, " "tuple or list). Slicings may be used as expressions or as targets in " "assignment or :keyword:`del` statements. The syntax for a slicing:" msgstr "" -#: ../../reference/expressions.rst:886 +#: ../../reference/expressions.rst:896 msgid "" "There is ambiguity in the formal syntax here: anything that looks like an " "expression list also looks like a slice list, so any subscription can be " @@ -921,7 +935,7 @@ msgid "" "the case if the slice list contains no proper slice)." msgstr "" -#: ../../reference/expressions.rst:898 +#: ../../reference/expressions.rst:908 msgid "" "The semantics for a slicing are as follows. The primary is indexed (using " "the same :meth:`__getitem__` method as normal subscription) with a key that " @@ -936,23 +950,23 @@ msgid "" "expressions." msgstr "" -#: ../../reference/expressions.rst:922 +#: ../../reference/expressions.rst:932 msgid "Calls" msgstr "" -#: ../../reference/expressions.rst:924 +#: ../../reference/expressions.rst:934 msgid "" "A call calls a callable object (e.g., a :term:`function`) with a possibly " "empty series of :term:`arguments `:" msgstr "" -#: ../../reference/expressions.rst:941 +#: ../../reference/expressions.rst:951 msgid "" "An optional trailing comma may be present after the positional and keyword " "arguments but does not affect the semantics." msgstr "" -#: ../../reference/expressions.rst:947 +#: ../../reference/expressions.rst:957 msgid "" "The primary must evaluate to a callable object (user-defined functions, " "built-in functions, methods of built-in objects, class objects, methods of " @@ -962,7 +976,7 @@ msgid "" "formal :term:`parameter` lists." msgstr "" -#: ../../reference/expressions.rst:955 +#: ../../reference/expressions.rst:965 msgid "" "If keyword arguments are present, they are first converted to positional " "arguments, as follows. First, a list of unfilled slots is created for the " @@ -984,7 +998,7 @@ msgid "" "call." msgstr "" -#: ../../reference/expressions.rst:975 +#: ../../reference/expressions.rst:985 msgid "" "An implementation may provide built-in functions whose positional parameters " "do not have names, even if they are 'named' for the purpose of " @@ -993,7 +1007,7 @@ msgid "" "`PyArg_ParseTuple` to parse their arguments." msgstr "" -#: ../../reference/expressions.rst:981 +#: ../../reference/expressions.rst:991 msgid "" "If there are more positional arguments than there are formal parameter " "slots, a :exc:`TypeError` exception is raised, unless a formal parameter " @@ -1002,7 +1016,7 @@ msgid "" "empty tuple if there were no excess positional arguments)." msgstr "" -#: ../../reference/expressions.rst:987 +#: ../../reference/expressions.rst:997 msgid "" "If any keyword argument does not correspond to a formal parameter name, a :" "exc:`TypeError` exception is raised, unless a formal parameter using the " @@ -1012,7 +1026,7 @@ msgid "" "(new) empty dictionary if there were no excess keyword arguments." msgstr "" -#: ../../reference/expressions.rst:998 +#: ../../reference/expressions.rst:1008 msgid "" "If the syntax ``*expression`` appears in the function call, ``expression`` " "must evaluate to an :term:`iterable`. Elements from these iterables are " @@ -1022,20 +1036,20 @@ msgid "" "*y1*, ..., *yM*, *x3*, *x4*." msgstr "" -#: ../../reference/expressions.rst:1005 +#: ../../reference/expressions.rst:1015 msgid "" "A consequence of this is that although the ``*expression`` syntax may appear " "*after* explicit keyword arguments, it is processed *before* the keyword " "arguments (and any ``**expression`` arguments -- see below). So::" msgstr "" -#: ../../reference/expressions.rst:1021 +#: ../../reference/expressions.rst:1031 msgid "" "It is unusual for both keyword arguments and the ``*expression`` syntax to " "be used in the same call, so in practice this confusion does not arise." msgstr "" -#: ../../reference/expressions.rst:1027 +#: ../../reference/expressions.rst:1037 msgid "" "If the syntax ``**expression`` appears in the function call, ``expression`` " "must evaluate to a :term:`mapping`, the contents of which are treated as " @@ -1044,35 +1058,35 @@ msgid "" "exception is raised." msgstr "" -#: ../../reference/expressions.rst:1033 +#: ../../reference/expressions.rst:1043 msgid "" "Formal parameters using the syntax ``*identifier`` or ``**identifier`` " "cannot be used as positional argument slots or as keyword argument names." msgstr "" -#: ../../reference/expressions.rst:1036 +#: ../../reference/expressions.rst:1046 msgid "" "Function calls accept any number of ``*`` and ``**`` unpackings, positional " "arguments may follow iterable unpackings (``*``), and keyword arguments may " "follow dictionary unpackings (``**``). Originally proposed by :pep:`448`." msgstr "" -#: ../../reference/expressions.rst:1042 +#: ../../reference/expressions.rst:1052 msgid "" "A call always returns some value, possibly ``None``, unless it raises an " "exception. How this value is computed depends on the type of the callable " "object." msgstr "" -#: ../../reference/expressions.rst:1046 +#: ../../reference/expressions.rst:1056 msgid "If it is---" msgstr "" -#: ../../reference/expressions.rst:1059 +#: ../../reference/expressions.rst:1069 msgid "a user-defined function:" msgstr "" -#: ../../reference/expressions.rst:1055 +#: ../../reference/expressions.rst:1065 msgid "" "The code block for the function is executed, passing it the argument list. " "The first thing the code block will do is bind the formal parameters to the " @@ -1081,73 +1095,73 @@ msgid "" "value of the function call." msgstr "" -#: ../../reference/expressions.rst:1073 +#: ../../reference/expressions.rst:1083 msgid "a built-in function or method:" msgstr "" -#: ../../reference/expressions.rst:1072 +#: ../../reference/expressions.rst:1082 msgid "" "The result is up to the interpreter; see :ref:`built-in-funcs` for the " "descriptions of built-in functions and methods." msgstr "" -#: ../../reference/expressions.rst:1080 +#: ../../reference/expressions.rst:1090 msgid "a class object:" msgstr "" -#: ../../reference/expressions.rst:1080 +#: ../../reference/expressions.rst:1090 msgid "A new instance of that class is returned." msgstr "" -#: ../../reference/expressions.rst:1090 +#: ../../reference/expressions.rst:1100 msgid "a class instance method:" msgstr "" -#: ../../reference/expressions.rst:1088 +#: ../../reference/expressions.rst:1098 msgid "" "The corresponding user-defined function is called, with an argument list " "that is one longer than the argument list of the call: the instance becomes " "the first argument." msgstr "" -#: ../../reference/expressions.rst:1099 +#: ../../reference/expressions.rst:1109 msgid "a class instance:" msgstr "" -#: ../../reference/expressions.rst:1097 +#: ../../reference/expressions.rst:1107 msgid "" "The class must define a :meth:`__call__` method; the effect is then the same " "as if that method was called." msgstr "" -#: ../../reference/expressions.rst:1105 ../../reference/expressions.rst:1871 +#: ../../reference/expressions.rst:1115 ../../reference/expressions.rst:1881 msgid "Await expression" msgstr "" -#: ../../reference/expressions.rst:1107 +#: ../../reference/expressions.rst:1117 msgid "" "Suspend the execution of :term:`coroutine` on an :term:`awaitable` object. " "Can only be used inside a :term:`coroutine function`." msgstr "" -#: ../../reference/expressions.rst:1119 +#: ../../reference/expressions.rst:1129 msgid "The power operator" msgstr "" -#: ../../reference/expressions.rst:1125 +#: ../../reference/expressions.rst:1135 msgid "" "The power operator binds more tightly than unary operators on its left; it " "binds less tightly than unary operators on its right. The syntax is:" msgstr "" -#: ../../reference/expressions.rst:1131 +#: ../../reference/expressions.rst:1141 msgid "" "Thus, in an unparenthesized sequence of power and unary operators, the " "operators are evaluated from right to left (this does not constrain the " "evaluation order for the operands): ``-1**2`` results in ``-1``." msgstr "" -#: ../../reference/expressions.rst:1135 +#: ../../reference/expressions.rst:1145 msgid "" "The power operator has the same semantics as the built-in :func:`pow` " "function, when called with two arguments: it yields its left argument raised " @@ -1155,7 +1169,7 @@ msgid "" "converted to a common type, and the result is of that type." msgstr "" -#: ../../reference/expressions.rst:1140 +#: ../../reference/expressions.rst:1150 msgid "" "For int operands, the result has the same type as the operands unless the " "second argument is negative; in that case, all arguments are converted to " @@ -1163,40 +1177,40 @@ msgid "" "``100``, but ``10**-2`` returns ``0.01``." msgstr "" -#: ../../reference/expressions.rst:1145 +#: ../../reference/expressions.rst:1155 msgid "" "Raising ``0.0`` to a negative power results in a :exc:`ZeroDivisionError`. " "Raising a negative number to a fractional power results in a :class:" "`complex` number. (In earlier versions it raised a :exc:`ValueError`.)" msgstr "" -#: ../../reference/expressions.rst:1149 +#: ../../reference/expressions.rst:1159 msgid "" "This operation can be customized using the special :meth:`__pow__` method." msgstr "" -#: ../../reference/expressions.rst:1154 +#: ../../reference/expressions.rst:1164 msgid "Unary arithmetic and bitwise operations" msgstr "" -#: ../../reference/expressions.rst:1160 +#: ../../reference/expressions.rst:1170 msgid "All unary arithmetic and bitwise operations have the same priority:" msgstr "" -#: ../../reference/expressions.rst:1171 +#: ../../reference/expressions.rst:1181 msgid "" "The unary ``-`` (minus) operator yields the negation of its numeric " "argument; the operation can be overridden with the :meth:`__neg__` special " "method." msgstr "" -#: ../../reference/expressions.rst:1179 +#: ../../reference/expressions.rst:1189 msgid "" "The unary ``+`` (plus) operator yields its numeric argument unchanged; the " "operation can be overridden with the :meth:`__pos__` special method." msgstr "" -#: ../../reference/expressions.rst:1186 +#: ../../reference/expressions.rst:1196 msgid "" "The unary ``~`` (invert) operator yields the bitwise inversion of its " "integer argument. The bitwise inversion of ``x`` is defined as ``-(x+1)``. " @@ -1204,17 +1218,17 @@ msgid "" "meth:`__invert__` special method." msgstr "" -#: ../../reference/expressions.rst:1195 +#: ../../reference/expressions.rst:1205 msgid "" "In all three cases, if the argument does not have the proper type, a :exc:" "`TypeError` exception is raised." msgstr "" -#: ../../reference/expressions.rst:1202 +#: ../../reference/expressions.rst:1212 msgid "Binary arithmetic operations" msgstr "" -#: ../../reference/expressions.rst:1206 +#: ../../reference/expressions.rst:1216 msgid "" "The binary arithmetic operations have the conventional priority levels. " "Note that some of these operations also apply to certain non-numeric types. " @@ -1222,7 +1236,7 @@ msgid "" "multiplicative operators and one for additive operators:" msgstr "" -#: ../../reference/expressions.rst:1221 +#: ../../reference/expressions.rst:1231 msgid "" "The ``*`` (multiplication) operator yields the product of its arguments. " "The arguments must either both be numbers, or one argument must be an " @@ -1232,19 +1246,19 @@ msgid "" "an empty sequence." msgstr "" -#: ../../reference/expressions.rst:1227 +#: ../../reference/expressions.rst:1237 msgid "" "This operation can be customized using the special :meth:`__mul__` and :meth:" "`__rmul__` methods." msgstr "" -#: ../../reference/expressions.rst:1234 +#: ../../reference/expressions.rst:1244 msgid "" "The ``@`` (at) operator is intended to be used for matrix multiplication. " "No builtin Python types implement this operator." msgstr "" -#: ../../reference/expressions.rst:1245 +#: ../../reference/expressions.rst:1255 msgid "" "The ``/`` (division) and ``//`` (floor division) operators yield the " "quotient of their arguments. The numeric arguments are first converted to a " @@ -1254,13 +1268,13 @@ msgid "" "the :exc:`ZeroDivisionError` exception." msgstr "" -#: ../../reference/expressions.rst:1252 +#: ../../reference/expressions.rst:1262 msgid "" "This operation can be customized using the special :meth:`__truediv__` and :" "meth:`__floordiv__` methods." msgstr "" -#: ../../reference/expressions.rst:1259 +#: ../../reference/expressions.rst:1269 msgid "" "The ``%`` (modulo) operator yields the remainder from the division of the " "first argument by the second. The numeric arguments are first converted to " @@ -1272,7 +1286,7 @@ msgid "" "absolute value of the second operand [#]_." msgstr "" -#: ../../reference/expressions.rst:1268 +#: ../../reference/expressions.rst:1278 msgid "" "The floor division and modulo operators are connected by the following " "identity: ``x == (x//y)*y + (x%y)``. Floor division and modulo are also " @@ -1280,7 +1294,7 @@ msgid "" "y, x%y)``. [#]_." msgstr "" -#: ../../reference/expressions.rst:1273 +#: ../../reference/expressions.rst:1283 msgid "" "In addition to performing the modulo operation on numbers, the ``%`` " "operator is also overloaded by string objects to perform old-style string " @@ -1289,20 +1303,20 @@ msgid "" "formatting`." msgstr "" -#: ../../reference/expressions.rst:1278 +#: ../../reference/expressions.rst:1288 msgid "" "The *modulo* operation can be customized using the special :meth:`__mod__` " "method." msgstr "" -#: ../../reference/expressions.rst:1280 +#: ../../reference/expressions.rst:1290 msgid "" "The floor division operator, the modulo operator, and the :func:`divmod` " "function are not defined for complex numbers. Instead, convert to a " "floating point number using the :func:`abs` function if appropriate." msgstr "" -#: ../../reference/expressions.rst:1289 +#: ../../reference/expressions.rst:1299 msgid "" "The ``+`` (addition) operator yields the sum of its arguments. The " "arguments must either both be numbers or both be sequences of the same " @@ -1310,84 +1324,84 @@ msgid "" "then added together. In the latter case, the sequences are concatenated." msgstr "" -#: ../../reference/expressions.rst:1294 +#: ../../reference/expressions.rst:1304 msgid "" "This operation can be customized using the special :meth:`__add__` and :meth:" "`__radd__` methods." msgstr "" -#: ../../reference/expressions.rst:1302 +#: ../../reference/expressions.rst:1312 msgid "" "The ``-`` (subtraction) operator yields the difference of its arguments. " "The numeric arguments are first converted to a common type." msgstr "" -#: ../../reference/expressions.rst:1305 +#: ../../reference/expressions.rst:1315 msgid "" "This operation can be customized using the special :meth:`__sub__` method." msgstr "" -#: ../../reference/expressions.rst:1311 +#: ../../reference/expressions.rst:1321 msgid "Shifting operations" msgstr "" -#: ../../reference/expressions.rst:1318 +#: ../../reference/expressions.rst:1328 msgid "" "The shifting operations have lower priority than the arithmetic operations:" msgstr "" -#: ../../reference/expressions.rst:1323 +#: ../../reference/expressions.rst:1333 msgid "" "These operators accept integers as arguments. They shift the first argument " "to the left or right by the number of bits given by the second argument." msgstr "" -#: ../../reference/expressions.rst:1326 +#: ../../reference/expressions.rst:1336 msgid "" "This operation can be customized using the special :meth:`__lshift__` and :" "meth:`__rshift__` methods." msgstr "" -#: ../../reference/expressions.rst:1331 +#: ../../reference/expressions.rst:1341 msgid "" "A right shift by *n* bits is defined as floor division by ``pow(2,n)``. A " "left shift by *n* bits is defined as multiplication with ``pow(2,n)``." msgstr "" -#: ../../reference/expressions.rst:1338 +#: ../../reference/expressions.rst:1348 msgid "Binary bitwise operations" msgstr "" -#: ../../reference/expressions.rst:1342 +#: ../../reference/expressions.rst:1352 msgid "Each of the three bitwise operations has a different priority level:" msgstr "" -#: ../../reference/expressions.rst:1353 +#: ../../reference/expressions.rst:1363 msgid "" "The ``&`` operator yields the bitwise AND of its arguments, which must be " "integers or one of them must be a custom object overriding :meth:`__and__` " "or :meth:`__rand__` special methods." msgstr "" -#: ../../reference/expressions.rst:1362 +#: ../../reference/expressions.rst:1372 msgid "" "The ``^`` operator yields the bitwise XOR (exclusive OR) of its arguments, " "which must be integers or one of them must be a custom object overriding :" "meth:`__xor__` or :meth:`__rxor__` special methods." msgstr "" -#: ../../reference/expressions.rst:1371 +#: ../../reference/expressions.rst:1381 msgid "" "The ``|`` operator yields the bitwise (inclusive) OR of its arguments, which " "must be integers or one of them must be a custom object overriding :meth:" "`__or__` or :meth:`__ror__` special methods." msgstr "" -#: ../../reference/expressions.rst:1379 +#: ../../reference/expressions.rst:1389 msgid "Comparisons" msgstr "" -#: ../../reference/expressions.rst:1391 +#: ../../reference/expressions.rst:1401 msgid "" "Unlike C, all comparison operations in Python have the same priority, which " "is lower than that of any arithmetic, shifting or bitwise operation. Also " @@ -1395,14 +1409,14 @@ msgid "" "conventional in mathematics:" msgstr "" -#: ../../reference/expressions.rst:1401 +#: ../../reference/expressions.rst:1411 msgid "" "Comparisons yield boolean values: ``True`` or ``False``. Custom :dfn:`rich " "comparison methods` may return non-boolean values. In this case Python will " "call :func:`bool` on such value in boolean contexts." msgstr "" -#: ../../reference/expressions.rst:1407 +#: ../../reference/expressions.rst:1417 msgid "" "Comparisons can be chained arbitrarily, e.g., ``x < y <= z`` is equivalent " "to ``x < y and y <= z``, except that ``y`` is evaluated only once (but in " @@ -1410,7 +1424,7 @@ msgid "" "false)." msgstr "" -#: ../../reference/expressions.rst:1411 +#: ../../reference/expressions.rst:1421 msgid "" "Formally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*, " "*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y opN " @@ -1418,24 +1432,24 @@ msgid "" "each expression is evaluated at most once." msgstr "" -#: ../../reference/expressions.rst:1416 +#: ../../reference/expressions.rst:1426 msgid "" "Note that ``a op1 b op2 c`` doesn't imply any kind of comparison between *a* " "and *c*, so that, e.g., ``x < y > z`` is perfectly legal (though perhaps not " "pretty)." msgstr "" -#: ../../reference/expressions.rst:1421 +#: ../../reference/expressions.rst:1431 msgid "Value comparisons" msgstr "" -#: ../../reference/expressions.rst:1423 +#: ../../reference/expressions.rst:1433 msgid "" "The operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare the " "values of two objects. The objects do not need to have the same type." msgstr "" -#: ../../reference/expressions.rst:1426 +#: ../../reference/expressions.rst:1436 msgid "" "Chapter :ref:`objects` states that objects have a value (in addition to type " "and identity). The value of an object is a rather abstract notion in " @@ -1447,7 +1461,7 @@ msgid "" "indirectly, by means of their comparison implementation." msgstr "" -#: ../../reference/expressions.rst:1435 +#: ../../reference/expressions.rst:1445 msgid "" "Because all types are (direct or indirect) subtypes of :class:`object`, they " "inherit the default comparison behavior from :class:`object`. Types can " @@ -1455,7 +1469,7 @@ msgid "" "methods` like :meth:`__lt__`, described in :ref:`customization`." msgstr "" -#: ../../reference/expressions.rst:1441 +#: ../../reference/expressions.rst:1451 msgid "" "The default behavior for equality comparison (``==`` and ``!=``) is based on " "the identity of the objects. Hence, equality comparison of instances with " @@ -1465,14 +1479,14 @@ msgid "" "``x is y`` implies ``x == y``)." msgstr "" -#: ../../reference/expressions.rst:1448 +#: ../../reference/expressions.rst:1458 msgid "" "A default order comparison (``<``, ``>``, ``<=``, and ``>=``) is not " "provided; an attempt raises :exc:`TypeError`. A motivation for this default " "behavior is the lack of a similar invariant as for equality." msgstr "" -#: ../../reference/expressions.rst:1452 +#: ../../reference/expressions.rst:1462 msgid "" "The behavior of the default equality comparison, that instances with " "different identities are always unequal, may be in contrast to what types " @@ -1481,13 +1495,13 @@ msgid "" "in fact, a number of built-in types have done that." msgstr "" -#: ../../reference/expressions.rst:1458 +#: ../../reference/expressions.rst:1468 msgid "" "The following list describes the comparison behavior of the most important " "built-in types." msgstr "" -#: ../../reference/expressions.rst:1461 +#: ../../reference/expressions.rst:1471 msgid "" "Numbers of built-in numeric types (:ref:`typesnumeric`) and of the standard " "library types :class:`fractions.Fraction` and :class:`decimal.Decimal` can " @@ -1497,7 +1511,7 @@ msgid "" "of precision." msgstr "" -#: ../../reference/expressions.rst:1468 +#: ../../reference/expressions.rst:1478 msgid "" "The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are " "special. Any ordered comparison of a number to a not-a-number value is " @@ -1507,32 +1521,32 @@ msgid "" "is compliant with IEEE 754." msgstr "" -#: ../../reference/expressions.rst:1475 +#: ../../reference/expressions.rst:1485 msgid "" "``None`` and ``NotImplemented`` are singletons. :PEP:`8` advises that " "comparisons for singletons should always be done with ``is`` or ``is not``, " "never the equality operators." msgstr "" -#: ../../reference/expressions.rst:1479 +#: ../../reference/expressions.rst:1489 msgid "" "Binary sequences (instances of :class:`bytes` or :class:`bytearray`) can be " "compared within and across their types. They compare lexicographically " "using the numeric values of their elements." msgstr "" -#: ../../reference/expressions.rst:1483 +#: ../../reference/expressions.rst:1493 msgid "" "Strings (instances of :class:`str`) compare lexicographically using the " "numerical Unicode code points (the result of the built-in function :func:" "`ord`) of their characters. [#]_" msgstr "" -#: ../../reference/expressions.rst:1487 +#: ../../reference/expressions.rst:1497 msgid "Strings and binary sequences cannot be directly compared." msgstr "" -#: ../../reference/expressions.rst:1489 +#: ../../reference/expressions.rst:1499 msgid "" "Sequences (instances of :class:`tuple`, :class:`list`, or :class:`range`) " "can be compared only within each of their types, with the restriction that " @@ -1541,7 +1555,7 @@ msgid "" "raises :exc:`TypeError`." msgstr "" -#: ../../reference/expressions.rst:1495 +#: ../../reference/expressions.rst:1505 msgid "" "Sequences compare lexicographically using comparison of corresponding " "elements. The built-in containers typically assume identical objects are " @@ -1549,19 +1563,19 @@ msgid "" "objects to improve performance and to maintain their internal invariants." msgstr "" -#: ../../reference/expressions.rst:1500 +#: ../../reference/expressions.rst:1510 msgid "" "Lexicographical comparison between built-in collections works as follows:" msgstr "" -#: ../../reference/expressions.rst:1502 +#: ../../reference/expressions.rst:1512 msgid "" "For two collections to compare equal, they must be of the same type, have " "the same length, and each pair of corresponding elements must compare equal " "(for example, ``[1,2] == (1,2)`` is false because the type is not the same)." msgstr "" -#: ../../reference/expressions.rst:1507 +#: ../../reference/expressions.rst:1517 msgid "" "Collections that support order comparison are ordered the same as their " "first unequal elements (for example, ``[1,2,x] <= [1,2,y]`` has the same " @@ -1570,25 +1584,25 @@ msgid "" "true)." msgstr "" -#: ../../reference/expressions.rst:1513 +#: ../../reference/expressions.rst:1523 msgid "" "Mappings (instances of :class:`dict`) compare equal if and only if they have " "equal `(key, value)` pairs. Equality comparison of the keys and values " "enforces reflexivity." msgstr "" -#: ../../reference/expressions.rst:1517 +#: ../../reference/expressions.rst:1527 msgid "" "Order comparisons (``<``, ``>``, ``<=``, and ``>=``) raise :exc:`TypeError`." msgstr "" -#: ../../reference/expressions.rst:1519 +#: ../../reference/expressions.rst:1529 msgid "" "Sets (instances of :class:`set` or :class:`frozenset`) can be compared " "within and across their types." msgstr "" -#: ../../reference/expressions.rst:1522 +#: ../../reference/expressions.rst:1532 msgid "" "They define order comparison operators to mean subset and superset tests. " "Those relations do not define total orderings (for example, the two sets " @@ -1599,110 +1613,110 @@ msgid "" "sets as inputs)." msgstr "" -#: ../../reference/expressions.rst:1530 +#: ../../reference/expressions.rst:1540 msgid "Comparison of sets enforces reflexivity of its elements." msgstr "" -#: ../../reference/expressions.rst:1532 +#: ../../reference/expressions.rst:1542 msgid "" "Most other built-in types have no comparison methods implemented, so they " "inherit the default comparison behavior." msgstr "" -#: ../../reference/expressions.rst:1535 +#: ../../reference/expressions.rst:1545 msgid "" "User-defined classes that customize their comparison behavior should follow " "some consistency rules, if possible:" msgstr "" -#: ../../reference/expressions.rst:1538 +#: ../../reference/expressions.rst:1548 msgid "" "Equality comparison should be reflexive. In other words, identical objects " "should compare equal:" msgstr "" -#: ../../reference/expressions.rst:1541 +#: ../../reference/expressions.rst:1551 msgid "``x is y`` implies ``x == y``" msgstr "" -#: ../../reference/expressions.rst:1543 +#: ../../reference/expressions.rst:1553 msgid "" "Comparison should be symmetric. In other words, the following expressions " "should have the same result:" msgstr "" -#: ../../reference/expressions.rst:1546 +#: ../../reference/expressions.rst:1556 msgid "``x == y`` and ``y == x``" msgstr "``x == y`` 和 ``y == x``" -#: ../../reference/expressions.rst:1548 +#: ../../reference/expressions.rst:1558 msgid "``x != y`` and ``y != x``" msgstr "``x != y`` 和 ``y != x``" -#: ../../reference/expressions.rst:1550 +#: ../../reference/expressions.rst:1560 msgid "``x < y`` and ``y > x``" msgstr "``x < y`` 和 ``y > x``" -#: ../../reference/expressions.rst:1552 +#: ../../reference/expressions.rst:1562 msgid "``x <= y`` and ``y >= x``" msgstr "``x <= y`` 和 ``y >= x``" -#: ../../reference/expressions.rst:1554 +#: ../../reference/expressions.rst:1564 msgid "" "Comparison should be transitive. The following (non-exhaustive) examples " "illustrate that:" msgstr "" -#: ../../reference/expressions.rst:1557 +#: ../../reference/expressions.rst:1567 msgid "``x > y and y > z`` implies ``x > z``" msgstr "" -#: ../../reference/expressions.rst:1559 +#: ../../reference/expressions.rst:1569 msgid "``x < y and y <= z`` implies ``x < z``" msgstr "" -#: ../../reference/expressions.rst:1561 +#: ../../reference/expressions.rst:1571 msgid "" "Inverse comparison should result in the boolean negation. In other words, " "the following expressions should have the same result:" msgstr "" -#: ../../reference/expressions.rst:1564 +#: ../../reference/expressions.rst:1574 msgid "``x == y`` and ``not x != y``" msgstr "``x == y`` 和 ``not x != y``" -#: ../../reference/expressions.rst:1566 +#: ../../reference/expressions.rst:1576 msgid "``x < y`` and ``not x >= y`` (for total ordering)" msgstr "" -#: ../../reference/expressions.rst:1568 +#: ../../reference/expressions.rst:1578 msgid "``x > y`` and ``not x <= y`` (for total ordering)" msgstr "" -#: ../../reference/expressions.rst:1570 +#: ../../reference/expressions.rst:1580 msgid "" "The last two expressions apply to totally ordered collections (e.g. to " "sequences, but not to sets or mappings). See also the :func:`~functools." "total_ordering` decorator." msgstr "" -#: ../../reference/expressions.rst:1574 +#: ../../reference/expressions.rst:1584 msgid "" "The :func:`hash` result should be consistent with equality. Objects that are " "equal should either have the same hash value, or be marked as unhashable." msgstr "" -#: ../../reference/expressions.rst:1578 +#: ../../reference/expressions.rst:1588 msgid "" "Python does not enforce these consistency rules. In fact, the not-a-number " "values are an example for not following these rules." msgstr "" -#: ../../reference/expressions.rst:1587 +#: ../../reference/expressions.rst:1597 msgid "Membership test operations" msgstr "" -#: ../../reference/expressions.rst:1589 +#: ../../reference/expressions.rst:1599 msgid "" "The operators :keyword:`in` and :keyword:`not in` test for membership. ``x " "in s`` evaluates to ``True`` if *x* is a member of *s*, and ``False`` " @@ -1713,7 +1727,7 @@ msgid "" "expression ``x in y`` is equivalent to ``any(x is e or x == e for e in y)``." msgstr "" -#: ../../reference/expressions.rst:1597 +#: ../../reference/expressions.rst:1607 msgid "" "For the string and bytes types, ``x in y`` is ``True`` if and only if *x* is " "a substring of *y*. An equivalent test is ``y.find(x) != -1``. Empty " @@ -1721,14 +1735,14 @@ msgid "" "\"\" in \"abc\"`` will return ``True``." msgstr "" -#: ../../reference/expressions.rst:1602 +#: ../../reference/expressions.rst:1612 msgid "" "For user-defined classes which define the :meth:`__contains__` method, ``x " "in y`` returns ``True`` if ``y.__contains__(x)`` returns a true value, and " "``False`` otherwise." msgstr "" -#: ../../reference/expressions.rst:1606 +#: ../../reference/expressions.rst:1616 msgid "" "For user-defined classes which do not define :meth:`__contains__` but do " "define :meth:`__iter__`, ``x in y`` is ``True`` if some value ``z``, for " @@ -1737,7 +1751,7 @@ msgid "" "as if :keyword:`in` raised that exception." msgstr "" -#: ../../reference/expressions.rst:1612 +#: ../../reference/expressions.rst:1622 msgid "" "Lastly, the old-style iteration protocol is tried: if a class defines :meth:" "`__getitem__`, ``x in y`` is ``True`` if and only if there is a non-negative " @@ -1746,17 +1760,17 @@ msgid "" "raised, it is as if :keyword:`in` raised that exception)." msgstr "" -#: ../../reference/expressions.rst:1624 +#: ../../reference/expressions.rst:1634 msgid "" "The operator :keyword:`not in` is defined to have the inverse truth value " "of :keyword:`in`." msgstr "" -#: ../../reference/expressions.rst:1637 +#: ../../reference/expressions.rst:1647 msgid "Identity comparisons" msgstr "" -#: ../../reference/expressions.rst:1639 +#: ../../reference/expressions.rst:1649 msgid "" "The operators :keyword:`is` and :keyword:`is not` test for an object's " "identity: ``x is y`` is true if and only if *x* and *y* are the same " @@ -1764,11 +1778,11 @@ msgid "" "``x is not y`` yields the inverse truth value. [#]_" msgstr "" -#: ../../reference/expressions.rst:1651 +#: ../../reference/expressions.rst:1661 msgid "Boolean operations" msgstr "" -#: ../../reference/expressions.rst:1662 +#: ../../reference/expressions.rst:1672 msgid "" "In the context of Boolean operations, and also when expressions are used by " "control flow statements, the following values are interpreted as false: " @@ -1779,25 +1793,25 @@ msgid "" "method." msgstr "" -#: ../../reference/expressions.rst:1671 +#: ../../reference/expressions.rst:1681 msgid "" "The operator :keyword:`not` yields ``True`` if its argument is false, " "``False`` otherwise." msgstr "" -#: ../../reference/expressions.rst:1676 +#: ../../reference/expressions.rst:1686 msgid "" "The expression ``x and y`` first evaluates *x*; if *x* is false, its value " "is returned; otherwise, *y* is evaluated and the resulting value is returned." msgstr "" -#: ../../reference/expressions.rst:1681 +#: ../../reference/expressions.rst:1691 msgid "" "The expression ``x or y`` first evaluates *x*; if *x* is true, its value is " "returned; otherwise, *y* is evaluated and the resulting value is returned." msgstr "" -#: ../../reference/expressions.rst:1684 +#: ../../reference/expressions.rst:1694 msgid "" "Note that neither :keyword:`and` nor :keyword:`or` restrict the value and " "type they return to ``False`` and ``True``, but rather return the last " @@ -1808,11 +1822,11 @@ msgid "" "argument (for example, ``not 'foo'`` produces ``False`` rather than ``''``.)" msgstr "" -#: ../../reference/expressions.rst:1694 +#: ../../reference/expressions.rst:1704 msgid "Assignment expressions" msgstr "" -#: ../../reference/expressions.rst:1699 +#: ../../reference/expressions.rst:1709 msgid "" "An assignment expression (sometimes also called a \"named expression\" or " "\"walrus\") assigns an :token:`~python-grammar:expression` to an :token:" @@ -1820,44 +1834,44 @@ msgid "" "`~python-grammar:expression`." msgstr "" -#: ../../reference/expressions.rst:1704 +#: ../../reference/expressions.rst:1714 msgid "One common use case is when handling matched regular expressions:" msgstr "" -#: ../../reference/expressions.rst:1711 +#: ../../reference/expressions.rst:1721 msgid "Or, when processing a file stream in chunks:" msgstr "" -#: ../../reference/expressions.rst:1718 +#: ../../reference/expressions.rst:1728 msgid "See :pep:`572` for more details about assignment expressions." msgstr "" -#: ../../reference/expressions.rst:1725 +#: ../../reference/expressions.rst:1735 msgid "Conditional expressions" msgstr "" -#: ../../reference/expressions.rst:1737 +#: ../../reference/expressions.rst:1747 msgid "" "Conditional expressions (sometimes called a \"ternary operator\") have the " "lowest priority of all Python operations." msgstr "" -#: ../../reference/expressions.rst:1740 +#: ../../reference/expressions.rst:1750 msgid "" "The expression ``x if C else y`` first evaluates the condition, *C* rather " "than *x*. If *C* is true, *x* is evaluated and its value is returned; " "otherwise, *y* is evaluated and its value is returned." msgstr "" -#: ../../reference/expressions.rst:1744 +#: ../../reference/expressions.rst:1754 msgid "See :pep:`308` for more details about conditional expressions." msgstr "" -#: ../../reference/expressions.rst:1751 +#: ../../reference/expressions.rst:1761 msgid "Lambdas" msgstr "" -#: ../../reference/expressions.rst:1762 +#: ../../reference/expressions.rst:1772 msgid "" "Lambda expressions (sometimes called lambda forms) are used to create " "anonymous functions. The expression ``lambda parameters: expression`` yields " @@ -1865,25 +1879,25 @@ msgid "" "defined with:" msgstr "" -#: ../../reference/expressions.rst:1771 +#: ../../reference/expressions.rst:1781 msgid "" "See section :ref:`function` for the syntax of parameter lists. Note that " "functions created with lambda expressions cannot contain statements or " "annotations." msgstr "" -#: ../../reference/expressions.rst:1779 +#: ../../reference/expressions.rst:1789 msgid "Expression lists" msgstr "" -#: ../../reference/expressions.rst:1793 +#: ../../reference/expressions.rst:1803 msgid "" "Except when part of a list or set display, an expression list containing at " "least one comma yields a tuple. The length of the tuple is the number of " "expressions in the list. The expressions are evaluated from left to right." msgstr "" -#: ../../reference/expressions.rst:1802 +#: ../../reference/expressions.rst:1812 msgid "" "An asterisk ``*`` denotes :dfn:`iterable unpacking`. Its operand must be " "an :term:`iterable`. The iterable is expanded into a sequence of items, " @@ -1891,12 +1905,12 @@ msgid "" "unpacking." msgstr "" -#: ../../reference/expressions.rst:1807 +#: ../../reference/expressions.rst:1817 msgid "" "Iterable unpacking in expression lists, originally proposed by :pep:`448`." msgstr "" -#: ../../reference/expressions.rst:1812 +#: ../../reference/expressions.rst:1822 msgid "" "The trailing comma is required only to create a single tuple (a.k.a. a " "*singleton*); it is optional in all other cases. A single expression " @@ -1905,28 +1919,28 @@ msgid "" "parentheses: ``()``.)" msgstr "" -#: ../../reference/expressions.rst:1822 +#: ../../reference/expressions.rst:1832 msgid "Evaluation order" msgstr "" -#: ../../reference/expressions.rst:1826 +#: ../../reference/expressions.rst:1836 msgid "" "Python evaluates expressions from left to right. Notice that while " "evaluating an assignment, the right-hand side is evaluated before the left-" "hand side." msgstr "" -#: ../../reference/expressions.rst:1829 +#: ../../reference/expressions.rst:1839 msgid "" "In the following lines, expressions will be evaluated in the arithmetic " "order of their suffixes::" msgstr "" -#: ../../reference/expressions.rst:1843 +#: ../../reference/expressions.rst:1853 msgid "Operator precedence" msgstr "" -#: ../../reference/expressions.rst:1848 +#: ../../reference/expressions.rst:1858 msgid "" "The following table summarizes the operator precedence in Python, from " "highest precedence (most binding) to lowest precedence (least binding). " @@ -1935,176 +1949,176 @@ msgid "" "left to right (except for exponentiation, which groups from right to left)." msgstr "" -#: ../../reference/expressions.rst:1854 +#: ../../reference/expressions.rst:1864 msgid "" "Note that comparisons, membership tests, and identity tests, all have the " "same precedence and have a left-to-right chaining feature as described in " "the :ref:`comparisons` section." msgstr "" -#: ../../reference/expressions.rst:1860 +#: ../../reference/expressions.rst:1870 msgid "Operator" msgstr "" -#: ../../reference/expressions.rst:1860 +#: ../../reference/expressions.rst:1870 msgid "Description" msgstr "描述" -#: ../../reference/expressions.rst:1862 +#: ../../reference/expressions.rst:1872 msgid "``(expressions...)``," msgstr "``(expressions...)``," -#: ../../reference/expressions.rst:1864 +#: ../../reference/expressions.rst:1874 msgid "``[expressions...]``, ``{key: value...}``, ``{expressions...}``" msgstr "``[expressions...]``, ``{key: value...}``, ``{expressions...}``" -#: ../../reference/expressions.rst:1862 +#: ../../reference/expressions.rst:1872 msgid "" "Binding or parenthesized expression, list display, dictionary display, set " "display" msgstr "" -#: ../../reference/expressions.rst:1868 +#: ../../reference/expressions.rst:1878 msgid "``x[index]``, ``x[index:index]``, ``x(arguments...)``, ``x.attribute``" msgstr "``x[index]``, ``x[index:index]``, ``x(arguments...)``, ``x.attribute``" -#: ../../reference/expressions.rst:1868 +#: ../../reference/expressions.rst:1878 msgid "Subscription, slicing, call, attribute reference" msgstr "" -#: ../../reference/expressions.rst:1871 +#: ../../reference/expressions.rst:1881 msgid ":keyword:`await` ``x``" msgstr ":keyword:`await` ``x``" -#: ../../reference/expressions.rst:1873 +#: ../../reference/expressions.rst:1883 msgid "``**``" msgstr "``**``" -#: ../../reference/expressions.rst:1873 +#: ../../reference/expressions.rst:1883 msgid "Exponentiation [#]_" msgstr "" -#: ../../reference/expressions.rst:1875 +#: ../../reference/expressions.rst:1885 msgid "``+x``, ``-x``, ``~x``" msgstr "``+x``, ``-x``, ``~x``" -#: ../../reference/expressions.rst:1875 +#: ../../reference/expressions.rst:1885 msgid "Positive, negative, bitwise NOT" msgstr "" -#: ../../reference/expressions.rst:1877 +#: ../../reference/expressions.rst:1887 msgid "``*``, ``@``, ``/``, ``//``, ``%``" msgstr "``*``, ``@``, ``/``, ``//``, ``%``" -#: ../../reference/expressions.rst:1877 +#: ../../reference/expressions.rst:1887 msgid "" "Multiplication, matrix multiplication, division, floor division, remainder " "[#]_" msgstr "" -#: ../../reference/expressions.rst:1881 +#: ../../reference/expressions.rst:1891 msgid "``+``, ``-``" msgstr "``+``, ``-``" -#: ../../reference/expressions.rst:1881 +#: ../../reference/expressions.rst:1891 msgid "Addition and subtraction" msgstr "" -#: ../../reference/expressions.rst:1883 +#: ../../reference/expressions.rst:1893 msgid "``<<``, ``>>``" msgstr "``<<``, ``>>``" -#: ../../reference/expressions.rst:1883 +#: ../../reference/expressions.rst:1893 msgid "Shifts" msgstr "" -#: ../../reference/expressions.rst:1885 +#: ../../reference/expressions.rst:1895 msgid "``&``" msgstr "``&``" -#: ../../reference/expressions.rst:1885 +#: ../../reference/expressions.rst:1895 msgid "Bitwise AND" msgstr "" -#: ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:1897 msgid "``^``" msgstr "``^``" -#: ../../reference/expressions.rst:1887 +#: ../../reference/expressions.rst:1897 msgid "Bitwise XOR" msgstr "" -#: ../../reference/expressions.rst:1889 +#: ../../reference/expressions.rst:1899 msgid "``|``" msgstr "``|``" -#: ../../reference/expressions.rst:1889 +#: ../../reference/expressions.rst:1899 msgid "Bitwise OR" msgstr "" -#: ../../reference/expressions.rst:1891 +#: ../../reference/expressions.rst:1901 msgid "" ":keyword:`in`, :keyword:`not in`, :keyword:`is`, :keyword:`is not`, ``<``, " "``<=``, ``>``, ``>=``, ``!=``, ``==``" msgstr "" -#: ../../reference/expressions.rst:1891 +#: ../../reference/expressions.rst:1901 msgid "Comparisons, including membership tests and identity tests" msgstr "" -#: ../../reference/expressions.rst:1895 +#: ../../reference/expressions.rst:1905 msgid ":keyword:`not` ``x``" msgstr ":keyword:`not` ``x``" -#: ../../reference/expressions.rst:1895 +#: ../../reference/expressions.rst:1905 msgid "Boolean NOT" msgstr "" -#: ../../reference/expressions.rst:1897 +#: ../../reference/expressions.rst:1907 msgid ":keyword:`and`" msgstr ":keyword:`and`" -#: ../../reference/expressions.rst:1897 +#: ../../reference/expressions.rst:1907 msgid "Boolean AND" msgstr "" -#: ../../reference/expressions.rst:1899 +#: ../../reference/expressions.rst:1909 msgid ":keyword:`or`" msgstr ":keyword:`or`" -#: ../../reference/expressions.rst:1899 +#: ../../reference/expressions.rst:1909 msgid "Boolean OR" msgstr "" -#: ../../reference/expressions.rst:1901 +#: ../../reference/expressions.rst:1911 msgid ":keyword:`if ` -- :keyword:`!else`" msgstr ":keyword:`if ` -- :keyword:`!else`" -#: ../../reference/expressions.rst:1901 +#: ../../reference/expressions.rst:1911 msgid "Conditional expression" msgstr "" -#: ../../reference/expressions.rst:1903 +#: ../../reference/expressions.rst:1913 msgid ":keyword:`lambda`" msgstr ":keyword:`lambda`" -#: ../../reference/expressions.rst:1903 +#: ../../reference/expressions.rst:1913 msgid "Lambda expression" msgstr "" -#: ../../reference/expressions.rst:1905 +#: ../../reference/expressions.rst:1915 msgid "``:=``" msgstr "``:=``" -#: ../../reference/expressions.rst:1905 +#: ../../reference/expressions.rst:1915 msgid "Assignment expression" msgstr "" -#: ../../reference/expressions.rst:1910 +#: ../../reference/expressions.rst:1920 msgid "Footnotes" msgstr "註解" -#: ../../reference/expressions.rst:1911 +#: ../../reference/expressions.rst:1921 msgid "" "While ``abs(x%y) < abs(y)`` is true mathematically, for floats it may not be " "true numerically due to roundoff. For example, and assuming a platform on " @@ -2116,7 +2130,7 @@ msgid "" "approach is more appropriate depends on the application." msgstr "" -#: ../../reference/expressions.rst:1920 +#: ../../reference/expressions.rst:1930 msgid "" "If x is very close to an exact integer multiple of y, it's possible for ``x//" "y`` to be one larger than ``(x-x%y)//y`` due to rounding. In such cases, " @@ -2124,7 +2138,7 @@ msgid "" "* y + x % y`` be very close to ``x``." msgstr "" -#: ../../reference/expressions.rst:1925 +#: ../../reference/expressions.rst:1935 msgid "" "The Unicode standard distinguishes between :dfn:`code points` (e.g. U+0041) " "and :dfn:`abstract characters` (e.g. \"LATIN CAPITAL LETTER A\"). While most " @@ -2138,7 +2152,7 @@ msgid "" "(COMBINING CEDILLA)." msgstr "" -#: ../../reference/expressions.rst:1936 +#: ../../reference/expressions.rst:1946 msgid "" "The comparison operators on strings compare at the level of Unicode code " "points. This may be counter-intuitive to humans. For example, ``\"\\u00C7\" " @@ -2146,13 +2160,13 @@ msgid "" "same abstract character \"LATIN CAPITAL LETTER C WITH CEDILLA\"." msgstr "" -#: ../../reference/expressions.rst:1941 +#: ../../reference/expressions.rst:1951 msgid "" "To compare strings at the level of abstract characters (that is, in a way " "intuitive to humans), use :func:`unicodedata.normalize`." msgstr "" -#: ../../reference/expressions.rst:1944 +#: ../../reference/expressions.rst:1954 msgid "" "Due to automatic garbage-collection, free lists, and the dynamic nature of " "descriptors, you may notice seemingly unusual behaviour in certain uses of " @@ -2160,13 +2174,13 @@ msgid "" "instance methods, or constants. Check their documentation for more info." msgstr "" -#: ../../reference/expressions.rst:1949 +#: ../../reference/expressions.rst:1959 msgid "" "The power operator ``**`` binds less tightly than an arithmetic or bitwise " "unary operator on its right, that is, ``2**-1`` is ``0.5``." msgstr "" -#: ../../reference/expressions.rst:1952 +#: ../../reference/expressions.rst:1962 msgid "" "The ``%`` operator is also used for string formatting; the same precedence " "applies."