Forbid explicit step in slice
See original GitHub issueRule request
Thesis
# bad
a[1:4:]
# good
a[1:4]
# bad
a[1::]
# good
a[1:]
# bad
a[1:4:1]
# good
a[1:4]
# bad
a[1::1]
# good
a[1:]
# bad
a[::1]
# good
a.copy()
Case with a[::]
will be covered in #1011
Reasoning
Consistency
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Issuehunt
You can request for a bounty in order to promote it! Request a bounty. Forbid explicit step in slice #1071.
Read more >Indexing and Selecting in Pandas - slicing - wrighters.io
If you instantiante a slice object explicitly, you can supply a single value (the stop), or you can supply the start and stop...
Read more >0198-slice-notation - The Rust RFC Book
One way of solving this problem is for the slice methods to take self (by value) rather than &self , and in turn...
Read more >Extended slice that goes to beginning of sequence with ...
My question is: Is there any good pythonic way of using extended slices with negative strides and explicit start and end indices that...
Read more >PDL::Slices - Indexing, slicing, and dicing - metacpan.org
If you specify no boundary conditions the default is to forbid boundary violations on all axes. ... <n>:<m>:<s> -- select a range with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
True, it doesn’t make much sense when we are talking about immutable objects, I just wanted to give some example that
.copy()
is not a good solution, however I agree thatcopy.copy()
is.If we decide to write token visitor instead of AST, it will be possible to distinguish cases like 1st and 2nd ones, but I need to do some research and experiments to fully confirm that.
Let’s for the beginning cover remaining cases. It’s better than nothing.
So, why could we want to use
[::]
on it if it is immutable? Also, you can always usecopy.copy
function for custom collections (than does nothing for tuples as well, btw).As you said, we can’t say the difference between
a[:]
anda[::]
. So we can’t suggest using one instead of others.