Issue36138
Created on 2019-02-27 14:54 by p-ganssle, last changed 2019-03-16 05:34 by ncoghlan.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 12137 | merged | Yasser Alshalaan, 2019-03-02 04:58 | |
| PR 12362 | merged | miss-islington, 2019-03-16 03:57 | |
| Messages (5) | |||
|---|---|---|---|
| msg336765 - (view) | Author: Paul Ganssle (p-ganssle) * | Date: 2019-02-27 14:54 | |
In a recent python-dev thread, there was some confusion about how to get something like `timedelta.total_microseconds()`. There is already an existing, supported idiom for this, which is that `timedelta` implements division:
td = timedelta(hours=1)
num_microseconds = td / timedelta(microseconds=1)
In this e-mail ( https://mail.python.org/pipermail/python-dev/2019-February/156351.html ), Nick Coghlan proposed that we update the documentation and there were no objections, quoting:
* In the "Supported Operations" section of https://docs.python.org/3/library/datetime.html#timedelta-objects,
change "Division (3) of t2 by t3." to "Division (3) of overall
duration t2 by interval unit t3."
* In the total_seconds() documentation, add a sentence "For interval units
other than seconds, use the division form directly (e.g. `td / timedelta(microseconds=1)`)"
I am starting this issue to track that change.
|
|||
| msg336980 - (view) | Author: Yasser Alshalaan (Yasser Alshalaan) * | Date: 2019-03-02 02:29 | |
I'll do this in a moment I'll have the PR |
|||
| msg338052 - (view) | Author: Nick Coghlan (ncoghlan) * | Date: 2019-03-16 03:57 | |
New changeset f40b4a0b6277b2779b9ded3736325489f2af93e4 by Nick Coghlan (Yasser A) in branch 'master': bpo-36138: Clarify docs about converting datetime.timedelta to scalars. (GH-12137) https://github.com/python/cpython/commit/f40b4a0b6277b2779b9ded3736325489f2af93e4 |
|||
| msg338053 - (view) | Author: miss-islington (miss-islington) | Date: 2019-03-16 04:03 | |
New changeset e213cd6325f2d6f116b6c3dce109cdf21f6263d5 by Miss Islington (bot) in branch '3.7': bpo-36138: Clarify docs about converting datetime.timedelta to scalars. (GH-12137) https://github.com/python/cpython/commit/e213cd6325f2d6f116b6c3dce109cdf21f6263d5 |
|||
| msg338054 - (view) | Author: Nick Coghlan (ncoghlan) * | Date: 2019-03-16 05:34 | |
I've merged Yasser's PR (thank you!), but in the review discussion for that, we noticed something else: the `total_seconds()` documentation mentions the floating point dynamic resolution problem, but doesn't mention using `//` or `divmod()` as the fix for that, while the operator table doesn't mention the dynamic resolution problem at all. So I haven't closed the issue yet, as fixing that feel in-scope for this issue, even though I didn't want to hold up the initial PR for it. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2019-03-16 05:34:12 | ncoghlan | set | messages: + msg338054 |
| 2019-03-16 04:03:46 | miss-islington | set | nosy:
+ miss-islington messages: + msg338053 |
| 2019-03-16 03:57:57 | miss-islington | set | pull_requests: + pull_request12329 |
| 2019-03-16 03:57:00 | ncoghlan | set | messages: + msg338052 |
| 2019-03-02 05:42:27 | Yasser Alshalaan | set | pull_requests: - pull_request12138 |
| 2019-03-02 04:58:48 | Yasser Alshalaan | set | pull_requests: + pull_request12139 |
| 2019-03-02 03:29:25 | Yasser Alshalaan | set | keywords:
+ patch stage: patch review pull_requests: + pull_request12138 |
| 2019-03-02 02:29:09 | Yasser Alshalaan | set | nosy:
+ Yasser Alshalaan messages: + msg336980 |
| 2019-02-27 16:06:14 | fdrake | set | nosy:
+ fdrake |
| 2019-02-27 14:54:37 | p-ganssle | create | |