Visitar URL original
gh-106446: Fix failed doctest in stdtypes by CharlieZhao95 路 Pull Request #106447 路 python/cpython 路 GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve doctest
  • Loading branch information
CharlieZhao95 committed Jul 11, 2023
commit a73c1e77fe5eb53d107ca07922e2e34f902d47f5
16 changes: 9 additions & 7 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3766,7 +3766,7 @@ copying.
98
>>> v[-1]
103
>>> v[1:4] # doctest: +SKIP
>>> v[1:4]
<memory at 0x7f3ddc9f4350>
>>> bytes(v[1:4])
b'bce'
Expand Down Expand Up @@ -4786,10 +4786,10 @@ An example of dictionary view usage::
>>> # set operations
>>> keys & {'eggs', 'bacon', 'salad'}
{'bacon'}
>>> keys ^ {'sausage', 'juice'}
{'juice', 'sausage', 'bacon', 'spam'}
>>> keys | ['juice', 'juice', 'juice']
{'bacon', 'spam', 'juice'}
>>> keys ^ {'sausage', 'juice'} == {'juice', 'sausage', 'bacon', 'spam'}
True
>>> keys | ['juice', 'juice', 'juice'] == {'bacon', 'spam', 'juice'}
True

>>> # get back a read-only proxy for the original dictionary
>>> values.mapping
Expand Down Expand Up @@ -5203,9 +5203,11 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
>>> isinstance("", int | str)
True

However, union objects containing :ref:`parameterized generics
<types-genericalias>` cannot be used::
However, :ref:`parameterized generics <types-genericalias>` in
union objects cannot be checked::

>>> isinstance(1, int | list[int]) # short-circuit evaluation
True
>>> isinstance([1], int | list[int])
Traceback (most recent call last):
...
Expand Down