token_utils.utils

utils.py

A collection of various functions

Functions

dedent(tokens, nb)

Given a list of tokens, produces an equivalent list corresponding to a line of code with the first nb characters removed.

get_first(tokens[, exclude_comment])

DEPRECATED

get_first_index(tokens[, exclude_comment])

DEPRECATED

get_last(tokens[, exclude_comment])

DEPRECATED

get_last_index(tokens[, exclude_comment])

DEPRECATED

get_number(tokens[, exclude_comment])

DEPRECATED

indent(tokens, nb[, tab])

Given a list of tokens, produces an equivalent list corresponding to a line of code with nb space characters inserted at the beginning.

pairwise(iterable[, prev])

Similar to itertools.pairwise (Python 3.10+).

sliding_window(iterable, n)

Collect data into overlapping fixed-length chunks or blocks.