[Python-ideas] Non-ASCII in Python syntax? [was: Null coalescing operator]
Chris Angelico
rosuav at gmail.com
Sun Oct 30 10:13:08 EDT 2016
On Mon, Oct 31, 2016 at 12:39 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> It's certainly not difficult, in principle. I have (had, I lost it in
> an upgrade recently...) a little AutoHotkey program that interpreted
> Vim-style digraphs in any application that needed them. But my point
> was that we don't want to require people to write such custom
> utilities, just to be able to write Python code. Or is the feeling
> that it's acceptable to require that?
There's a chicken-and-egg problem. So long as most people don't have
tools like that, a language that requires them is going to be very
annoying - but so long as no major language uses such characters,
there's no reason for developers to set up those kinds of tools.
Possibly the best way is a gentle introduction of alternative
syntaxes. Since Python currently has no "empty set display" syntax,
that seems like a perfect starting point. You can always type "set()",
but that involves an actual function call; using ∅ gives a small
performance boost, eliminates the risk of shadowing, etc, etc. All
minor points, but could be convenient enough. Also, if repr(set())
returns "∅", it'll be easy for anyone to get hold of the character for
copy/paste.
As of 2016, I think it's not acceptable to *require* this, but it may
be time to start making use of it, retaining ASCII-only digraphs and
trigraphs, the way C has alternative spelling for braces and so on.
Then time passes, most people will be comfortable using the characters
themselves, and the digraphs/trigraphs can be deprecated, with new
syntax not being given any.
Pipe dream?
ChrisA
More information about the Python-ideas
mailing list