Alan G Isaac alan.isaac at gmail.com
Thu Aug 13 05:15:51 CEST 2009

> On Aug 13, 6:45 am, Alan G Isaac <alan.is... at gmail.com> wrote:
>> Given a csv.DictWriter instance `dw`
>> I think it would be nice to be able to
>> say dw.write_header()
>> instead of
>> dw.writer.writerow(dw.fieldnames)
>> Good idea?

On 8/12/2009 10:24 PM John Machin apparently wrote:
> Yes, it's a brilliant idea. All you have to do is insert the following
> lines in your code after importing csv:
> csv.DictWriter.write_header = (
>     lambda dw: dw.writer.writerow(dw.fieldnames)
>     )

I do not understand the reason for your silly, sarcastic response.
I already showed you how to achieve the result, so obviously
I am not just asking for my own personal gain.

I take it you do not realize that many users do not see
a simple way to get this often needed functionality.
(For example, see the gymnatics suggested by Shai Vaingast
in his otherwise excellent and useful book.) And indeed,
there is no reason to expect them to.

So my question was, would this improve the class from
a usability perspective?  Do you have a useful response?

Alan Isaac

More information about the Python-list mailing list