On 03/10/2016 07:59 PM, Neal Becker wrote:
sohcahto...@gmail.com wrote:
On Thursday, March 10, 2016 at 10:33:47 AM UTC-8, 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?
Paul Rubin writes:
> Jussi Piitulainen writes:
>> return ModeIO(f.read())
>
> These suggestions involving f.read() assume the file contents are small
> enough to reasonably slurp into memory. That's unlike the original
> where "load" receives a stream and might process it piecewise.
If y
Jussi Piitulainen writes:
> return ModeIO(f.read())
These suggestions involving f.read() assume the file contents are small
enough to reasonably slurp into memory. That's unlike the original
where "load" receives a stream and might process it piecewise.
--
https://mail.python.org/mailma
Chris Angelico writes:
> On Fri, Mar 11, 2016 at 5:33 AM, 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?
>
> Yep!
>
> def read_file(fn, *a, **kw):
> with ope
On Fri, 11 Mar 2016 05:33 am, 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?
Depends on what you mean by "ensure". Have load() call the file's close
method may be g
On Fri, Mar 11, 2016 at 5:33 AM, 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?
Yep!
def read_file(fn, *a, **kw):
with open(fn, *a, **kw) as f:
return f.
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
On Thu, Mar 10, 2016 at 11:59 AM, Neal Becker wrote:
> sohcahto...@gmail.com wrote:
>
>> On Thursday, March 10, 2016 at 10:33:47 AM UTC-8, 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 e
sohcahto...@gmail.com wrote:
> On Thursday, March 10, 2016 at 10:33:47 AM UTC-8, 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?
>
> with open('my file', 'rb')
On Thursday, March 10, 2016 at 10:33:47 AM UTC-8, 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?
with open('my file', 'rb') as f:
x = load(f)
--
https://mail.p
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?
--
https://mail.python.org/mailman/listinfo/python-list
11 matches
Mail list logo