[Python-ideas] allow `lambda' to be spelled λ

Paul Moore p.f.moore at gmail.com
Thu Jul 21 04:37:06 EDT 2016

On 21 July 2016 at 08:54, Chris Angelico <rosuav at gmail.com> wrote:
> No; I'm not saying that. I'm completely disagreeing with #1's value. I
> don't think the language interpreter should concern itself with
> visually-confusing identifiers. Unicode normalization is about
> *equivalent characters*, not confusability, and I think that's as far
> as Python should go.

+1. There are plenty of ways of writing programs that don't do what
the reader expects. (Non-malicious) people writing Python code
shouldn't be using visually ambiguous identifiers. People running code
they don't trust should check it (and yes, "are there any
non-ASCII/confusable characters used in identifiers" is one check they
should make, among many).

Avoiding common mistakes is a good thing. But that's about as far as
we should go. On that note, though, "smart quotes" do find their way
into code, usually via cut and paste from documents in tools like MS
Word that "helpfully" change straight quotes to smart ones. So it
*may* be worth special casing a check for smart quotes in identifiers,
and reporting something like "was this meant to be a string, but you
accidentally used smart quotes"? On the other hand, people who
routinely copy code samples from sources that mangle the quotes are
probably used to errors of this nature, and know what went wrong even
if the error is unclear. After all, I don't know *any* language that
explicitly checks for this specific error.

Personally, I don't think that the effort required is justified by the
minimal benefit. But if someone were to be inclined to make that
effort and produce a patch, an argument along the above lines
(catching a common cut and paste error) might be sufficient to
persuade someone to commit it.


More information about the Python-ideas mailing list