[Python-ideas] `numbers.Natural`

David Mertz mertz at gnosis.cx
Sat Sep 27 08:46:11 CEST 2014


I've mentioned before that I used vim-cute-python (
https://github.com/ehamberg/vim-cute-python), but customized myself (
http://gnosis.cx/bin/.vim/after/syntax/python.vim).

I do not utilize U+2115 'DOUBLE-STRUCK CAPITAL N' anywhere, but it is an
elegant character.  I use others such as:

  syntax match pyNiceOperator "\<in\>" conceal cchar=∈
  syntax match pyNiceOperator "\<or\>" conceal cchar=∨
  syntax match pyNiceOperator "\<and\>" conceal cchar=∧
  syntax match pyNiceOperator "\<not in\>" conceal cchar=∉
  syntax keyword pyNiceOperator sum conceal cchar=∑
  syntax keyword pyNiceBuiltin all conceal cchar=∀
  syntax keyword pyNiceBuiltin any conceal cchar=∃
  syntax keyword pyNiceStatement int conceal cchar=ℤ
  syntax keyword pyNiceStatement float conceal cchar=ℝ
  syntax keyword pyNiceStatement complex conceal cchar=ℂ

And contentiously, but it makes sense to me:

  syntax keyword pyNiceStatement None conceal cchar=ℵ

In my mind, since aleph-naught is the first inaccessible cardinal, and
'None' can similarly not be "reached" by operations on values of other
types, there is a bit of an analogy.  The fact aleph visually resembles
capital-N(one) add to the appeal.

So onscreen I see something like:

  for x ∈ it:
      if isinstance(x, (ℤ, ℝ, ℂ)):
          y = (x ∨ z) ∧ w

I could easily define something to use ℕ but still have the actual source
spelling of "Natural", just displayed in a fancy way.


On Fri, Sep 26, 2014 at 10:04 PM, Chris Angelico <rosuav at gmail.com> wrote:

> 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
> _______________________________________________
> 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/
>



-- 
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/1f2c49ca/attachment-0001.html>


More information about the Python-ideas mailing list