Skip to content

Commit 02fff75

Browse files
committed
Add a note and reword OP docs
1 parent e02ced8 commit 02fff75

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Doc/library/token.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ change between Python versions.
1919
The module also provides a mapping from numeric codes to names and some
2020
functions. The functions mirror definitions in the Python C header files.
2121

22+
Note that a token's value may depend on tokenizer options. For example, a
23+
``"+"`` token may be reported as either :data:`PLUS` or :data:`OP`, or
24+
a ``"match"`` token may be either :data:`NAME` or :data:`SOFT_KEYWORD`.
25+
2226

2327
.. data:: tok_name
2428

@@ -63,9 +67,14 @@ The token constants are:
6367

6468
.. data:: OP
6569

66-
A generic token value returned by the :mod:`tokenize` module for
67-
:ref:`operators <operators>` and :ref:`delimiters <delimiters>`.
68-
See the :mod:`tokenize` module documentation for details.
70+
A generic token value that indicates an
71+
:ref:`operator <operators>` or :ref:`delimiter <delimiters>`.
72+
73+
.. impl-detail::
74+
75+
This value is only reported by the :mod:`tokenize` module.
76+
Internally, the tokenizer uses
77+
:ref:`exact token types <token_operators_delimiters>` instead.
6978

7079
.. data:: COMMENT
7180

@@ -172,6 +181,8 @@ and are defined for special uses in the tokenizer or parser:
172181
are later rejected by the parser.
173182

174183

184+
.. _token_operators_delimiters:
185+
175186
The remaining tokens represent specific :ref:`operators <operators>` and
176187
:ref:`delimiters <delimiters>`.
177188
(The :mod:`tokenize` module reports these as :data:`OP`; see ``exact_type``

0 commit comments

Comments
 (0)