[New-bugs-announce] [issue27497] csv module: Add return value to DictWriter.writeheader

Logan report at bugs.python.org
Tue Jul 12 11:14:08 EDT 2016


New submission from Logan:

Currently, DictWriter.writeheader() is defined like:

    def writeheader(self):
        header = dict(zip(self.fieldnames, self.fieldnames))
        self.writerow(header)

It would be useful to have it return the value of writerow():

    def writeheader(self):
        header = dict(zip(self.fieldnames, self.fieldnames))
        return self.writerow(header)

This would useful because:
1) It would match the behavior of DictWriter.writerow
2) It would enable DictWriter.writeheader to be used in within a generator function (ala https://docs.djangoproject.com/en/1.9/howto/outputting-csv/#streaming-large-csv-files)

----------
messages: 270248
nosy: lsowen
priority: normal
severity: normal
status: open
title: csv module: Add return value to DictWriter.writeheader
type: enhancement
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27497>
_______________________________________


More information about the New-bugs-announce mailing list