|
|
|
|
|
by hansvm
1991 days ago
|
|
I don't know; the grammar is already pretty complicated without introducing additional indexing schemes. Now that you mention it though, I don't know that I've ever written an algorithm mixing and matching negative/positive indices in a way that couldn't be trivially re-written with that kind of syntax. I'm sure such cases exist for somebody... Looking for solutions, if you're stuck with Python and hate that behavior: - If you don't need errors raised then a[~i] is already equal to a[-i-1]. - In your own code (or at its boundaries when wrapping external lists) it's nearly free and not much code to subclass list, override __getitem__, and raise errors for negative indices while responding to some syntax like a[0,] or a.R[0]. |
|