def printout(queries, things, default=None, f=sys.stdout, **kwargs):
 results = denorm(queries, things, default=None)
 fields = set(itertools.chain(*(x.keys() for x in results)))
 W = csv.DictWriter(f=f, fieldnames=fields, **kwargs)
 W.writeheader()
 for r in results:
  W.writerow(r)

def printout ( queries , things , default = None , f = sys . stdout , ** kwargs ) : results = denorm ( queries , things , default = None ) fields = set ( itertools . chain ( * ( x . keys ( ) for x in results ) ) ) W = csv . DictWriter ( f = f , fieldnames = fields , ** kwargs ) W . writeheader ( ) for r in results : W . writerow ( r )
will print header and objects **kwargs go to csv .