Skip to content

Instantly share code, notes, and snippets.

@raspberrypisig
Created June 8, 2025 04:28
Show Gist options
  • Select an option

  • Save raspberrypisig/98cd3f7d225fc43f0e090f32125d5ab8 to your computer and use it in GitHub Desktop.

Select an option

Save raspberrypisig/98cd3f7d225fc43f0e090f32125d5ab8 to your computer and use it in GitHub Desktop.
  1. Ellipsis (...)

Use cases

  • instead of pass

    def some_func()
        ...
  1. 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]
  1. type hinting
     from typing import Any
     def process_data(data: Any, config: ...):
         pass
  1. sentinel value
     def my_function(arg=...):
         if arg is ...:
             print("Argument not provided")
         else:
             print("Argument provided:", arg)
  1. Required parameters: Some libraries, like typer, use ... to denote required parameters, which must be provided by the user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment