Skip to content

bpo-34764: improve docs example of iter() with sentinel value#11222

Merged
rhettinger merged 9 commits into
python:masterfrom
chris-rands:fix-issue-34764
Dec 24, 2018
Merged

bpo-34764: improve docs example of iter() with sentinel value#11222
rhettinger merged 9 commits into
python:masterfrom
chris-rands:fix-issue-34764

Conversation

@chris-rands

@chris-rands chris-rands commented Dec 18, 2018

Copy link
Copy Markdown
Contributor

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels Dec 18, 2018
@chris-rands

Copy link
Copy Markdown
Contributor Author

Actually is it necessary to set random.seed() in such documentation example code snippets to ensure that the output is reproducible?

@rhettinger rhettinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would like to keep something closer to the original. The random() example is not a motivating use case. Instead, consider a block-reader example or some other non-toy use case:

# Read data in chunks
for block in iter(partial(f.read, 128), ''):
    ...

This partial() can be replaced with lambda: f.read(128) or with a def statement.

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@chris-rands

Copy link
Copy Markdown
Contributor Author

Thanks @rhettinger, I have tried to make the requested changes; please review again

@tirkarthi

Copy link
Copy Markdown
Member

Doctest fails on Travis since mydata.db is not present during execution. You can convert it back to a normal example code or wrap it inside a function and not calling it.

@rhettinger rhettinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed-length block reads would be more typical for binary data.

@chris-rands

Copy link
Copy Markdown
Contributor Author

Thanks @rhettinger for your patience! I have made the requested changes (and fixed the indentation); please review again

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @chris-rands for the PR, and @rhettinger for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-11301 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 24, 2018
…GH-11222)

(cherry picked from commit d378b1f)

Co-authored-by: Chris Rands <c_rands100@hotmail.com>
rhettinger pushed a commit that referenced this pull request Dec 24, 2018
…) (#11301)

(cherry picked from commit d378b1f)

Co-authored-by: Chris Rands <c_rands100@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants