The `untokenize` library (version 0.1.1) transforms a stream of Python tokens back into source code. Its primary distinction from the standard library's `tokenize.untokenize()` is its ability to preserve the original whitespace between tokens, addressing a common limitation. Released in February 2014, this library is stable for its intended purpose, but is no longer under active development.
pip install untokenizeVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `untokenize` to reconstruct source code from a token stream, ensuring original whitespace is preserved. It uses `tokenize.tokenize` from the standard library to generate tokens, then passes them to `untokenize.untokenize`.
Be aware of its maintenance status and consider thoroughly testing its behavior with newer Python versions (beyond Python 2.7 era) if used in critical projects. For modern, actively maintained tokenization/untokenization needs, consider alternatives or the standard library's `tokenize` module with its known limitations.
Always explicitly import `untokenize` as `import untokenize` and call `untokenize.untokenize(tokens)` to ensure you are using this library's version. If you need the standard library's behavior, use `from tokenize import untokenize as std_untokenize`.
No dependency data recorded yet.