Welcome to pyastgrep’s documentation!

pyastgrep is a command-line utility (and library) for grepping Python files using XPath syntax (or CSS selectors) against the Python AST (Abstract Syntax Tree).

In other words, this allows you to search Python code against specific syntax elements (function definitions, arguments, assignments, variables etc), instead of grepping for string matches.

The interface and behaviour is designed to match grep and ripgrep as far as it makes sense to do so.

The project is hosted on Github.

Indices and tables