gh-116666: Add "token" glossary term (GH-130888)

Add glossary entry for `token`, and link to it.
Avoid talking about tokens in the SyntaxError intro (errors.rst); at this point
tokenization is too much of a technical detail. (Even to an advanced reader,
the fact that a *single* token is highlighted isn't too relevant. Also, we don't
need to guarantee that it's a single token.)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Petr Viktorin 2025-03-17 17:05:47 +01:00 committed by GitHub
parent 863d54cbaf
commit 30d5205849
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 11 deletions

View file

@ -24,11 +24,12 @@ complaint you get while you are still learning Python::
SyntaxError: invalid syntax
The parser repeats the offending line and displays little arrows pointing
at the token in the line where the error was detected. The error may be
caused by the absence of a token *before* the indicated token. In the
example, the error is detected at the function :func:`print`, since a colon
(``':'``) is missing before it. File name and line number are printed so you
know where to look in case the input came from a script.
at the place where the error was detected. Note that this is not always the
place that needs to be fixed. In the example, the error is detected at the
function :func:`print`, since a colon (``':'``) is missing just before it.
The file name (``<stdin>`` in our example) and line number are printed so you
know where to look in case the input came from a file.
.. _tut-exceptions:

View file

@ -37,10 +37,10 @@ Alternatives to the Interactive Interpreter
This facility is an enormous step forward compared to earlier versions of the
interpreter; however, some wishes are left: It would be nice if the proper
indentation were suggested on continuation lines (the parser knows if an indent
token is required next). The completion mechanism might use the interpreter's
symbol table. A command to check (or even suggest) matching parentheses,
quotes, etc., would also be useful.
indentation were suggested on continuation lines (the parser knows if an
:data:`~token.INDENT` token is required next). The completion mechanism might
use the interpreter's symbol table. A command to check (or even suggest)
matching parentheses, quotes, etc., would also be useful.
One alternative enhanced interactive interpreter that has been around for quite
some time is IPython_, which features tab completion, object exploration and