Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21007 > unrolled thread

RE: alternative to with statement?

Started by"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
First post2012-02-28 22:12 +0000
Last post2012-02-28 22:12 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  RE: alternative to with statement? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-02-28 22:12 +0000

#21007 — RE: alternative to with statement?

From"Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Date2012-02-28 22:12 +0000
SubjectRE: alternative to with statement?
Message-ID<mailman.264.1330467191.3037.python-list@python.org>
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 cached resources

Is this a common pattern? I thought the point of the context manager 
was to remove create and close the resources (like with file opening).
Seems slightly odd to use just for creation...but maybe only because
I have never used it like that.


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web