Message313551
I've recently run into this issue impeding duck-typing between int and float again, when used in conjunction the int.__pow__, which may variously return an int or float depending on the value - not the type - of the arguments.
This is succinctly demonstrated by this example:
>>> (10 ** -2).is_integer()
False
>>> (10 ** 2).is_integer()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute 'is_integer'
I hear the argument about Python being harder to learn if more methods are supported on the built-in types - and perhaps float.is_integer should never have been added, but now its there, but I think Python is harder to learn and teach in the presence of these differences. Is is harder to learn "Real numbers support an is_integer() method", than it is "float supports an is_integer() method"?
I'm happy to put in the work bring my original patches up-to-date, or create a PR depending on what current process is. |
|
Date |
User |
Action |
Args |
2018-03-10 18:28:00 | robert_smallshire | set | recipients:
+ robert_smallshire, tim.peters, rhettinger, facundobatista, mark.dickinson, christian.heimes, skrah, serhiy.storchaka, Austin Bingham |
2018-03-10 18:28:00 | robert_smallshire | set | messageid: <1520706480.8.0.467229070634.issue26680@psf.upfronthosting.co.za> |
2018-03-10 18:28:00 | robert_smallshire | link | issue26680 messages |
2018-03-10 18:28:00 | robert_smallshire | create | |
|