When Do You Use an Ellipsis in Python?
In English writing, you can use the ellipsis to indicate that you’re leaving something out.
Essentially, you use three dots (...
) to replace the content.
But the ellipsis doesn’t only exist in prose—you may have seen three dots in Python source code, too.
The ellipsis literal (...
) evaluates to Python’s Ellipsis
.
Because Ellipsis
is a built-in constant,
you can use Ellipsis
or ...
without importing it:
>>>
>>> ...
Ellipsis
>>> Ellipsis
Ellipsis
>>> ... is Ellipsis
True
Although three dots may look odd as Python syntax, there are situations where using ...
can