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


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

Re: context managers inline?

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2016-03-10 19:45 +0000
Last post2016-03-10 19:45 +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: context managers inline? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-10 19:45 +0000

#104547 — Re: context managers inline?

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2016-03-10 19:45 +0000
SubjectRe: context managers inline?
Message-ID<mailman.151.1457639182.15725.python-list@python.org>
On 10/03/2016 18:33, Neal Becker wrote:
> Is there a way to ensure resource cleanup with a construct such as:
>
> x = load (open ('my file', 'rb))
>
> Is there a way to ensure this file gets closed?
>

I don't see how there can be.  Surely you must split it into two lines 
to use the context manager via the 'with' keyword, or you leave the one 
line as is and forego the context manager.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [standalone]


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


csiph-web