Colon, double colon and ellipsis

Posted by Bruce Liu on November 8, 2021

🏷️ Tags: python

List

a = list(range(10))
a[:]
a[::]
a[...]

a[:] is equivalent to a[::]. a[...] was not working.

numpy.array

import numpy as np

a = np.arange(10)
a[:]
a[::]
a[...]

a[:], a[::], and a[...] are equivalent for a numpy.array object. For s[startstep] operation, the default value of start, end, and step is 0, -1, and 1 separately.

Python tools

Share on:

« PREVIOUS: Ports of free hydrodynamic models/softwares