This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Mariatta
Recipients Mariatta, hughdbrown, mtraskin, peter.otten, serhiy.storchaka, terry.reedy
Date 2016-10-21.04:20:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1477023611.48.0.125033395098.issue18219@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks Hugh,

Are you thinking of something like the following?

class DictWriter:
    def __init__(self, f, fieldnames, restval="", extrasaction="raise",
                 dialect="excel", *args, **kwds):
        self._fieldnames = fieldnames    # list of keys for the dict
        self._fieldnames_set = set(self._fieldnames)

    @property
    def fieldnames(self):
        return self._fieldnames

    @fieldnames.setter
    def fieldnames(self, value):
        self._fieldnames = value
        self._fieldnames_set = set(self._fieldnames)


    def _dict_to_list(self, rowdict):
        if self.extrasaction == "raise":
            wrong_fields = rowdict.keys() - self._fieldnames_set
     
    ...

If so, I can work on another patch.
Thanks.
History
Date User Action Args
2016-10-21 04:20:11Mariattasetrecipients: + Mariatta, terry.reedy, peter.otten, serhiy.storchaka, mtraskin, hughdbrown
2016-10-21 04:20:11Mariattasetmessageid: <1477023611.48.0.125033395098.issue18219@psf.upfronthosting.co.za>
2016-10-21 04:20:11Mariattalinkissue18219 messages
2016-10-21 04:20:11Mariattacreate