[docs] [issue11426] CSV examples can't close their files
report at bugs.python.org
Mon Mar 7 07:19:32 CET 2011
New submission from Graham Wideman <initcontact at grahamwideman.com>:
On the csv doc page (.../library/csv.html) most of the examples show creation of an anonymous file object within the csv.reader or csv.writer function, for example...
spamWriter = csv.writer(open('eggs.csv', 'w'), delimiter=' ',....
This anonymity prevents later closing the file, which seems especially problematic for a writer. It also confuses users as to whether there's some sort of close function on a csv.reader or csv.writer object which should be called, or perhaps some other magic behind the scenes.
I'm pretty sure that it's the doc that is incorrect here.
This issue was raised pernthetically here http://bugs.python.org/issue7198#msg124678 by sjmachin, though mysteriously overlooked in his later suggested patch http://bugs.python.org/issue7198#msg126593
I suggest changing all examples to include the complete cycle of opening an explicit file, and later closing it.
assignee: docs at python
nosy: docs at python, gwideman
title: CSV examples can't close their files
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the docs