Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docs:import datetime as dt in examples#145315

Merged
hugovk merged 3 commits intopython:mainfrom
hugovk:docs-import-datetime-as-dt
Mar 6, 2026
Merged

Docs:import datetime as dt in examples#145315
hugovk merged 3 commits intopython:mainfrom
hugovk:docs-import-datetime-as-dt

Conversation

@hugovk
Copy link
Member

@hugovkhugovk commentedFeb 27, 2026
edited
Loading

Seehttps://discuss.python.org/t/renaming-datetime-datetime-to-datetime-datetime/26279/4 and the following post for support.

There's a few other examples in other files we can update after this.


📚 Documentation preview 📚:https://cpython-previews--145315.org.readthedocs.build/en/145315/library/datetime.html

mbeijen, itsthejoker, and ssweber reacted with thumbs up emoji
@hugovkhugovk added skip issue skip news needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsFeb 27, 2026
@hugovkhugovkforce-pushed thedocs-import-datetime-as-dt branch from068dc30 to904011aCompareFebruary 27, 2026 13:49
@hugovkhugovk marked this pull request as ready for reviewFebruary 27, 2026 13:58
Copy link
Member

@StanFromIrelandStanFromIreland left a comment
edited
Loading

Choose a reason for hiding this comment

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

This is churn in my opinion, and quite a lot of it. I agree withPaul Moore's comment, we need not enforce such things. I also don't see consensus in the thread for this, from a rough count I gather more people are against the change.

@hugovk
Copy link
MemberAuthor

I agree withPaul Moore's comment, we need not enforce such things.

There's no enforcement here, this is a docs-only change. You can stillimport datetime if you prefer. There are no stdlib (or linter) changes.

I also don't see consensus in the thread for this, from a rough count I gather more people are against the change.

I disagree. I see more people against code and linter changes, but maybe just a couple against docs changes. I see 12 supporting Terry's docs suggestion (plus him), and another couple also supporting via comments.

itsthejoker reacted with thumbs up emoji

@nedbat
Copy link
Member

I'm in favor of changing these examples in the docs. It provides a clear distinction between the module and the class, while gently showing importing the module as a preference over importing the classes directly.

hugovk reacted with thumbs up emoji

@treyhunner
Copy link
Member

I do struggle with new Python learners hitting confusion about the different between the module and the classdatetime, especially in example code likedatetime.now().

I tend to use thefrom datetime import ... convention in my own code, but that's the convention that's most likely to causedatetime confusion for new learners.

I am in favor of changing the documentation so that they do not use thefrom datetime import ... syntax. I think thisimport datetime as dt convention is a good way to do that.

I read through all the changes and they look good to me. 👍

hugovk reacted with thumbs up emoji

@picnixz
Copy link
Member

I'm also in favor of this change. Too many times my IDE bite me by importing the class instead of the module or vice-versa soimport datetime as dt would definitely help newcomers to distinguish between the module, the class, and the instace methoddatetime.datetime.time!

hugovk reacted with thumbs up emoji

Copy link
Member

@StanFromIrelandStanFromIreland left a comment

Choose a reason for hiding this comment

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

If the docs experts think it's best, I won't block.

hugovk reacted with rocket emoji
@hugovkhugovk merged commitd3b6faf intopython:mainMar 6, 2026
32 checks passed
@hugovkhugovk deleted the docs-import-datetime-as-dt branchMarch 6, 2026 11:18
@miss-islington-app
Copy link

Thanks@hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMar 6, 2026
(cherry picked from commitd3b6faf)Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@miss-islington-app
Copy link

Sorry,@hugovk, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker d3b6faf9758dce236d45c708a450437cdc3e97cd 3.13

@bedevere-app
Copy link

GH-145583 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelMar 6, 2026
hugovk added a commit to hugovk/cpython that referenced this pull requestMar 6, 2026
(cherry picked from commitd3b6faf)Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@bedevere-app
Copy link

GH-145584 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelMar 6, 2026
hugovk added a commit that referenced this pull requestMar 6, 2026
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@hugovk
Copy link
MemberAuthor

There's a few other examples in other files we can update after this.

Please see PR#145640.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nedbatnedbatnedbat approved these changes

@StanFromIrelandStanFromIrelandStanFromIreland approved these changes

@pgansslepganssleAwaiting requested review from pgansslepganssle is a code owner

@abalkinabalkinAwaiting requested review from abalkinabalkin is a code owner

Assignees

@hugovkhugovk

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@hugovk@nedbat@treyhunner@picnixz@StanFromIreland

[8]ページ先頭

©2009-2026 Movatter.jp