On this page
  1. tokenize.TokenInfo
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

tokenize.TokenInfo

Prev: tokenize.TokenError | Up: tokenize | Next: tokenize.tokenize
Rel: tokenize.detect_encoding, tokenize.generate_tokens, tokenize.open, tokenize.TokenError
Ref: docs.python.org — tokenize.TokenInfo
Tags: #public #python3 #stdlib #tokenize


Import

import tokenize
from tokenize import TokenInfo

Signature & Overview

tokenize.TokenInfo(type, string, start, end, line)

tokenize.TokenInfo class.

Methods & Attributes

Usage

import io, tokenize

tok = next(tokenize.generate_tokens(io.StringIO('x = 1').readline))
assert isinstance(tok, tokenize.TokenInfo) and tok.string == 'x'

Gotchas

REPL Inspect

from tokenize import TokenInfo
help(TokenInfo)

Linked from

Related notes