[Python-ideas] `numbers.Natural`

Chris Angelico rosuav at gmail.com
Sat Sep 27 07:04:46 CEST 2014


On Sat, Sep 27, 2014 at 11:13 AM, Andrew Barnert
<abarnert at yahoo.com.dmarc.invalid> wrote:
> Wouldn't is\N{ELEMENT}\N{DOUBLE_N} or something like that (sorry, don't know
> how to type the actual Unicode on my phone, do know how to look up the right
> names but too lazy to do so) be better if "in mathematics" is what you
> really want? In math textbooks and papers, the symbols are usually
> translated to "is a natural number", not "is a Natural number", so I don't
> think violating PEP 8 is warranted here.

Assuming the characters you're after are U+2208 'ELEMENT OF' and
U+2115 'DOUBLE-STRUCK CAPITAL N', your name would be is∈ℕ(). I'd
prefer isℕ() for two reasons: firstly, ∈ is a symbol, so it's not
valid in a name (though you could open the other can of worms and ask
for it to be an operator - then you could spell it "x ∈ ℕ" instead of
"isℕ(x)"), and secondly because it's much more common to ask "is
natural?" than "is element-of natural?" in function names. But I think
this has long gone into crazyland.

ChrisA


More information about the Python-ideas mailing list