Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Created July 6, 2019 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyaltrabelsi/88f71a6b1484a1d63edc8980bb529bf1 to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/88f71a6b1484a1d63edc8980bb529bf1 to your computer and use it in GitHub Desktop.
Python trick saving/naming slices for iterables
# Naming slices (slice(start, end, step))
>>> a = [0, 1, 2, 3, 4, 5]
>>> LASTTHREE = slice(-3, None)
>>> LASTTHREE
slice(-3, None, None)
>>> a[LASTTHREE]
[3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment