Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104547
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: context managers inline? |
| Date | 2016-03-10 19:45 +0000 |
| Message-ID | <mailman.151.1457639182.15725.python-list@python.org> (permalink) |
| References | <nbselg$he9$1@ger.gmane.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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: context managers inline? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-10 19:45 +0000
csiph-web