[Python-Dev] Enable access to the AST for Python code

Peter Ludemann pludemann at google.com
Fri May 22 02:29:17 CEST 2015

On 21 May 2015 at 17:12, Ethan Furman <ethan at stoneleaf.us> wrote:

> On 05/21/2015 04:33 PM, Greg Ewing wrote:
>> Steve Dower wrote:
>>> It's only a macro system when you generate code in unexpected/unobvious
>>> places with it. This is more like inspect.getsource(), but going straight
>>> to the AST.
>> Is it really that much different? The end result is
>> the same -- the user writes something that looks like
>> a Python expression, but it gets evaluated using some
>> other set of semantics that can be arbitrarily different
>> from Python's.
> I think the key difference is that the AST is not going to be converted to
> run different Python code under Python, but under some other language --
> presumably to implement the semantics of the Python snippet.

As a simple example, a "macro" with access to the AST could decide to not
evaluate something, whereas normal Python rules would be to evaluate
(similar to wrapping with LISP QUOTE or LAMBDA). This would make PEP484
simpler (e.g., no need for special handling of "forward" references to

> --
> ~Ethan~
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/pludemann%40google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150521/9676dccb/attachment-0001.html>

More information about the Python-Dev mailing list