On 4/8/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> To me an AST access feature would only be useful for changing the "VM" that
> Python code runs on.  For example, there is an object-relational mapper out
> there (I think it's Robert Brewer's DejaVu system) that takes Python
> generator expressions and converts them into SQL.  Right now it does it by
> bytecode hacking, because the only alternative is to parse a string.

I can see how reading the AST could be useful here, but Python 2.5
already has that:

>>> expr = compile('(x**y for x, y in z)', '<string>', 'eval', 0x400)
>>> expr.body.elt.left.id
'x'
>>> expr.body.elt.right.id
'y'
>>> expr.body.elt.op
<_ast.Pow object at 0x00BD0690>
>>> [name.id for name in expr.body.generators[0].target.elts]
['x', 'y']
>>> expr.body.generators[0].iter.id
'z'

Do the use-cases here really need to change the AST on the original
function?  What's wrong with creating a new function?

STeVe
--
Grammar am for people who can't think for myself.
        --- Bucky Katt, Get Fuzzy
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to