diff options
author | Georg Brandl <georg@python.org> | 2008-03-21 20:01:51 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-03-21 20:01:51 +0000 |
commit | 77354cf5ef9644121a28041216591762628d8b65 (patch) | |
tree | b0fc669e46257a85f58988cd93180cfe5cc71ef8 /Lib/csv.py | |
parent | 331243270dc91cfccd31b071abb8d2fcf84a7984 (diff) | |
download | cpython-git-77354cf5ef9644121a28041216591762628d8b65.tar.gz |
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.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/csv.py b/Lib/csv.py index 8c6b740127..41026e03bd 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 |