alternative to with statement?

2012-02-28 Thread Craig Yoshioka
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 _ in cachingcontext(x): # create cached resources here # return

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 # return

Re: alternative to with statement?

2012-02-28 Thread Chris Kaynor
On Tue, Feb 28, 2012 at 1:04 PM, Craig Yoshioka crai...@me.com 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

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

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

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'