Ellipsis is used mainly by the numeric python extension, which adds a multidimensional array type. Since there are more than one dimensions, slicing becomes more complex than just a start and stop index; it is useful to be able to slice in multiple dimensions as well. eg, given a 4x4 array, the top left area would be defined by the slice "[:2,:2]"

>>> a
array([[ 1,  2,  3,  4],
       [ 5,  6,  7,  8],
       [ 9, 10, 11, 12],
       [13, 14, 15, 16]])

>>> a[:2,:2]  # top left
array([[1, 2],
       [5, 6]])

Ellipsis is used here to indicate a placeholder for the rest of the array dimensions not specified. Think of it as indicating the full slice [:] for dimensions not specified, so for a 3d array, a[...,0] is the same as a[:,:,0] and for 4d, a[:,:,:,0].

Note that the actual Ellipsis literal (...) is not usable outside the slice syntax in python2, though there is a builtin Ellipsis object. This is what is meant by "The conversion of an ellipsis slice item is the built-in Ellipsis object." ie. "a[...]" is effectively sugar for "a[Ellipsis]". In python3, ... denotes Ellipsis anywhere, so you can write:

>>> ...
Ellipsis

If you're not using numpy, you can pretty much ignore all mention of Ellipsis. None of the builtin types use it, so really all you have to care about is that lists get passed a single slice object, that contains "start","stop" and "step" members. ie:

l[start:stop:step]   # proper_slice syntax from the docs you quote.

is equivalent to calling:

l.__getitem__(slice(start, stop, step))
Answer from Brian on Stack Overflow
🌐
Python
docs.python.org › 3 › c-api › slice.html
Slice Objects — Python 3.15.2 documentation
3.15.2 documentation » · Python/C API reference manual » · Concrete Objects Layer » · Slice Objects · | Theme · Auto · Light · Dark | PyTypeObject PySlice_Type¶ · Part of the Stable ABI. The type object for slice objects. This is the same as slice in the Python layer.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › brackets › slicing.html
[] (slicing) — Python Reference (The Right Way) 0.1 documentation
>>> +---+---+---+---+ >>> |-4 |-3 |-2 |-1 | <= negative indexes >>> +---+---+---+---+ >>> | A | B | C | D | <= sequence elements >>> +---+---+---+---+ >>> | 0 | 1 | 2 | 3 | <= positive indexes >>> +---+---+---+---+ >>> |<- 0:3:1 ->| <= extent of the slice: "ABCD"[0:3:1]
🌐
W3Schools
w3schools.com › python › ref_func_slice.asp
Python slice() Function
Start the slice object at position 3, and slice to position 5, and return the result:
🌐
Real Python
realpython.com › ref › builtin-functions › slice
slice() | Python’s Built-in Functions – Real Python
Returns a slice object that can be used to extract a portion of a sequence. Since Python 3.12, slice objects are hashable, provided that start, stop, and step are hashable, so they can be dictionary keys or set members.
🌐
DataCamp
datacamp.com › home › tutorials › python › python slice: useful methods for everyday coding
Python Slice: Useful Methods for Everyday Coding | DataCamp
January 15, 2025 - As I said, slicing is a core feature in Python, allowing developers to extract portions of sequences like lists, strings, and tuples. Python offers two primary ways to slice sequences without importing anything: the slicing : syntax and the slice() function.
Top answer
1 of 3
35

Ellipsis is used mainly by the numeric python extension, which adds a multidimensional array type. Since there are more than one dimensions, slicing becomes more complex than just a start and stop index; it is useful to be able to slice in multiple dimensions as well. eg, given a 4x4 array, the top left area would be defined by the slice "[:2,:2]"

>>> a
array([[ 1,  2,  3,  4],
       [ 5,  6,  7,  8],
       [ 9, 10, 11, 12],
       [13, 14, 15, 16]])

>>> a[:2,:2]  # top left
array([[1, 2],
       [5, 6]])

Ellipsis is used here to indicate a placeholder for the rest of the array dimensions not specified. Think of it as indicating the full slice [:] for dimensions not specified, so for a 3d array, a[...,0] is the same as a[:,:,0] and for 4d, a[:,:,:,0].

Note that the actual Ellipsis literal (...) is not usable outside the slice syntax in python2, though there is a builtin Ellipsis object. This is what is meant by "The conversion of an ellipsis slice item is the built-in Ellipsis object." ie. "a[...]" is effectively sugar for "a[Ellipsis]". In python3, ... denotes Ellipsis anywhere, so you can write:

>>> ...
Ellipsis

If you're not using numpy, you can pretty much ignore all mention of Ellipsis. None of the builtin types use it, so really all you have to care about is that lists get passed a single slice object, that contains "start","stop" and "step" members. ie:

l[start:stop:step]   # proper_slice syntax from the docs you quote.

is equivalent to calling:

l.__getitem__(slice(start, stop, step))
2 of 3
27

Defining simple test class that just prints what is being passed:

>>> class TestGetitem(object):
...   def __getitem__(self, item):
...     print type(item), item
... 
>>> t = TestGetitem()

Expression example:

>>> t[1]
<type 'int'> 1
>>> t[3-2]
<type 'int'> 1
>>> t['test']
<type 'str'> test
>>> t[t]
<class '__main__.TestGetitem'> <__main__.TestGetitem object at 0xb7e9bc4c>

Slice example:

>>> t[1:2]
<type 'slice'> slice(1, 2, None)
>>> t[1:'this':t]
<type 'slice'> slice(1, 'this', <__main__.TestGetitem object at 0xb7e9bc4c>)

