py-backwards is a transpiler that takes modern Python code (with newer syntax) and converts it to older Python versions so you can run it in legacy environments. For example, if you want to use f-strings, type annotations, or other Python 3.x niceties but have to deploy on a machine that only has an older interpreter, py-backwards rewrites your code to an equivalent, earlier syntax. It does this by parsing the source into an abstract syntax tree (AST), applying transformation rules, and emitting compatible code. This allows teams to write forward-looking Python without immediately upgrading all their runtime environments. The project is particularly handy for packaging, CI, or on-prem situations where upgrading Python is slow or impossible. It aims to preserve behavior, keep the diff small, and support multiple modern features as they appear.
Features
- Transpile modern Python syntax to older Python versions
- AST-based transformations to preserve behavior
- Support for newer features like f-strings and annotations
- Useful for legacy or slow-to-upgrade deployment targets
- CLI-friendly so it can be run in CI/CD pipelines
- Lets teams write modern Python while keeping old runtimes