def needelts(query, elts): for elt in elts: if query[elt] == None: raise "need %s" % elt