Parso: A Python Parser
Parso is a Python parser that supports error recovery and round-trip parsing for different Python versions. It is currently at version 0.8.6, released on February 9, 2026, and follows a regular release cadence with updates approximately every 6 months.
Warnings
- breaking Parso dropped support for Python 2.7, 3.4, and 3.5 in version 0.8.0.
- deprecated The 'lib2to3' module is deprecated since Python 3.10 and may be removed in future versions. Parso is a recommended alternative.
Install
-
pip install parso
Imports
- parse
from parso import parse
Quickstart
import parso
code = 'def greet(name):\n return f"Hello, {name}!"\n\ngreet('World')'
# Parse the code
module = parso.parse(code, version='3.9')
# Access the root node
root_node = module.get_root_node()
# Print the parsed code
print(root_node.get_code())