◐ Shell
clean mode source ↗

bpo-29414: Change 'the for statement is such an iterator' in Tutorial by marco-buttu · Pull Request #273 · python/cpython

@DimitrisJim

Just spotted a small typo unrelated to the main change :-). The last sentence should read "arguments" instead of "argument". Other than that, the change LGTM.

@marco-buttu

DimitrisJim

berkerpeksag

berkerpeksag

wm75

@wm75 wm75 left a comment

Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that list is a class and that's why you cannot use it as an example of a function that takes an iterable, but by discarding list(range(5)) from the section you lose the important demonstration of how to turn a range into an actual list. Now the preceding example only shows the "strange" behavior of print(range(10)), but it's never shown how to really print those numbers.
Also, if you are picky about list not being a function, you should most certainly change the section title (The range() function) and its first sentence about the built-in function range.

@wm75

While you're at it, you could look into the subsequent section, too. It talks about "Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the list" and you could replace "list" with "iterable" here again.
Further down In that section you could also fix another typo:
"When used with a loop, the else clause has more in common with the else clause of a try statement than it does that of if statements" should be
"When used with a loop, the else clause has more in common with the else clause of a try statement than it does with that of if statements".

@marco-buttu

@wm75, good points. I added an example about range to list. I also added an extra whitespace after the dots, at the end of the sentences, to be consistent with the rest of the doc. Thank you very much

@wm75

The more I look at this chapter, the more I think that it needs a bigger restructuring. I don't even think any more that range deserves its own section in a chapter on control flow. I think I'll try my hands on a more radical rewrite of the chapter, but I think I'll add it to the original #bpo-29414 on the issue tracker first to get a broader discussion.

@wm75 wm75 mentioned this pull request

Jul 2, 2017

@brettcannon

To try and help move older pull requests forward, we are going through and backfilling 'awaiting' labels on pull requests that are lacking the label. Based on the current reviews, the best we can tell in an automated fashion is that a core developer requested changes to be made to this pull request.

If/when the requested changes have been made, please leave a comment that says, I have made the requested changes; please review again. That will trigger a bot to flag this pull request as ready for a follow-up review.

rhettinger

DinoV pushed a commit to DinoV/cpython that referenced this pull request

Jan 14, 2020

jaraco pushed a commit that referenced this pull request

Dec 2, 2022