[New-bugs-announce] [issue11426] CSV examples can't close their files

Graham Wideman 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
components: Documentation
messages: 130228
nosy: docs at python, gwideman
priority: normal
severity: normal
status: open
title: CSV examples can't close their files
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11426>
_______________________________________


More information about the New-bugs-announce mailing list