#! /usr/bin/env python from itertools import imap import re TOKEN = re.compile(r"(?:^|(?<=\s))[^\s]+|(?:^|(? COLUMNS: break n += 1 n = max(n, 1) # Concatenate the tokens and prepend spaces for indentation outls.append(' ' * inl_indent + "".join(tokens[:n])) # Continue with tokens tokens = tokens[n:] return "\n".join(outls)