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.

Author robert_smallshire
Recipients Austin Bingham, christian.heimes, facundobatista, mark.dickinson, rhettinger, robert_smallshire, serhiy.storchaka, skrah, tim.peters
Date 2018-03-10.18:28:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520706480.8.0.467229070634.issue26680@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-03-10 18:28:00robert_smallshiresetrecipients: + robert_smallshire, tim.peters, rhettinger, facundobatista, mark.dickinson, christian.heimes, skrah, serhiy.storchaka, Austin Bingham
2018-03-10 18:28:00robert_smallshiresetmessageid: <1520706480.8.0.467229070634.issue26680@psf.upfronthosting.co.za>
2018-03-10 18:28:00robert_smallshirelinkissue26680 messages
2018-03-10 18:28:00robert_smallshirecreate