Re: Generating nested code with context managers

2010-05-05 Thread Dan Goodman
I tried a very similar thing, but not using with statements: http://mail.python.org/pipermail/python-list/2010-March/1239577.html Dan On 04/05/2010 22:36, Terry Reedy wrote: In a current thread, people have claimed that generating properly indented nested blocks is a pain because of the need t

Re: Generating nested code with context managers

2010-05-04 Thread alex23
On May 5, 6:36 am, Terry Reedy wrote: > The relatively new with statement and associated context managers are > designed, among other things, for this situation, where one needs to > alter and restore a global context. So here is my updated (3.1) > proof-of-concept version. This is what I love ab

Re: Generating nested code with context managers

2010-05-04 Thread python
Terry, > So here is my updated (3.1) proof-of-concept version. Very clever! An excellent example of how to use the 'with' statement with something besides the traditional file open example. Not the original OP, but thank you anyway. Malcolm -- http://mail.python.org/mailman/listinfo/python-li

Generating nested code with context managers

2010-05-04 Thread Terry Reedy
In a current thread, people have claimed that generating properly indented nested blocks is a pain because of the need to keep track of indent levels. Someone countered with the now rather ancient http://effbot.org/zone/python-code-generator.htm The usage example c = CodeGeneratorBackend() c.