Message313917
Many functions implemented in C accept Decimal instances.
>>> chr(decimal.Decimal(65.2))
'A'
This is because PyLong_AsLong() and similar functions call __int__().
Floats are specially prohibited when convert arguments with PyArg_Parse() with the "i" format unit.
>>> chr(65.2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: integer argument expected, got float
The specific of factorial() is that it accepts integral floats and raises ValueError instead of TypeError for non-integral floats. Maybe it was planned to extend factorial() to non-integral floats by using a gamma function. All other functions in the math module worked with floats at the time of adding factorial() in issue2138. math.gamma() was added 1.5 years later in issue3366. |
|
Date |
User |
Action |
Args |
2018-03-15 23:00:55 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, terry.reedy, facundobatista, mark.dickinson, skrah, John.Yeung |
2018-03-15 23:00:55 | serhiy.storchaka | set | messageid: <1521154855.8.0.467229070634.issue33083@psf.upfronthosting.co.za> |
2018-03-15 23:00:55 | serhiy.storchaka | link | issue33083 messages |
2018-03-15 23:00:55 | serhiy.storchaka | create | |
|