[Python-Dev] Symmetry arguments for API expansion

Chris Barker chris.barker at noaa.gov
Tue Mar 20 20:32:11 EDT 2018


It seems .as_integer_ratio() has been resolved.

what about the original .is_integer() request? (Or did I miss that somehow?)

Anyway, it seems like __index__() should play a role here somehow... isn't
that how you ask an object for the integer version of itself?

Could float et al. add an __index__ method that would return a ValueError
if the value was not an integer?

Of course, as pointed out earlier in this thread, an "exact" integer is
probably not what you want with a float anyway....

-CHB


On Tue, Mar 13, 2018 at 10:29 PM, Tim Peters <tim.peters at gmail.com> wrote:

> [Tim]
> >> An obvious way to extend it is for Fraction() to look for a special
> >> method too, say "_as_integer_ratio()".
>
> [Greg Ewing]
> > Why not __as_integer_ratio__?
>
> Because. at this point, that would be beating a dead horse ;-)
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <[Python-Dev] Symmetry arguments for API expansion

	
  • Next message (by thread): [Python-Dev] Symmetry arguments for API expansion
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

  • More information about the Python-Dev mailing list

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant