The code:
if (query_id, _) in hashtable[bucket]:
NameError: global name '_' is not defined
hastable[bucket]
The x in y
is not magic; it's basically the same as y.__contains__(x)
. Therefore, in
cannot search with placeholders; the left argument is fully evaluated. Instead, use
if any(query_id == qid for (qid, _) in hashtable[bucket]):