News for hackers. Stuff that matters.

Ask HN: Examples of meta programming or AST-hacking in Python?

I've found a few promising examples of AST-hacking within Python, but I'd like to know if anyone has some more.

Here's what I've found:

http://blaag.haard.se/Using-the-AST-to-hack-constants-into-Python/

http://hackflow.com/blog/2015/03/29/metaprogramming-beyond-decency/

I'd also be interested in just seeing people implementing domain specific languages in Python, using Pyparsing or other techniques.

( 3 comments | 2 points | on HN )
Re:Ask HN: Examples of meta programming or AST-hacking in Py... by gjenks on Saturday January 30, 2016 @04:05PM (#11003743)
I wrote a Python module called PyPatt that implements Pythonic Pattern Matching as you'd find in functional languages. There's both a function-based and macro-based version. The macro version is deprecated but was used for a while.

Docs: http://www.grantjenks.com/docs/pypatt-python-pattern-matchin... Source: https://github.com/grantjenks/pypatt_python_pattern_matching...

Re:Ask HN: Examples of meta programming or AST-hacking in Py... by dalke on Friday January 29, 2016 @07:22PM (#10999696)
Re:Ask HN: Examples of meta programming or AST-hacking in Py... by jonjacky on Friday January 29, 2016 @10:51PM (#11000391)
Hy is a Lisp that compiles to Python AST and then to Python bytecode:

https://github.com/hylang/hy/blob/master/docs/language/inter...