steven Michalske added the comment:

Argh, I swear I proofread this...

print([a[x] for x in [slice(y+3, y-1, -1) for y in range(0, len(a), 4)]])
[[], [7, 7, 6, 5]]

Catching my explicit case, I changed my code to:
print([a[x] for x in [slice(y+3, y-1 if y > 1 else None, -1) for y in range(0, 
len(a), 4)]])
[[3, 2, 1, 0], [7, 6, 5, 4]]

Also, I could have done this...

print(list(reversed([a[x] for x in [slice(y, y-4, -1) for y in range(-1, 
-len(a), -4)]])))
[[3, 2, 1, 0], [7, 6, 5, 4]]
But, Yikes All those inverses!

Side Note
I wish we had partitioning in ranges/slices.

a[::4] == [0, 4]
a[::4:2] == [[0, 1], [4, 5]]
a[::4:-4] == [[3, 2, 1, 0], [7, 6, 5, 4]]

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to