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


Groups > comp.lang.python > #14934

Re: CSV writer question

Date 2011-10-24 21:35 +0100
From Andrew McLean <lists@andros.org.uk>
Subject Re: CSV writer question
References <CAEk9e3rzxQruEO4J_xc8pxw9y4mq6QK2HK=nTX7TdECm2+T8+g@mail.gmail.com> <CAPTjJmqV34UGamM7FHcggv_yitiBvz9rroQOo-bm_1fR8LFBLQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2190.1319488517.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 24/10/2011 08:03, Chris Angelico wrote:
> On Mon, Oct 24, 2011 at 4:18 PM, Jason Swails<jason.swails@gmail.com>  wrote:
>> my_csv = csv.writer(open('temp.1.csv', 'wb'))
>>
> Have you confirmed, or can you confirm, whether or not the file gets
> closed automatically when the writer gets destructed? If so, all you
> need to do is:
>
> my_csv = something_else
> # or:
> del my_csv
>
> to unbind what I assume is the only reference to the csv.writer, upon
> which it should promptly clean itself up.
My understanding is that in cpython the file does get closed when the 
writer is deleted, however, it's not guaranteed to happen in other 
Python implementations (e.g. IronPython, PyPy and Jython).

Andrew

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: CSV writer question Andrew McLean <lists@andros.org.uk> - 2011-10-24 21:35 +0100

csiph-web