[Python-ideas] `numbers.Natural`

Ben Finney ben+python at benfinney.id.au
Sat Sep 27 01:41:38 CEST 2014


David Mertz <mertz at gnosis.cx> writes:

> Isn't the right answer to create an isNatural() function?

No, the right answer (by PEP 8) is to create an ‘is_natural’ or
‘isnatural’ function :-)

> Why do we need a type or class rather than just a function?

Less facetiously: I suspect what is being asked for here is a type which
will *ensure* the values are natural numbers.

That is a good use of types, IMO: they enforce a domain of values.

I'm not convinced there is a pressing need to add such a type to the
standard type hierarchy though.

-- 
 \      “I find the whole business of religion profoundly interesting. |
  `\     But it does mystify me that otherwise intelligent people take |
_o__)                                    it seriously.” —Douglas Adams |
Ben Finney



More information about the Python-ideas mailing list