Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
> You code fail, see below for other comment > > Traceback (most recent call last): >   File "Download/pastie-2379978.rb", line 108, in >     make_template(template1) >   File "Download/pastie-2379978.rb", line 60, in make_template >     ast.fix_missing_locations(astFromSrc) >   File "/usr/lib/pyt

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 5:23 am, Irmen de Jong wrote: > On 16-08-11 13:33, Paul Wray wrote: > > > > > > > > > > > The idea: > > Python syntax allows a statement to be a bare literal or identifier. > > These have no effect on the program. > > > So the f

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 2:14 am, Chris Angelico wrote: > On Tue, Aug 16, 2011 at 12:33 PM, Paul Wray wrote: > > The idea is simply to use python ASTs to transform this code so that it > > accumulates the values of the bare expressions. > > That'd be similar to what the interactiv

Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
d templates) , it would be simple to extend the technique to creating template functions from strings, and insert the resulting methods into a namespace for execution.) I think, given the technique is already working with the AST, that sandboxing should not be too hard either - advice on this aspect would be appreciated. Paul Wray -- http://mail.python.org/mailman/listinfo/python-list