Re: [Python-Dev] AST manipulation and source code generation

2005-06-02 Thread Gareth McCaughan
> ?!ng: Well, i should refine that a bit to say that the Lisp macro system > is a little more specific. Whereas AST transformations in Python > are open-ended (you could generate any result you want), the key > interesting property of Lisp macros is that they are constrained > to be "safe", in the

Re: [Python-Dev] AST manipulation and source code generation

2005-05-26 Thread Jeremy Hylton
On 5/26/05, Chad Whitacre <[EMAIL PROTECTED]> wrote: > chad: Hmmm ... I don't follow python-dev closely but hasn't there been > resistance to macros in Python? Are we saying macros may be a good idea > after all? > > ?!ng: resistance -> Yes. > ?!ng: good idea -> Not really. AST transformations ar

Re: [Python-Dev] AST manipulation and source code generation

2005-05-26 Thread Chad Whitacre
Thanks Jeremy. Also wandered off-list w/ Ka-Ping; posting here for posterity. chad - chad: BTW, how does the concept of AST transformations relate to the concept of (Lisp) macros? Am I right to think that they are similar? ?!ng: Absolutely. In terms of mechanism, they're basically the s

Re: [Python-Dev] AST manipulation and source code generation

2005-05-26 Thread Jeremy Hylton
On 5/26/05, Chad Whitacre <[EMAIL PROTECTED]> wrote: > > Would there be any interest in extending the compiler package with tools > > for AST transformations and for emitting Python source code from ASTs? > > Heh, so I guess the answer is "yes." > > BTW, how does the concept of AST transformation

Re: [Python-Dev] AST manipulation and source code generation

2005-05-26 Thread Chad Whitacre
> Would there be any interest in extending the compiler package with tools > for AST transformations and for emitting Python source code from ASTs? Heh, so I guess the answer is "yes." BTW, how does the concept of AST transformations relate to the concept of (Lisp) macros? Am I right to think th

Re: [Python-Dev] AST manipulation and source code generation

2005-05-26 Thread Sylvain Thénault
> > On 5/24/05, Ka-Ping Yee <[EMAIL PROTECTED]> wrote: > > > > > >> Would there be any interest in extending the compiler package with > >> tools > >> for AST transformations and for emitting Python source code from > >> ASTs? the astng package from logilab's common library [1] extends compile

Re: [Python-Dev] AST manipulation and source code generation

2005-05-25 Thread Chad Whitacre
Ka-Ping, FWIW, I've also got an implementation, which is based on the parser module rather than the compiler module. Much simpler, imo, but whitespace isn't preserved (could be perhaps?). Anyway, take it or leave it. Links follow. chad - Subversion repository: http://svn.zetadev.com/

Re: [Python-Dev] AST manipulation and source code generation

2005-05-25 Thread Andy Gross
I wrote something like this (called pyunparse) a little while ago. It's not the cleanest code in the world, but it worked for my original use case (debugging Logix, which uses python ASTs as an IR): http://www.pycs.net/users/445/stories/7.html Cheers, /arg On May 24, 2005, at 9:56

Re: [Python-Dev] AST manipulation and source code generation

2005-05-24 Thread Jeremy Hylton
On 5/24/05, Ka-Ping Yee <[EMAIL PROTECTED]> wrote: > Would there be any interest in extending the compiler package with tools > for AST transformations and for emitting Python source code from ASTs? Sure. Eventually, we'll have to figure out how to unify the compiler package AST and the ast-branc

[Python-Dev] AST manipulation and source code generation

2005-05-23 Thread Ka-Ping Yee
Would there be any interest in extending the compiler package with tools for AST transformations and for emitting Python source code from ASTs? I was experimenting with possible translations for exception chaining and wanted to run some automated tests, so i started playing around with the compile