A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-September/113605.html below:

[Python-Dev] Meta coding in Python

[Python-Dev] Meta coding in Python [Python-Dev] Meta coding in PythonAlbert Zeyer albzey at googlemail.com
Fri Sep 16 00:44:35 CEST 2011
Hi list,

I thought it would be nice in Python to allow some sort of meta coding
(which goes far ahead of simple function descriptors).

The most straight forward way would be to allow operations on the AST.

I wrote a small patch for CPython 2.7.1 which, for each code object,
adds the related AST of the statement to a new attribute `co_ast`.

https://github.com/albertz/CPython/commit/2670e621458fd80311fc02897b698ea2a36d494b

Some simple demonstration of what you can do with this:

https://github.com/albertz/CPython/blob/astcompile_patch/test_co_ast.py

I'm not sure wether the Python AST in this form is optimal for doing
such things, though. Maybe another representation would be more
efficient and result in simpler code for doing transformations.

Discussion about this is very welcome.

Regards,
Albert
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4