[Python-ideas] `numbers.Natural`
David Mertz
mertz at gnosis.cx
Sat Sep 27 02:01:46 CEST 2014
Well, yeah. I think I lost that discussion in the type annotation thread
though. I'd love types to include predicates, but Guido wouldn't š. An
'is_natural()' function--by whichever spelling--needs to contain a test
which isn't in the type system, whichever result one chooses for
'is_natural(1.0)'.
FWIW, I want 'isNatural(0j+1) == True'. But I'm on the losing end of at
least three arguments there.... Unless I just roll my own in 5-8 lines of
code.[*]
[*] I'd want the non-PEP8 spelling because "Natural" in mathematics is
always capitalized. That's why we have the built-in 'isGuido(BDFL)' rather
than 'is_guido()'.
On Sep 26, 2014 4:42 PM, "Ben Finney" <ben+python at benfinney.id.au> wrote:
> 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
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140926/79c2a2cf/attachment.html>
More information about the Python-ideas
mailing list