News for hackers. Stuff that matters.
Re:I'm Switching to Python and Actually Liking It by pletnes on Wednesday July 16, 2025 @05:22PM (#44586924)
It would be utterly nuts otherwise. For loops over all elements in a sequence. If the sequence is a list of str, as an example, what would the «item after the last item» be?
Re:I'm Switching to Python and Actually Liking It by setr on Wednesday July 16, 2025 @05:29PM (#44586982)
the issue isn't the value of i, the issue is that i is still available after the loop ends. in most other languages, if it was instantiated by the for-each loop, it'd die with the for-each loop