What does the Ellipsis object do?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Python, ... is not punctuation magic. It is a real built-in singleton object named Ellipsis. You can write it either as ... or as Ellipsis, and both names refer to the same object.
Most everyday Python code never needs it, which is why it feels mysterious. Its main practical uses are advanced slicing, placeholder bodies, and APIs that intentionally interpret Ellipsis as a special sentinel value.
Ellipsis is a real object
You can inspect it directly in normal Python code:
This prints something like:
Because it is a singleton, identity checks are the right way to compare it:
That makes Ellipsis behave a bit like None in the sense that it can serve as a distinguished marker, but its meaning is entirely up to the surrounding code.
Use it in multidimensional slicing
The most common real-world use is in array libraries such as NumPy. Ellipsis means "fill in however many full slices are needed here."
Without ..., you would have to write all the intermediate colons explicitly. That becomes tedious as dimensionality grows.
For example, these two expressions are equivalent for a three-dimensional array:
The first form is easier to maintain when the number of middle dimensions is large or may change.
Use it as a placeholder deliberately
Python also allows ... as a valid expression, so developers sometimes use it as a placeholder in unfinished code:
This is legal Python. The function body runs and evaluates the Ellipsis object, then immediately returns None. That means it is a placeholder, not a blocker.
If you want unfinished code to fail loudly, raise an exception instead:
That difference matters. ... is silent, while NotImplementedError makes the missing implementation obvious.
Use it as a custom sentinel
Sometimes None already has business meaning, and you need a different sentinel to mean "argument not provided". Ellipsis can serve that role:
This works because Ellipsis is unique and unlikely to appear accidentally in user data. That said, many teams prefer a dedicated private sentinel object because it communicates intent more clearly than reusing Ellipsis.
Common Pitfalls
- Assuming
...automatically means "not implemented" when Python itself gives it no such behavior. - Using
...as a placeholder in a function body and forgetting that the function still executes and returnsNone. - Reusing
Ellipsisas a custom sentinel when a dedicated private sentinel object would communicate intent more clearly. - Confusing the
Ellipsisobject with slicing syntax itself rather than the indexed object's interpretation of it. - Expecting ordinary Python lists or all custom classes to support
...in indexing the way NumPy does.
Summary
- '
...andEllipsisrefer to the same built-in singleton object.' - Its most common practical use is multidimensional slicing, especially in NumPy.
- It can be used as a placeholder, but it does not automatically raise an error.
- '
Ellipsiscan act as a sentinel whenNonealready has a separate meaning.' - Its behavior in indexing depends on the object being indexed, not on Python alone.

