Skip to content

IDLE: add a token browser #152941

Description

@serhiy-storchaka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-IDLEtype-featureA feature request or enhancement

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions