The “correct” (according to Bourbaki) mathematical notation for an empty set is “∅" (aka Unicode U+2205, or HTML ∅)

Some time ago, for a project which had a lot of empty sets, I tried to use this symbol as a short hand for set(). But:

>>> ⦰ = set()
  File "<stdin>", line 1
    ⦰ = set()
    ^
SyntaxError: invalid character '⦰' (U+29B0)
>>> ø = set()
>>>

In other words, “⦰” is illegal as an identifier in Python (same for  ⌀ aka U+2300 DIAMETER SIGN), but “ø” (aka U+00F8 LATIN SMALL LETTER O WITH STROKE) is legal !

So I used  "⌀" instead of “⦰”, but I eventually dropped the whole idea because, IIRC, some tools weren’t too happy with it.

Still, I guess it wouldn’t be neither too hard nor two disruptive to accept “⦰” as well as some other mathematical characters as identifiers in Python. 

Since once of the application domains where Python shines nowadays is mathematics (numerical, but also symbolic), I think it’s a shame that we are preventing to use the proper unicode characters to designate some universal mathematical objects.

More info here: https://en.wikipedia.org/wiki/Null_sign

  S.

On 13 Mar 2022 at 22:52:16, joao.p.f.batista.97@gmail.com wrote:
Currently:
l = [] # new empty list
t = () # new empty tuple
s = set() # new empty set (no clean and consistent way of initializing regarding the others) <<<
d = {} # new empty dictionary

Possible solution:
s = {} # new empty set
d = {:} # new empty dictionary (the ":" is a reference to key-value pairs)

Current workaround at least for consistency:
l = list() # new empty list
t = tuple() # new empty tuple
s = set() # new empty set
d = dict() # new empty dictionary

However, it doesn't feel right to not be able to initialize an empty set as cleanly and consistently as lists, tuples and dictionaries in both forms.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/OPWEKLLGT6RWMEHC4SLEZ2LSRVCSS4GP/
Code of Conduct: http://python.org/psf/codeofconduct/


--
Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier - http://linkedin.com/in/sfermigier
Founder & CEO, Abilian - Enterprise Social Software - http://www.abilian.com/
Co-Founder & Co-Chairman, National Council for Free & Open Source Software (CNLL) - http://cnll.fr/
Co-Founder & Chairman, Association Professionnelle Européenne du Logiciel Libre (APELL) - https://www.apell.info/
Co-Founder & Spokesperson, European Cloud Industrial Alliance (EUCLIDIA) - https://www.euclidia.eu/ 
Founder, PyParis & PyData Paris - http://pyparis.org/http://pydata.fr/