RE: alternative to with statement?

2012-02-28 Thread Prasad, Ramit
Craig Yoshioka wrote: >It is a bit non-normal. but I think this is a good use case as I want to >create a very simple-to-use system for non-python experts to safely wrap their >CLI programs in a caching architecture... that's why I lament the inability to >not use the more streamlined 'with' sy

Re: alternative to with statement?

2012-02-28 Thread Craig Yoshioka
It is a bit non-normal. but I think this is a good use case as I want to create a very simple-to-use system for non-python experts to safely wrap their CLI programs in a caching architecture... that's why I lament the inability to not use the more streamlined 'with' syntax– abusing the for loo

Re: alternative to with statement?

2012-02-28 Thread Terry Reedy
On 2/28/2012 5:12 PM, Prasad, Ramit wrote: Craig Yoshioka wrote: I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. [..] I would have really liked: with cachingcontext(

Re: alternative to with statement?

2012-02-28 Thread Chris Kaynor
On Tue, Feb 28, 2012 at 1:04 PM, Craig Yoshioka wrote: > > I see that there was previously a PEP to allow the with statement to skip the > enclosing block... this was shot down, and I'm trying to think of the most > elegant alternative. > The best I've found is to abuse the for notation: > > for

RE: alternative to with statement?

2012-02-28 Thread Prasad, Ramit
Craig Yoshioka wrote: >I see that there was previously a PEP to allow the with statement to skip the >enclosing block... this was shot down, and I'm trying to think of the most >elegant alternative. [..] >I would have really liked: >with cachingcontext(x): ># create cached resources here >#