CSV writer question

Jason Swails jason.swails at gmail.com
Mon Oct 24 16:13:50 EDT 2011


On Mon, Oct 24, 2011 at 3:03 AM, Chris Angelico <rosuav at gmail.com> wrote:

> On Mon, Oct 24, 2011 at 4:18 PM, Jason Swails <jason.swails at 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
>

I'm not sure why I decided against this approach in the first place.  This
does work (at least with my test), so it's what I'll do.  I probably wasn't
confident that it would clean itself up properly, but that's probably rather
un-pythonic and would not have made it into the stdlib if that was the case.

Thanks!
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111024/bcb0176a/attachment-0001.html>


More information about the Python-list mailing list