-
-
Notifications
You must be signed in to change notification settings - Fork 403
Forbid a[len(a)-1] #862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Awesome! |
@kxepal do you have any comments on this? |
Can I take this? |
Let's start with #861 |
Can I take this one? |
Done! Thanks! 👍 |
LGFM, except this case is quite rare one and mostly relates to migration from some Golang to Python. I can't find any similar issues in real Python code. |
Hi @lensvol, how's it going? Do you need any help? |
Hi @sobolevn, everything is on track, got distracted by real-life issues sadly :/ Hope I will close it this week. |
Rule request
Thesis
That's a common mistake of gophers. Golang has no negative index (yet?), but Python has.
Bad:
Good:
The floor division is ok. Plus len and minus len isn't
Reasoning
a[len(a)-1]
is slow,a[len(a)+1]
is IndexError.The text was updated successfully, but these errors were encountered: