Overview, Historical Timeline, Problems & Solutions
An Overview of Python Ellipsis
What is the Python Ellipsis?
You may have seen three dots ...
used in writing to mean "and so on." In Python, these three dots are called the Ellipsis object. Python includes this object to give special meaning in code.
The Python Ellipsis is a built-in object that shows up when you write ...
in your code. It does not mean anything on its own. But tools, libraries, and Python features can use it to mark a missing part, a slice, or something left to be done later.
Python lets you use the ellipsis ...
to show a placeholder or extended slice.
x = ...
print(x) # prints: Ellipsis
The three dots become the built-in object named Ellipsis
. Python knows what it is and keeps it as a single object.
How does the Python Ellipsis work in slices?
When you write a slice like a[1:5]
, you use the :
symbol to mark a range. In some advanced cases, like working with multi-dimensional arrays, you can use ...
in a slice to show “all remaining dimensions.”
This is used in tools like NumPy. The ellipsis tells the code to leave part of the slice open.
Python lets tools use ...
to slice higher-dimensional data.
a = (1, 2, 3, 4)
print(a[...]) # prints: (1, 2, 3, 4)
Python keeps the ...
in the code and sends it to the object’s slicing logic. Regular built-in types may not change behavior, but custom types can.
What is the truth value of Python Ellipsis?
Every Python object has a truth value. This means Python treats it as either true or false in a condition. The Python Ellipsis is always true.
Python treats Ellipsis as a true value.
if ...:
print("Ellipsis is true") # prints: Ellipsis is true
Even though the Ellipsis looks like it might mean “nothing,” it acts like something in Python. It is not None
. It is not false. It is its own object, and it is always true.
A Historical Timeline of Python Ellipsis
Where does the Python Ellipsis come from?
Python includes the Ellipsis object as part of its core object model. It began as a placeholder for special use cases in slicing and later became a standard way to signal "unfinished" parts of code.
People created markers for ranges and slices.
1960 — Slice notation ALGOL and early languages introduced the idea of selecting parts of arrays using index notation.
1980 — Advanced slicing in arrays MATLAB and APL used ranges and wildcards to cut across multi-dimensional data.
Python added a built-in object for placeholder syntax.
2000 — Ellipsis object added Python 2.0 added the ...
literal, mapped to the built-in object Ellipsis
, for use in extended slices.
2001 — Use in custom types Tools like NumPy began using ...
in slice notation to improve readability in array operations.
Python did not extend the use of ellipsis further.
2010 — Placeholders in stubs Python style guides began using ...
to mark not-yet-implemented code in function bodies.
2025 — Ellipsis remains stable Python continues to support the ellipsis as a literal and placeholder without change.
Problems & Solutions with Python Ellipsis
How do you use the Python Ellipsis the right way?
The ellipsis ...
is a symbol most people know from writing. In Python, it becomes a special object. You do not use it every day, but in certain cases, it can help make your code more flexible or easier to finish later. These problems show how Python's ellipsis object works and why it exists.
Problem: How do you leave a function unimplemented in Python?
You are building out a class or a set of functions. Some parts are ready, but some functions are not written yet. You want your code to run without errors, but you also want to mark what still needs work.
Problem: You want to write down the name of a function before writing the full body.
Solution: Use the ellipsis ...
as a placeholder. This lets the code run, but it reminds you that the body is not done yet.
Python lets you leave a function body unfinished using ...
.
def future_feature():
...
print(future_feature()) # prints: None
This defines the function without raising an error. The ellipsis works like a valid but empty statement.
Problem: How do you create a placeholder value in Python?
You are designing a pipeline where some parts are not connected yet. You want to show that something will go there in the future, but not right now.
Problem: You want a value that shows "not done" or "to be filled in later" but still runs.
Solution: Use the ...
ellipsis as a clear marker.
Python lets you use ...
as a safe placeholder value.
next_step = ...
print(next_step) # prints: Ellipsis
This lets you write and run the rest of the code. The Ellipsis
object stays in place until replaced.
Problem: How do you match dimensions in a slice in Python?
You are using a library that works with multi-dimensional data. You want to slice only one part of the data but leave the rest untouched.
Problem: You want to pick one row in a multi-row dataset without writing out every slice.
Solution: Use the ...
ellipsis in the slice to cover the remaining dimensions.
Python lets libraries use ...
in slices for extra dimensions.
class Data:
def __getitem__(self, key):
return key
d = Data()
print(d[1, ..., 2]) # prints: (1, Ellipsis, 2)
Here, the object keeps the Ellipsis
in the slice. This is useful for NumPy arrays and similar tools.
Problem: How do you check if a value is Ellipsis in Python?
You are reading data or receiving input. Sometimes, the input includes ...
to mark something left out. You want to test for it.
Problem: You need to see if a value is the ellipsis object.
Solution: Use identity testing with is
.
Python lets you check for ...
using is
.
x = ...
if x is Ellipsis:
print("This is an ellipsis") # prints: This is an ellipsis
This check works because ...
is always the same object as Ellipsis
.
Problem: How do you use ...
in a condition in Python?
You want to test how Python treats different values in an if-statement. You expect ...
to act like an empty value, but Python treats it differently.
Problem: You assume ...
is false in a condition.
Solution: Know that Python treats Ellipsis
as true.
Python treats Ellipsis as a true value in conditions.
if ...:
print("Yes") # prints: Yes
else:
print("No")
Even though it looks like a “missing” part, Python sees the ellipsis as something, not nothing.
Like, Comment, Share, and Subscribe
Did you find this helpful? Let me know by clicking the like button below. I'd love to hear your thoughts in the comments, too! If you want to see more content like this, don't forget to subscribe. Thanks for reading!
Mike Vincent is an American software engineer and app developer from Los Angeles, California. More about Mike Vincent
Top comments (0)