[Python-ideas] Python Numbers as Human Concept Decimal System

Chris Angelico rosuav at gmail.com
Fri Mar 7 01:17:55 CET 2014


On Fri, Mar 7, 2014 at 10:59 AM, Cameron Simpson <cs at zip.com.au> wrote:
> Aside: Unless you do something obtuse, like make "3F" be a regular
> number with a special internal flag which is treated differently
> on the right hand side of a division operation: if encoutered,
> division now returns a Fraction instead of an int or float; this
> feels like something that could easily have nasty side effects.

Thanks, now I can take the paper bag off my head. I'm not the only one!

I thought exactly what you say here, that 3F would have to be a
magical type of integer. But actually, all it has to be is Fraction(3)
and everything will work perfectly.

>>> 1/Fraction(3)
Fraction(1, 3)

ChrisA


More information about the Python-ideas mailing list