int vs. float

Steve D'Aprano steve+python at pearwood.info
Sat Feb 11 23:50:18 EST 2017


On Sun, 12 Feb 2017 02:34 pm, Chris Angelico wrote:

> On Sun, Feb 12, 2017 at 2:27 PM, Steve D'Aprano
> <steve+python at pearwood.info> wrote:
>>>
>>> For example:
>>>
>>>    >>> ast.literal_eval("( 1.0, 3 )").__class__.__name__
>>>    'tuple'
>>
>>
>> In what way does returning a tuple match the requirement "return an int
>> or a float or generate an error message"?
> 
> Easy. You just use a version of Python in which tuple is a subclass of
> int.


Wouldn't a subclass of float be more appropriate? After all, floats have a
mantissa and an exponent, which kinda makes them a tuple...

*tongue firmly in cheek*


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list