[Python-ideas] Enabling access to the AST for Python code
Nathaniel Smith
njs at pobox.com
Fri May 22 03:40:25 CEST 2015
On Thu, May 21, 2015 at 6:18 PM, Ben Hoyt <benhoyt at gmail.com> wrote:
> Hi Python Ideas folks,
>
> (I previously posted a similar message on Python-Dev, but it's a
> better fit for this list. See that thread here:
> https://mail.python.org/pipermail/python-dev/2015-May/140063.html)
>
> Enabling access to the AST for compiled code would make some cool
> things possible (C# LINQ-style ORMs, for example), and not knowing too
> much about this part of Python internals, I'm wondering how possible
> and practical this would be.
What concretely are you imagining? I can imagine lots of possibilities
with pretty different properties... e.g., one could have an '.ast'
attribute attached to every code object, which always tracks the
source that the code was compiled from. Or one could add a new
(quasi)quoting syntax, like 'select(! c for c in Customer if
sum(c.orders.price) > 1000)' where ! is a low-priority operator that
simply returns the AST of whatever is written to the right of it.
Or... lots of things, probably.
-n
--
Nathaniel J. Smith -- http://vorpus.org
More information about the Python-ideas
mailing list