Reputation: 3
I am trying to use the csv.reader function in Python 3.
dir('csv') displays (I have deleted some to shorten the post):
Code:
['__add__', ..., 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', ..., 'zfill']
What it does not show is 'reader'.
Is there any way to add the 'reader' function to the csv module?
Upvotes: 0
Views: 108
Reputation: 106455
'csv'
is just a string, so when you do dir('csv')
it just gives you all the attributes and methods available to str
.
If you do dir(csv)
(without the quotes) instead you will be able to see all the attributes and methods that the csv
module has (providing that you have imported the csv
module first):
>>> import csv
>>> dir(csv)
['Dialect', 'DictReader', 'DictWriter', 'Error', 'OrderedDict', 'QUOTE_ALL', 'QUOTE_MINIMAL', 'QUOTE_NONE', 'QUOTE_NONNUMERIC', 'Sniffer', 'StringIO', '_Dialect', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__', 'excel', 'excel_tab', 'field_size_limit', 'get_dialect', 'list_dialects', 're', 'reader', 'register_dialect', 'unix_dialect', 'unregister_dialect', 'writer']
Upvotes: 3