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

MRAB python at mrabarnett.plus.com
Tue Jul 19 13:27:14 EDT 2016


On 2016-07-19 16:13, Chris Angelico wrote:
> On Wed, Jul 20, 2016 at 1:03 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> The reason that can help is that the main problem with "improving"
>> error messages, is that it can be really hard to tell whether the
>> improvements are actually improvements or not (in some cases it's
>> obvious, but in others it's hard to decide when you've reached a point
>> of "good enough", so you throw up your hands and say "Eh, it's at
>> least distinctive enough that people will be able to find it on Stack
>> Overflow").
>
> Plus, there are all sorts of errors that look very different to
> humans, but identical to the parser. Steven showed us an example where
> an invalid character looked like it belonged in the identifier, yet to
> the parser it's just "this Unicode category isn't valid here", same as
> the bad-quote one. In a *very* few situations, a single error is
> common enough to be worth special-casing (eg print without
> parentheses, in recent Pythons), but otherwise, Stack Overflow or
> python-list will do a far better job of diagnosis than the lexer ever
> can. Ultimately, syntax errors represent an error in translation from
> a human's concept to the text that's given to the interpreter, and
> trying to reconstruct the concept from the errant text is better done
> by a human than a computer. Obviously it's great when the computer can
> read your mind, but it's never going to be perfect.
>
Unicode has a couple of properties called "ID_Start" and "ID_Continue".

The codepoint '“' doesn't match either of them, which is a good hint 
that Python shouldn't really be saying "invalid character in identifier" 
(it's the first character, but it can't be part of an identifier).



More information about the Python-ideas mailing list