-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Replace strftime with f-strings where nicer #33455
Conversation
I’m not particular sure about this, strftime is more obvious and (subjectively) easier to read. The f-string format can be beneficial if the formatted date string is going into another f-string (as in some cases here) but not when it’s on its own. |
@uranusjr Reduced to being part of larger f-strings. |
I really like conciseness of the way it's done now. It very nicely focuses the concerns (date + format) in one place within the larger f-string. @uranusjr -> is that good for you as well? |
"start_time": datetime(2012, 1, 2, 0, 0).strftime("%s") + "000", | ||
"end_time": datetime(2012, 1, 3, 0, 0).strftime("%s") + "000", | ||
"start_time": f"{datetime(2012, 1, 2, 0, 0):%s}000", | ||
"end_time": f"{datetime(2012, 1, 3, 0, 0):%s}000", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s probably better to just convert these to literals with a comment, going through datetime just to convert into a datetime is a bit over the top.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to a more explicit version.
(cherry picked from commit 94f70d8)
No description provided.