Larry Lustig Larry Lustig - 1 year ago 86
Python Question

What is "_csv" in Python?

In attempting to read the source code for the
file (as a guide to implementing my own
class in another context) I found that much of the functionality in that file is, in turn, imported from something called

from _csv import Error, __version__, writer, reader, register_dialect, \
unregister_dialect, get_dialect, list_dialects, \
field_size_limit, \

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?

Answer Source

_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/'>

There are no hidden files in the Python source code :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download