pub fn parse(
input: impl AsRef<str>,
filename: impl AsRef<str>,
) -> PyResult<Module>
Expand description
Parses Python code and returns the AST as a Module.
This function accepts any type that can be converted to a string reference, making it flexible for different input types.
§Arguments
input
- The Python source code to parsefilename
- The filename to associate with the parsed code
§Returns
PyResult<Module>
- The parsed AST module or a Python error
§Examples
use python_ast::parse;
let code = "x = 1 + 2";
let module = parse(code, "example.py").unwrap();