lesscode.org


Token

A Python syntax token.

This class provides access to information about a named python object. Token objects are arranged into a hierarchy that should look exactly like the introspection object hierarchy.

Token objects have six important attributes:

  • type - The token's type. This will be one of the following string values:
    • 'file' - The token is a root file token. The name attribute contains the name of the file.
    • 'def' - The token describes a function or method.
    • 'class' - The token describes a class.
    • '=' - The token describes an attribute
  • name - The name of the file, class, function, or attribute
  • indent - The indent level as an integer starting at 0.
  • line - The line number that the token appears on.
  • last_line - The line at which the token is no longer 'on the stack'
  • children - list of child tokens.

Methods

f __getitem__(self, name) ...

f __init__(self, type, name, line, indent) ...

f __iter__(self) ...

f find(self, name) ...

f for_line(self, line) ...

f tuplize(self) ...

See the source for more information.