-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-138307: Update the Ellipsis documentation #138306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
01a9007
e8e0582
011ceb9
fae75b7
5688029
f57a7d4
bea09ee
7cbfd39
767dd95
66f0b96
fd21e0a
ce58d75
929e89f
a0dfdd4
57ae57e
9339d93
28258f6
f08b81c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5869,13 +5869,26 @@ It is written as ``None``. | |
The Ellipsis Object | ||
------------------- | ||
|
||
This object is commonly used by slicing (see :ref:`slicings`). It supports no | ||
This object is commonly used as a placeholder of another objects, values or even | ||
instructions. It supports no | ||
adorilson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
special operations. There is exactly one ellipsis object, named | ||
:const:`Ellipsis` (a built-in name). ``type(Ellipsis)()`` produces the | ||
:const:`Ellipsis` singleton. | ||
|
||
It is written as ``Ellipsis`` or ``...``. | ||
|
||
For instance, at the standard library and its documentation, ``Ellipsis`` can | ||
adorilson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
appears in :ref:`pretty printers <prettyprinter-objects>`, | ||
|
||
:const:`documentation tests <doctest.ELLIPSIS>`, | ||
|
||
:ref:`type annotations <annotating-callables>`, | ||
|
||
or instead of :ref:`pass statement <tut-pass>`. | ||
|
||
|
||
.. seealso:: | ||
|
||
`NumPy's slicing and striding <https://numpy.org/doc/stable/user/basics.indexing.html#slicing-and-striding>`_ | ||
A well-known Ellipsis use in third party packages is for slicing in Numpy. | ||
|
||
|
||
.. _bltin-notimplemented-object: | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -251,6 +251,7 @@ statements: a ``try`` statement's ``else`` clause runs when no exception | |||||
occurs, and a loop's ``else`` clause runs when no ``break`` occurs. For more on | ||||||
the ``try`` statement and exceptions, see :ref:`tut-handling`. | ||||||
|
||||||
.. index:: single: ...; placeholder | ||||||
.. _tut-pass: | ||||||
|
||||||
:keyword:`!pass` Statements | ||||||
|
@@ -277,6 +278,12 @@ at a more abstract level. The :keyword:`!pass` is silently ignored:: | |||||
... pass # Remember to implement this! | ||||||
... | ||||||
|
||||||
For this last case, many people use the ellipsis literal :code:`...` instead of | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, I think it is lowercase. Because it is the ellipsis mark, not the object one. Like here: https://docs.python.org/3.13/library/constants.html#Ellipsis There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, it does evaluate to the Ellipsis singleton, even if that value is not used. >>> ast.parse('def f(): ...').body[0].body[0].value
Constant(value=Ellipsis, kind=None) |
||||||
:code:`pass`. This use has no special meaning to Python, and it is not part of | ||||||
adorilson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
the language definition (you could use any constant expression here), but | ||||||
:code:`...` is used conventionally as a placeholder body as well. | ||||||
See :ref:`bltin-ellipsis-object`. | ||||||
|
||||||
|
||||||
.. _tut-match: | ||||||
|
||||||
|
Uh oh!
There was an error while loading. Please reload this page.