Member-only story
Common Use Cases of Ellipsis (…) in Python
Learn to use ellipsis in different scenarios in your Python code
The Ellipsis in Python is a built-in object represented by three consecutive dots (…). It’s known as the Ellipsis object and can serve several purposes in Python code. In this post, we will introduce different scenarios where Ellipsis (…) is commonly used.
Placeholder for code
Firstly, the ellipsis literal … can be used as a placeholder to indicate that some code is intentionally left empty and will be implemented in the future.
def new_func():
"""This is a new func and will be defined later."""
...This is similar to using pass in a class or function body but is often preferred for indicating incomplete sections.
Indicate variable-length tuples in type hints
Ellipsis can also be used to denote a tuple of arbitrary length where each element is of the same type.










