Oh god, Stephane, you're giving me flashbacks to PEP 3117 ( https://www.python.org/dev/peps/pep-3117/). But not in a good way. Please pretty please let's keep unicode characters out of our code.
With regards to the original proposal, for what it's worth, I like it well enough. I think sets are the only type in the builtins module without a dedicated literal syntax? So it would provide, let's say, *pleasing symmetry* in that regard. I think literals also have some (minor) performance benefits compared to their equivalent type constructors. As long as no one can think of any objections (or perhaps an alternate syntax), it seems like a reasonable enough backwards-compatible change. On Fri, Apr 9, 2021 at 9:54 AM Chris Angelico <[email protected]> wrote: > On Fri, Apr 9, 2021 at 6:09 PM Stéfane Fermigier <[email protected]> wrote: > > > > I think the best alias for "empty set" would be the Unicode character > "Empty set" or U+2205, i.e. "∅". > > > > Alas, it's not a valid identifier in Python: > > > > >>> ∅ = set() > > File "<stdin>", line 1 > > ∅ = set() > > ^ > > SyntaxError: invalid character '∅' (U+2205) > > > > It works with the similarly looking "ϕ" or 'GREEK PHI SYMBOL' (U+03D5) > > > > >>> ϕ = set() > > >>> ϕ.union({1,2}) > > {1, 2} > > > > But it's less than ideal. > > > > I think it's an error from the Unicode standard to list the empty set as > a "Mathematical Operator" ( > https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode#Mathematical_Operators_block) > and not as a > > "Letterlike Symbol" like ℝ or ℕ ( > https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode#Letterlike_Symbols_block > ). > > > > Ex: > > > > >>> ℕ = [0, ...] # Whatever that means... > > >>> ℕ > > [0, Ellipsis] > > > > So yes, the language would need to be changed to allow the proper empty > set unicode symbol to be used. > > > > Not to mention everyone's keyboards. Python != APL. Err, I mean, Python ≠ > APL. > > ChrisA > _______________________________________________ > Python-ideas mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/TXKHZY6L3CE22XVK3MJTSW2LVGBOIBG5/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/D2K643R5LFIG35ZPACFQNCPMZP5LZSWR/ Code of Conduct: http://python.org/psf/codeofconduct/
