- Ellipsis (...)
Use cases
-
instead of pass
def some_func() ...
- multi-array slicing
import numpy as np
arr = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
print(arr[..., 1]) # Equivalent to arr[:, :, 1]- type hinting
from typing import Any
def process_data(data: Any, config: ...):
pass- sentinel value
def my_function(arg=...):
if arg is ...:
print("Argument not provided")
else:
print("Argument provided:", arg)- Required parameters: Some libraries, like typer, use ... to denote required parameters, which must be provided by the user.