GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix mismatching parameter in code example of `time.fromisoformat()` by mikelei8291 · Pull Request #103246 · python/cpython

Conversation

@mikelei8291

@mikelei8291 mikelei8291 commented Apr 4, 2023

Copy link
Copy Markdown
Contributor

The example code was intended to show that the comma was a valid delimiter for fractional seconds, but the returned datetime.time object was not consistent with the specified parameter.

The example was added in #92177.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mikelei8291
mikelei8291 requested review from abalkin and pganssle as code owners April 4, 2023 13:03
@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir skip news labels Apr 4, 2023
@AlexWaygood AlexWaygood added the skip issue label Apr 4, 2023
pganssle
pganssle reviewed Apr 4, 2023
View reviewed changes
Comment thread Doc/library/datetime.rst
>>> time.fromisoformat('04:23:01.000384')
datetime.time(4, 23, 1, 384)
>>> time.fromisoformat('04:23:01,000')
>>> time.fromisoformat('04:23:01,000384')

@pganssle pganssle Apr 4, 2023

Copy link
Copy Markdown
Member

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.

I think the point of this example is to show the comma-plus-three-digits format, so you want to change the output, not the input.

Though maybe it's better to change this to 04:23:01,678 to make it clear that those are milliseconds

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mikelei8291 mikelei8291 Apr 4, 2023

Copy link
Copy Markdown
Contributor Author

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.

There was only a little information for me to interpret the intention of the code example. Given that the returned value of the previous line was the same as this line, I can only guess that this line was meant to show that the comma is strictly equivalent to the dot as the delimiter for fractional seconds. Therefore, I decided to change the returned value of this line.

I think it would be more clear if there were separate examples of showing the equivalence of delimiters and showing the difference between two fractional seconds formats. If this was the case, I would like to keep the current change and add one more code example to demonstrate the 3-digits format for fractional seconds. For example:

>>> time.fromisoformat('04:23:01.384')
datetime.time(4, 23, 1, 384000)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@serhiy-storchaka serhiy-storchaka Feb 2, 2024

Copy link
Copy Markdown
Member

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.

time.fromisoformat('04:23:01.384') was supported in 3.10, but neither time.fromisoformat('04:23:01,000384') nor time.fromisoformat('04:23:01,384') worked. So this new test was for comma, not for three-digits fraction part.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
serhiy-storchaka
serhiy-storchaka approved these changes Feb 2, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

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.

LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mikelei8291 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Doc/library/datetime.rst
>>> time.fromisoformat('04:23:01.000384')
datetime.time(4, 23, 1, 384)
>>> time.fromisoformat('04:23:01,000')
>>> time.fromisoformat('04:23:01,000384')

@serhiy-storchaka serhiy-storchaka Feb 2, 2024

Copy link
Copy Markdown
Member

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.

time.fromisoformat('04:23:01.384') was supported in 3.10, but neither time.fromisoformat('04:23:01,000384') nor time.fromisoformat('04:23:01,384') worked. So this new test was for comma, not for three-digits fraction part.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Feb 2, 2024
@mikelei8291 mikelei8291 closed this Feb 6, 2024
@mikelei8291

mikelei8291 commented Feb 6, 2024

Copy link
Copy Markdown
Contributor Author

Although this PR was opened first, a fix was already merged with the close of issue #112925. :(

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Feb 6, 2024

Copy link
Copy Markdown
Member

In any way the problem is solved. Thank you for your PR @mikelei8291.

mikelei8291 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@pganssle pganssle pganssle left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@abalkin abalkin Awaiting requested review from abalkin

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting merge docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mikelei8291 @serhiy-storchaka @pganssle @bedevere-bot @AlexWaygood
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.