[Python-ideas] `numbers.Natural`

David Mertz mertz at gnosis.cx
Fri Sep 26 22:42:08 CEST 2014


>
> isNatural = lambda x: int(x)==x and x>0
>>
>
Actually, sorry.  This is crashy; what I mean is:

    from numbers import Number
    isNatural = lambda x: isinstance(x, Number) and int(x)==x and x>0


-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140926/70699faa/attachment-0001.html>


More information about the Python-ideas mailing list