Skip to content

Instantly share code, notes, and snippets.

@gchiam
Created November 26, 2015 00:11
Show Gist options
  • Save gchiam/bcb11b64ed8b17956c54 to your computer and use it in GitHub Desktop.
Save gchiam/bcb11b64ed8b17956c54 to your computer and use it in GitHub Desktop.
In [1]: from itertools import zip_longest
In [2]: size = 500
In [3]: parts = 16
In [4]: ranges = list(range(0, size, size // parts))
In [5]: ranges
Out[5]:
[0,
31,
62,
93,
124,
155,
186,
217,
248,
279,
310,
341,
372,
403,
434,
465,
496]
In [6]: list(zip_longest(ranges, ranges[1:], fillvalue=""))
Out[6]:
[(0, 31),
(31, 62),
(62, 93),
(93, 124),
(124, 155),
(155, 186),
(186, 217),
(217, 248),
(248, 279),
(279, 310),
(310, 341),
(341, 372),
(372, 403),
(403, 434),
(434, 465),
(465, 496),
(496, '')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment