Language and Compiler Modules

token

Defines symbolic constants and names used to classify Python lexical tokens. These numeric identifiers are not a stable cross-version interchange format. Use symbolic constants with tokenize; an operator may have a generic OP token type and a more specific exact_type.

Formal Syntax & Structure

python syntaxpython
import token

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import tokenprint(token.tok_name[token.NAME])
Python Reference