Skip to content

bpo-27741: Better wording for datetime.strptime() #9994

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

Merged
merged 4 commits into from
Oct 29, 2018
Merged

bpo-27741: Better wording for datetime.strptime() #9994

merged 4 commits into from
Oct 29, 2018

Conversation

augustogoulart
Copy link
Contributor

@augustogoulart augustogoulart commented Oct 20, 2018

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

@pganssle, @abalkin: Would you mind to double check?

@pganssle
Copy link
Member

I don't think this is wrong, though I would probably use "timezone offset" instead of "timezone", since nothing in strptime allows transmission of actual time zones.

One suggestion of a possible alternate wording (and I'm not really convinced that it's much better), is to retain the "equivalent" language but specify that it's for a special case:

equivalent to datetime(*(time.strptime(date_string, format)[0:6])) except
when the format includes sub-second components or timezone offset information,
which are supported in datetime.strptime but not time.strptime.

I sorta like being explicit about what things are intended to be equivalent, since similar is a more ambiguous term, but obviously this makes phrase wordier.

@augustogoulart
Copy link
Contributor Author

@pganssle I don't think the extra words in your suggestion would be a problem. My only concern is that we are describing something as equivalent, and pointing an exception just after.
Grammatically speaking, I really don't know if we can add an exception to something that is equivalent.

@pganssle
Copy link
Member

@augustogoulart I think "X is equivalent to Y under condition Z" is valid, my wording was that the two expressions are equivalent except when ..., to be precise as to when the two do the same thing and when they don't.

@augustogoulart
Copy link
Contributor Author

Thanks, @pganssle!

@taleinat
Copy link
Contributor

I agree with @pganssle's suggestion here.

Minor suggestion: "but not time.strptime" -> "but are discarded by time.strptime", since time.strptime won't fail, but will silently ignore such input.

@vstinner
Copy link
Member

@augustogoulart: Can you please make the change suggested by @taleinat?

@pganssle: I would prefer to wait for your ACK on this PR before merging it. Would you mind to Approve it once it looks good to you?

@pganssle
Copy link
Member

@vstinner Looks good to me, but @taleinat did have a sensible suggestion, so it might be best to implement that change.

@augustogoulart
Copy link
Contributor Author

@taleinat @pganssle @vstinner changes commited.

Copy link
Contributor

@taleinat taleinat left a comment

Choose a reason for hiding this comment

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

IMO the last part of the sentence is unnecessary.

equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``.
equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``, except
when the format includes sub-second components or timezone offset information,
which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``,
which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``.

equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``, except
when the format includes sub-second components or timezone offset information,
which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``,
since ``time.strptime`` won't fail; however, it will silently ignore such input.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
since ``time.strptime`` won't fail; however, it will silently ignore such input.

@augustogoulart
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@taleinat, @vstinner: please review the changes made to this pull request.

@vstinner
Copy link
Member

Is there anyone interested by this other strptime() doc issue? https://bugs.python.org/issue19376

@miss-islington
Copy link
Contributor

Thanks @augustogoulart for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

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

@bedevere-bot
Copy link

GH-10213 is a backport of this pull request to the 3.6 branch.

@miss-islington
Copy link
Contributor

Thanks @augustogoulart for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-10214 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 Oct 29, 2018
(cherry picked from commit c0799ec)

Co-authored-by: Gus Goulart <augusto@goulart.me>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 29, 2018
(cherry picked from commit c0799ec)

Co-authored-by: Gus Goulart <augusto@goulart.me>
@bedevere-bot
Copy link

GH-10215 is a backport of this pull request to the 2.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 29, 2018
(cherry picked from commit c0799ec)

Co-authored-by: Gus Goulart <augusto@goulart.me>
@taleinat
Copy link
Contributor

Is there anyone interested by this other strptime() doc issue? https://bugs.python.org/issue19376

I've marked that as "easy"; expect a PR rather quickly!

miss-islington added a commit that referenced this pull request Oct 29, 2018
(cherry picked from commit c0799ec)

Co-authored-by: Gus Goulart <augusto@goulart.me>
miss-islington added a commit that referenced this pull request Oct 29, 2018
(cherry picked from commit c0799ec)

Co-authored-by: Gus Goulart <augusto@goulart.me>
miss-islington added a commit that referenced this pull request Oct 29, 2018
(cherry picked from commit c0799ec)

Co-authored-by: Gus Goulart <augusto@goulart.me>
@vstinner
Copy link
Member

I've marked that as "easy"; expect a PR rather quickly!

Datetime is not easy, but we will see :-) See how many iterations were needed just for this simple doc change ;-)

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 skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants