def default_iget(fields, default=None):
 myiget = operator.itemgetter(*fields)
 L = len(fields)
 def f(thing):
  try:
   ans = list(myiget(thing))
   if (L < 2):
    ans = [ans]
   return ans
  except KeyError:
   return [thing.get(x, default) for x in fields]
 f.__doc__ = ('itemgetter with default %r for fields %r' % (default, fields))
 f.__name__ = 'default_itemgetter'
 return f

def default_iget ( fields , default = None ) : myiget = operator . itemgetter ( * fields ) L = len ( fields ) def f ( thing ) : try : ans = list ( myiget ( thing ) ) if ( L < 2 ) : ans = [ ans ] return ans except KeyError : return [ thing . get ( x , default ) for x in fields ] f . __doc__ = ( 'itemgetter with default %r for fields %r' % ( default , fields ) ) f . __name__ = 'default_itemgetter' return f
itemgetter with default handling .