tokenize.untokenize()
tokenize.untokenize() is a Python function in the Tokenize Module category. Converts tokens back into Python source code. The syntax is tokenize.untokenize(iterable). Returns: Source code bytes. A typical example: tokens = tokenize.generate_tokens(io.StringIO(code).readline)
original = tokenize.untokenize(tokens)
print(original) # Back to source code. A close sibling is tokenize.tokenize(), which yields tokens from a Python source file. A close sibling is tokenize.generate_tokens(), which like tokenize() but works with strings (not bytes). More about this category: Python tokenizer — tokenize, generate_tokens, untokenize. Related Tokenize Module entries: tokenize.tokenize(), tokenize.generate_tokens(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try tokenize.untokenize() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.