Skip to content

Conversation

adorilson
Copy link
Contributor

@adorilson adorilson commented Aug 31, 2025

After a discuss thread, this PR updates the Ellipsis documentation.


📚 Documentation preview 📚: https://cpython-previews--138306.org.readthedocs.build/

@picnixz

This comment was marked as resolved.

@picnixz picnixz changed the title Doc: Update the Ellipsis documentation gh-138307: Update the Ellipsis documentation Aug 31, 2025
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
appears in :ref:`pretty printers <prettyprinter-objects>`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets awkward: the use in pretty printing is three dots, but it's not an Ellipsis object. It's a typographic convention for omitted content (which is why Python uses three dots for this).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it.

Do you think we should add this third type to the glossary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise recursive_repr uses ... but it's not the Ellipsis form of ....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about doctest.ELLIPIS? Now, I'm thinking it is three dots, not the Ellipsis object.

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, in the standard library and its documentation, ``Ellipsis`` can
appears in
:const:`documentation tests <doctest.ELLIPSIS>`,
Copy link
Member

@nedbat nedbat Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doctest.ELLIPSIS is not an Ellipsis object. It's yet another instance of using three dots to mean "something is missing here." In a doctest, ... matches any text, like .* in a regex.

BTW, another use of three dots is the secondary REPL prompt:

>>> (
...

We can list out these "faux Ellipses" (not in those words) as a way of helping people who end up here because they were trying to figure out what something means.

I would structure it something like this:

In typical use, ``...`` as an Ellipsis appears in a few different places:
- In type annotations for :ref:`Callable arguments <annotating-callables>` or `tuple elements <find-the-reference>`
- As the body of a function instead of a :ref:`pass statement <tut-pass>`
- In third-party libraries, such as Numpy's slicing and striding <https://numpy.org/doc/stable/user/basics.indexing.html#slicing-and-striding>`_

Python also uses three dots in ways that are not Ellipsis objects:
- Doctest's :const:`doctest.ELLIPSIS`, as a pattern for missing content
- As the interactive prompt for "please finish your statement"

Lastly, the Python documentation often uses three dots in conventional English usage to mean omitted content, even in code examples that also use them as an Ellipsis.

Comment on lines 68 to 69
The same as the ellipsis literal "``...``", an object frequently used as a
placeholder for another value. Assignment to ``Ellipsis`` is possible, but
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure "a placeholder for another value" is a good summary. I don't think it describes many of the typing use cases, for one.

Maybe "to indicate that something is omitted"?

For instance, in the standard library and its documentation, ``Ellipsis`` can
appears in
:const:`documentation tests <doctest.ELLIPSIS>`,
:ref:`type annotations <annotating-callables>`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link goes to callables (Callable[..., T] meaning a gradual type covering callables with any sets of arguments), but this is not the only use in typing. It's also used for variable-length tuples (tuple[int, ...]), to represent an omitted default value in stubs or overloads (def f(x: int = ...) -> None:), and as an empty body for a function in stubs and a few other contexts (def f(x: int) -> None: ...).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely don't have the right links, i wanted to get the language right first.

@adorilson
Copy link
Contributor Author

@nedbat @JelleZijlstra

The latest commits address your latest comments.
Beside, I changed the ... glossary entry to mention Ellipsis object instead of the constant one.
I think It's more useful now.

Thank you for the comments and suggestions.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For this last case, many people use the ellipsis literal :code:`...` instead of
For this last case, many people use the Ellipsis literal :code:`...` instead of

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

Copy link
Member

@JelleZijlstra JelleZijlstra Sep 2, 2025

Choose a reason for hiding this comment

The 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)

Copy link
Member

@nedbat nedbat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small tweaks and it's ready to go.

@nedbat nedbat merged commit 88665de into python:main Sep 3, 2025
27 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Sep 3, 2025
@nedbat nedbat added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Sep 3, 2025
@miss-islington-app
Copy link

Thanks @adorilson for the PR, and @nedbat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @adorilson for the PR, and @nedbat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 3, 2025
* Doc: Change Ellipsis doc at library/constants

* Doc: Change Ellipsis doc at library/stdtypes

* Doc: Add NumPy reference into Ellipsis doc at library/stdtypes

* Doc: Add Ellipsis reference into the pass statement section at tutorial

