This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年09月19日 18:23 by cool-RR, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (8) | |||
|---|---|---|---|
| msg170737 - (view) | Author: Ram Rachum (cool-RR) * | Date: 2012年09月19日 18:23 | |
Please allow multiplying timedelta by a Decimal:
Python 3.3.0a1 (default, Mar 4 2012, 17:27:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> import decimal
>>> decimal.Decimal('0.1')*datetime.timedelta(seconds=3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'Decimal' and 'datetime.timedelta'
>>>
|
|||
| msg170739 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2012年09月19日 18:35 | |
Do you have a particular use-case in mind? Is there a reason that td * 0.1 or td / 10.0 aren't good enough? |
|||
| msg170740 - (view) | Author: Ram Rachum (cool-RR) * | Date: 2012年09月19日 18:41 | |
This is for cases where I already have the number as a Decimal. Asking me to convert it to `float` myself is annoying. |
|||
| msg170742 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2012年09月19日 18:50 | |
This is similar to issue 14262. If we decide that timedelta should play nice with Decimal, I would like to consider all related features. |
|||
| msg170743 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2012年09月19日 18:52 | |
> Asking me to convert it to `float` myself is annoying. Well, it's just a call to 'float', right? On the other side, we're looking at significant extra code to implement Decimal * timedelta, so there needs to be a good reason to add it. (And there's feature-creep involved, too; once we've got Decimal * timedelta, there will probably also be requests for timedelta / Decimal, and possibly timedelta / timedelta -> Decimal too). |
|||
| msg170744 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2012年09月19日 18:54 | |
In fact, this is a near-duplicate of #14262 becaus instead of >>> decimal.Decimal('0.1')*datetime.timedelta(seconds=3) one can always write >>> datetime.timedelta(seconds=decimal.Decimal('0.1')*3) |
|||
| msg170745 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2012年09月19日 18:54 | |
Agreed; +1 on folding this into issue 14262. |
|||
| msg170747 - (view) | Author: Ram Rachum (cool-RR) * | Date: 2012年09月19日 18:57 | |
+1 on folding this into issue 14262. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:36 | admin | set | github: 60179 |
| 2012年09月19日 18:58:00 | mark.dickinson | set | status: open -> closed superseder: Allow using decimals as arguments to `timedelta` resolution: duplicate |
| 2012年09月19日 18:57:08 | cool-RR | set | messages: + msg170747 |
| 2012年09月19日 18:54:59 | mark.dickinson | set | messages: + msg170745 |
| 2012年09月19日 18:54:13 | belopolsky | set | messages: + msg170744 |
| 2012年09月19日 18:52:47 | mark.dickinson | set | messages: + msg170743 |
| 2012年09月19日 18:50:16 | belopolsky | set | messages:
+ msg170742 versions: - Python 3.3 |
| 2012年09月19日 18:47:04 | mark.dickinson | set | nosy:
+ belopolsky |
| 2012年09月19日 18:41:17 | cool-RR | set | messages: + msg170740 |
| 2012年09月19日 18:35:58 | mark.dickinson | set | nosy:
+ mark.dickinson messages: + msg170739 |
| 2012年09月19日 18:23:26 | cool-RR | create | |