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[start:end:step] operation, the default value of start, end, and step is 0, -1, and 1 separately.

Python tools

Share on:

« PREVIOUS: Comparison of three functors on similarity in DinamicaEGO
NEXT: Add a search bar in Jekyll blogsite »