[Python-ideas] `numbers.Natural`
Thomas Gläßle
t_glaessle at gmx.de
Fri Sep 26 22:57:07 CEST 2014
Thomas Gläßle wrote on 09/26/2014 10:54 PM:
>
> David Mertz wrote on 09/26/2014 10:38 PM:
>> I think the original desired behavior is this different one-liner:
>>
>> isNatural = lambda x: int(x)==x and x>0
>
> Not sure about the original desired behaviour. I would have guessed
> the former function as well, as it more closely resembles the
> isinstance checks with the numbers types:
>
> >>> isinstance(1.0, (numbers.Rational, numbers.Integral))
> False
And more importantly: you wouldn't expect isNatural(3.5) to return True.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140926/9912ce8a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140926/9912ce8a/attachment.sig>
More information about the Python-ideas
mailing list