In attempting to read the source code for the csv.py
file (as a guide to implementing my own writer
class in another context) I found that much of the functionality in that file is, in turn, imported from something called _csv
:
from _csv import Error, __version__, writer, reader, register_dialect, \
unregister_dialect, get_dialect, list_dialects, \
field_size_limit, \
QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \
__doc__
I cannot find any file with this name on my system (including searching for files with the Hidden attribute set), although I can do import _csv
from the Python shell.
What is this module and is it possible to read it?
_csv
is the C "backbone" of the csv
module. Its source is in Modules/_csv.c
. You can find the compiled version of this module from the Python command prompt with:
>>> import _csv
>>> _csv
<module '_csv' from '/usr/lib/python2.6/lib-dynload/_csv.so'>
There are no hidden files in the Python source code :)