New submission from Graham Wideman <initcont...@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@python
components: Documentation
messages: 130228
nosy: docs@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue11426>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to