Real projects

Issue #22 new
Alex Hall created an issue

I’ve created several projects using the AST that could potentially be added under Real projects. These docs were very helpful for that, thank you!

  • birdseye is a graphical debugger which works by modifying every statement and expression in the AST - see How it works. The principle is based on Thonny, a popular IDE for beginners, which has a debugger that works in a similar way, although I think it may be harder to read through the source code.
  • executing lets you obtain an AST node corresponding to what a frame is currently doing. This has all sorts of uses, including many of the projects listed below.
  • heartrate uses executing to highlight exactly what is happening in each frame of a thread.
  • pure_eval lets you safely evaluate certain AST nodes without triggering arbitrary code that may have unwanted side effects.
  • stack_data extracts data from stack frames and tracebacks, particularly to display more useful tracebacks than the default. It uses both executing and pure_eval to provide this data, as well as its own AST parsing logic for things like intelligently selecting lines of context ('pieces') to display. Currently it is used by IPython for its fancy tracebacks, specifically to highlight the executing node (using the ‘executing’ library) and several other improvements which replaced old code that was based on tokens and other fragile techniques.
  • snoop is a debugger that uses:

    • executing for its function pp which displays the source code of its arguments as well as the value, for convenient print debugging
    • similar logic to birdseye (but simpler and more readable) to print the values of all sub-expressions with pp.deep
    • various other little bits of introspection using the AST
  • icecream is not my project but I was made a contributor after replacing pretty much all of its core logic with executing.

  • sorcery uses executing plus its own AST logic to provide all sorts of nifty tricks that usually aren’t possible in Python.

Comments (1)

  1. Thomas Kluyver repo owner

    Nice! I haven’t evaluated these in detail, but from the little I’ve seen, they look like an impressive collection of tools, and I’m glad Greentreesnakes helped you. Feel free to add any/all of them to the ‘real projects’ section.

    Except maybe sorcery - libraries allowing different models of code in Python seem like a different category to tools which help people manipulate & understand their code. Perhaps there should be a separate section for projects like this & MacroPy. Or perhaps they should just be left out, and people who are interested enough will find them through other ways.

  2. Log in to comment