Macros for Python: Quasiquotes, Case Classes, LINQ and more!
MacroPy is an implementation of Macros in the Python Programming Language. MacroPy provides a mechanism for user-defined functions (macros) to perform transformations on the abstract syntax tree(AST) of Python code at module import time. This is an easy way to modify the semantics of a python program
Python like you’ve never seen before
MacroPy allows you to create constructs which are impossible to have in normal python code, such as:
with trace: sum([x + 5 for x in range(3)]) # sum([x + 5 for x in range(3)]) # range(3) -> [0, 1, 2] # x + 5 -> 5 # x + 5 -> 6 # x + 5 -> 7 # [x + 5 for x in range(3)] -> [5, 6, 7] # sum([x + 5 for x in range(3)]) -> 18
print map(f[_], ['omg', 'wtf', 'bbq']) # ['o', 'w', 'b'] print reduce(f[_ + _], ['omg', 'wtf', 'bbq']) # 'omgwtfbbq
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size MacroPy-1.0.3.zip (36.8 kB)||File type Source||Python version None||Upload date||Hashes View|