* Doc: Update Ellipsis doc concerns assignments at library/constants

* Update Doc/library/stdtypes.rst

Co-authored-by: Stan Ulbrych <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/constants.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Remove pretty printers reference from Ellipsis doc at library/stdtypes

* Doc: Update index concerns Ellipsis object and pass statement

* Doc: Improve Ellipsis doc at library/constants

* Doc: Improve Ellipsis doc at library/stdtypes

* Doc: Change the "..." glossary entry to mention the Ellipsis object

* Doc: Some improvements concern ellipsis into typing doc

* Minor update Doc/tutorial/controlflow.rst

Co-authored-by: Ned Batchelder <[email protected]>

* Update Doc/library/constants.rst

Co-authored-by: Ned Batchelder <[email protected]>

* Update Doc/library/stdtypes.rst

Co-authored-by: Ned Batchelder <[email protected]>

---------
(cherry picked from commit 88665de)

Co-authored-by: Adorilson Bezerra <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>
Co-authored-by: Éric <[email protected]>
Co-authored-by: Ned Batchelder <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 3, 2025
* Doc: Change Ellipsis doc at library/constants

* Doc: Change Ellipsis doc at library/stdtypes

* Doc: Add NumPy reference into Ellipsis doc at library/stdtypes

* Doc: Add Ellipsis reference into the pass statement section at tutorial

* Doc: Update Ellipsis doc concerns assignments at library/constants

* Update Doc/library/stdtypes.rst

Co-authored-by: Stan Ulbrych <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/constants.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Remove pretty printers reference from Ellipsis doc at library/stdtypes

* Doc: Update index concerns Ellipsis object and pass statement

* Doc: Improve Ellipsis doc at library/constants

* Doc: Improve Ellipsis doc at library/stdtypes

* Doc: Change the "..." glossary entry to mention the Ellipsis object

* Doc: Some improvements concern ellipsis into typing doc

* Minor update Doc/tutorial/controlflow.rst

Co-authored-by: Ned Batchelder <[email protected]>

* Update Doc/library/constants.rst

Co-authored-by: Ned Batchelder <[email protected]>

* Update Doc/library/stdtypes.rst

Co-authored-by: Ned Batchelder <[email protected]>

---------
(cherry picked from commit 88665de)

Co-authored-by: Adorilson Bezerra <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>
Co-authored-by: Éric <[email protected]>
Co-authored-by: Ned Batchelder <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Sep 3, 2025

GH-138439 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 3, 2025
@bedevere-app
Copy link

bedevere-app bot commented Sep 3, 2025

GH-138440 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Sep 3, 2025
JelleZijlstra pushed a commit that referenced this pull request Sep 5, 2025
)

(cherry picked from commit 88665de)

Co-authored-by: Adorilson Bezerra <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>
Co-authored-by: Éric <[email protected]>
Co-authored-by: Ned Batchelder <[email protected]>
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
* Doc: Change Ellipsis doc at library/constants

* Doc: Change Ellipsis doc at library/stdtypes

* Doc: Add NumPy reference into Ellipsis doc at library/stdtypes

* Doc: Add Ellipsis reference into the pass statement section at tutorial

* Doc: Update Ellipsis doc concerns assignments at library/constants

* Update Doc/library/stdtypes.rst

Co-authored-by: Stan Ulbrych <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/constants.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Fix grammar on Ellipsis docs (library/stdtypes.rst)

Co-authored-by: Éric <[email protected]>

* Doc: Remove pretty printers reference from Ellipsis doc at library/stdtypes

* Doc: Update index concerns Ellipsis object and pass statement

* Doc: Improve Ellipsis doc at library/constants

* Doc: Improve Ellipsis doc at library/stdtypes

* Doc: Change the "..." glossary entry to mention the Ellipsis object

* Doc: Some improvements concern ellipsis into typing doc

* Minor update Doc/tutorial/controlflow.rst

Co-authored-by: Ned Batchelder <[email protected]>

* Update Doc/library/constants.rst

Co-authored-by: Ned Batchelder <[email protected]>

* Update Doc/library/stdtypes.rst

Co-authored-by: Ned Batchelder <[email protected]>

---------

Co-authored-by: Stan Ulbrych <[email protected]>
Co-authored-by: Éric <[email protected]>
Co-authored-by: Ned Batchelder <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants