You raise some very good points. Here's a different output from the same program, followed by some explanation for context.
= = =
$ python -im friendly_traceback --verbosity 8 raise_syntax_error75
SyntaxError: invalid character in identifier
1: """Should raise SyntaxError: invalid character in identifier for Python <=3.8
2: and SyntaxError: invalid character '«' (U+00AB) in Python 3.9"""
-->3: a = « hello »
^
Python indicates that you used some unicode characters not allowed
as part of a variable name; this includes many emojis.
However, I suspect that you used a fancy unicode quotation mark
instead of a normal single or double quote for a string.
This can happen if you copy-pasted code.
= = =
Comments:
1. Friendly-traceback is primarily intended for beginners who do not know what a SyntaxError or a NameError means. This is why it normally includes, by default, [quote] a message as though they've never seen such an error before [/quote]. They also might not know what "an identifier" means, but likely have seen "variable name".
2. Friendly-traceback is designed to support translation. Currently, all the explanations provided are available in French and English, and someone is working on a Chinese translation. Thus there might be a bit of duplication between the message provided by Python ("invalid character in identifier") always shown "as is", and the longer explanation given by friendly-traceback.
3. It allows one to select a "verbosity level". Up until a few minutes ago, the available verbosity levels were 0 to 9 - but did not include a level 8 (for historical reasons), each level providing a subset of all possible information. (The default level leaves out the normal Python traceback). Thanks to your comment, I finally filled a slot for level 8, which is what you see above. (This addition will be part of the next release on pypi). Note that the location of the ^ might be messed up in this email.
4. The original discussion mentioned that using the wrong types of quotes most often occurred when beginners copy-pasted some code from an ebook or a website. This is why the message mentions it ... but I've modified it so that it is, hopefully, less patronizing.
Thanks again for your comments. Hopefully, the changes I have made are an acceptable compromise between what you suggested and what might be useful for a complete beginner.