{"repo":"baziotis/metap","free":true,"listed":false,"github":"https://github.com/baziotis/metap","clone":"git clone https://github.com/baziotis/metap.git","description":"An easy-to-use meta-programming layer for Python","language":"Python","stars":64,"topics":["debugging","metaprogramming"],"license":"Apache-2.0","category":"dev-tools","readme_excerpt":"An easy-to-use meta-programming layer for Python. Motivation metap is an easy-to-use meta-programming layer for Python. It allows you to write programs that generate programs. That sounds fancy, but in practice metap just automates tedious program transformations and programming patterns. Blog post: https://sbaziotis.com/compilers/metap.html Installation First (because metap needs a bug-fixed version of astor ): Then: Quickstart metap works with two scripts: (a) A client, and (b) a meta-program. The metap-program is just a Python program, except it may have metap -specific features. The client tells metap how to process your meta-program to generate another Python program. Here's a simple example. Let's say you have the following meta-program, in the file test mp.py : In this simple example, the meta-program has nothing metap -specific. You can just run it with Python as it is. But, you can still tell a client to transform it in various useful ways. For example, you may want to log all the return s. So, we write a simple client: This says the minimum metap needs to know: which file to load ( test mp.py ), what to do (log the returns), and dump the result in test.py . Now, we first run: to produce test.py . Then, we run it: which produces: metap allows you to log all kinds of things, optionally supporting indentation and only logging within ranges. Another useful feature is dynamic type checking. Python accepts type annotations in e.g., variable declarations, function paramete","default_branch":null,"files":null,"tree":[],"storefront":"/r/baziotis","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/baziotis/metap/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}