[issue14262] Allow using decimals as arguments to `timedelta`

Ram Rachum report at bugs.python.org
Mon Mar 12 14:13:08 CET 2012


New submission from Ram Rachum <ram at rachum.com>:

Please allow using decimals as arguments to `timedelta`, so the following code won't raise an exception:

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
>>> datetime.timedelta(hours=decimal.Decimal(7))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported type for timedelta hours component: Decimal

It's really annoying to have to convert all the arguments to `float` every time I instantiate a `timedelta`.

----------
components: Library (Lib)
messages: 155449
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Allow using decimals as arguments to `timedelta`
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14262>
_______________________________________


More information about the Python-bugs-list mailing list