Seeing how source is split into tokens helps in learning how Python's tokenizer works and in debugging tokenizer-dependent behavior, but IDLE offers no way to inspect the token stream.
I propose a Token Browser added as an extension on the Tools menu (Shell and editor). It shows the output of tokenize for the current window in a ttk.Treeview — one row per token with its type, string, and range.
Interaction:
- Selecting a row highlights the corresponding source in the editor.
- Double-clicking a row moves the editor cursor to that token.
- The browser follows the editor: a selection selects every overlapping token row, and the cursor alone selects the single token containing it.
- Scope is the editor selection if there is one, else the Shell's current input, else the whole window.
A PR will follow.
Linked PRs
Seeing how source is split into tokens helps in learning how Python's tokenizer works and in debugging tokenizer-dependent behavior, but IDLE offers no way to inspect the token stream.
I propose a Token Browser added as an extension on the Tools menu (Shell and editor). It shows the output of
tokenizefor the current window in attk.Treeview— one row per token with its type, string, and range.Interaction:
A PR will follow.
Linked PRs