Created
July 6, 2019 06:34
-
-
Save eyaltrabelsi/88f71a6b1484a1d63edc8980bb529bf1 to your computer and use it in GitHub Desktop.
Python trick saving/naming slices for iterables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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