> with open(self.full_path, 'r') as input, open(self.output_csv, 'ab') as > output: > fieldnames = (...) > csv_writer = DictWriter(output, filednames) > # Call csv_writer.writeheader() if file is new. > csv_writer.writerows(my_dict) > > I'm wondering what's the best way of calling writeheader() only if the file is > new? > > My understanding is that I don't want to use os.path.exist(), since that opens > me up to race conditions.
What stops you from checking before and setting a flag? -- https://mail.python.org/mailman/listinfo/python-list