Ellipsis example:

>>> t[...]
<type 'ellipsis'> Ellipsis

Tuple with ellipsis and slice:

>>> t[...,1:]
<type 'tuple'> (Ellipsis, slice(1, None, None))
🌐
Codecademy
codecademy.com › docs › python › built-in functions › slice()
Python | Built-in Functions | slice() | Codecademy
September 26, 2025 - The slice() function creates a slice object that specifies how to slice sequences like strings, lists, tuples, and ranges. It provides a way to extract specific portions of sequences by defining the start, stop, and step parameters, offering ...
🌐
Programiz
programiz.com › python-programming › slicing
Python Slicing (With Code Visualization)
August 4, 2026 - text = "ABCDEFGH" # Reverse slice: index 6 down to index 1 print(text[6:1:-1]) # Output: GFEDC # Reverse slice: index -3 down to index -6, every 2nd item print(text[-3:-6:-2]) # Output: FD · If we omit the start index, slicing starts from the beginning of the sequence. And if we omit the stop index, slicing goes up to the end of the sequence. If we omit both, we get a copy of the entire sequence. text = "Python" # Omit stop: from index 2 to the end print(text[2:]) # Output: thon # Omit start: from the beginning up to index 4 print(text[:4]) # Output: Pyth # Omit both: the entire sequence print(text[:]) # Output: Python
Find elsewhere
🌐
W3Schools
w3schools.com › python › python_strings_slicing.asp
Python - Slicing Strings
You can return a range of characters by using the slice syntax.
🌐
Programiz
programiz.com › python-programming › methods › built-in › slice
Python slice() | Programiz
March 14, 2024 - Note: We can use slice with any object which supports sequence protocol (implements __getitem__() and __len()__ method).
🌐
Towards Data Science
towardsdatascience.com › home › data science › slicing in python: a comprehensive guide
Slicing in Python: A Comprehensive Guide | Towards Data Science
June 5, 2024 - A negative step value will reverse the direction of the slice (hence stop needs to be smaller than start). Python uses the following convention for slicing (including ranging): take the first element of a range/slice, but exclude the last one.
🌐
TechVidvan
techvidvan.com › tutorials › python-slicing
Slicing in Python with Python Slice Function and Indexing - TechVidvan
April 11, 2020 - The slice function takes in the values of start, stop and step as arguments and returns a slice object. This slice object can then be passed within the square brackets in place of start:stop:step to access the desired slice.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › slice.html
slice — Python Reference (The Right Way) 0.1 documentation
Slice objects have read-only data attributes start, stop and step which merely return the argument values (or their default). They have no other explicit functionality; however they are used by Numerical Python and other third party extensions. Slice objects are also generated when extended indexing syntax is used.
🌐
Python Tutorial
pythontutorial.net › home › advanced python › python slicing in depth
Python Slicing in Depth
March 27, 2025 - The slice seq[start:stop] selects elements starting at the index start and stopping at the index stop (excluding the element at the index stop). In other words, it returns all elements of the sequence at the index n where n satisfies the following ...
🌐
Stack Overflow
stackoverflow.com › questions › 509211 › understanding-slicing
slice - How slicing in Python works - Stack Overflow
March 28, 2022 - How does Python's slice notation work? That is: when I write code like a[x:y:z], a[:], a[::2] etc., how can I understand which elements end up in the slice? See Why are slice and range upper-bound
🌐
Simplilearn
simplilearn.com › home › resources › software development › your ultimate python tutorial for beginners › everything you need to know about python slicing
Everything You Need to Know About Python Slicing
January 26, 2025 - Python is a widely used, general-purpose programming language. So what is slicing and negative indices? Learn all about Python slicing, index, & more. Read On!
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Codemia
codemia.io › home › knowledge hub › how slicing in python works
How slicing in Python works | Codemia
September 23, 2025 - 1# Define a list 2numbers = [0, ... 18print(numbers[-3:]) # Output: [7, 8, 9] 19print(numbers[:-3]) # Output: [0, 1, 2, 3, 4, 5, 6] Python allows the use of negative indices for slicing....
🌐
Real Python
realpython.com › ref › glossary › slice
slice | Python Glossary – Real Python
>>> numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> # Slice from index 2 to 5 >>> subset = numbers[2:6] >>> subset [2, 3, 4, 5] >>> # Slice with a step of 2 >>> step_slice = numbers[0:9:2] >>> step_slice [0, 2, 4, 6, 8] >>> # Slice from index 4 to the end >>> end_slice = numbers[4:] >>> end_slice [4, 5, 6, 7, 8, 9] >>> # Reverse the list using slicing >>> reversed_list = numbers[::-1] >>> reversed_list [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] All three parts of start:stop:step are optional, and any part you leave out arrives as None, which the sequence reads as a sensible default. When Python evaluates the notation, it bundles the three values into a slice object and hands that object to the container’s .__getitem__() method.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-slicing
Python List Slicing - GeeksforGeeks
Explanation: slice a[::-1] starts from the end of the list and moves backward one element at a time, returning a reversed copy of the list.
Published: July 16, 2026
🌐
freeCodeCamp
freecodecamp.org › news › slicing-and-indexing-in-python
Slicing and Indexing in Python – Explained with Examples
December 11, 2025 - In Python, you perform slicing using the colon : operator. The syntax for slicing is as follows: ... where start_index is the index of the first element in the sub-sequence and end_index is the index of the last element in the sub-sequence ...