summaryrefslogtreecommitdiffstats
path: root/Lib/csv.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-03-21 20:01:51 (GMT)
committerGeorg Brandl <georg@python.org>2008-03-21 20:01:51 (GMT)
commit77354cf5ef9644121a28041216591762628d8b65 (patch)
treeb0fc669e46257a85f58988cd93180cfe5cc71ef8 /Lib/csv.py
parent331243270dc91cfccd31b071abb8d2fcf84a7984 (diff)
downloadcpython-77354cf5ef9644121a28041216591762628d8b65.zip
cpython-77354cf5ef9644121a28041216591762628d8b65.tar.gz
cpython-77354cf5ef9644121a28041216591762628d8b65.tar.bz2
Issue #2432: give DictReader the dialect and line_num attributes
advertised in the docs.
Diffstat (limited to 'Lib/csv.py')
-rw-r--r--Lib/csv.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/csv.py b/Lib/csv.py
index 8c6b740..41026e0 100644
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -75,6 +75,8 @@ class DictReader:
self.restkey = restkey # key to catch long rows
self.restval = restval # default value for short rows
self.reader = reader(f, dialect, *args, **kwds)
+ self.dialect = dialect
+ self.line_num = 0
def __iter__(self):
return self
@@ -84,6 +86,7 @@ class DictReader:
if self.fieldnames is None:
self.fieldnames = row
row = self.reader.next()
+ self.line_num = self.reader.line_num
# unlike the basic reader, we prefer not to return blanks,
# because we will typically wind up with a dict full of None