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.