[Python-ideas] Allow additional separator character in variables

Mikhail V mikhailwas at gmail.com
Sat Nov 18 22:22:51 EST 2017


Chris A wrote:
> Both of these create extremely confusing situations, where two
> nearly-identical symbols have completely different meanings.

In reality, hyphen and Minus sign are not even closely similar -
Minus is ca. twice as wide, however the citizens of the Monospaced
Kingdom may disagree ; )  Though I think its population will
dramatically decrease in one or two decades.

> Solution 2 is a massive backward-compatibility break.

Yep, although elimination of improper usage is always good
thing in longer perspective (and less new additional chars).
But I do realise that it is a non-starter.


> ... a marginal benefit ... How much benefit do you REALLY get
> from using hyphens rather than underscores?

IMO it's far higher than marginal, at least compared to most
syntax proposals I remember. One of the hardest and most important
tasks which a programmer is faced, is making readable variable names.
Underscores are still one of the MOST ugly things I observe currently
in Python syntax. This means, if fixings this, then there will be only
"small warts" left (such as e.g. single quotes).

For me, one "cheap" solution against underscores is to use
syntax highlighting which grays them out, but if those become like
spaces, then it becomes a bit confusing, e.g. in function with many arguments.
Also, unfortunately, not many editors allow easy (if any) highlighting
customisation on that level.
One possible solution is to use a custom font that has hyphen instead of the
underscore, but this is not a proper solution, because, well, the
character standard
is still there, regardless I like it or not. And one should still have
an alternative,
i.e. *not only one* separator, for example to denote something "special".
Also it can enrich some semantical emphasis, e.g.:
my-variable_global


Mikhail


More information about the Python-ideas mailing list