Aug-02-2021, 05:05 PM
(This post was last modified: Aug-02-2021, 05:05 PM by deanhystad.)
Sorry, I was editing my response. See above.
You cannot use the process.extractOne() return value as a True/False. extractOne returns a tuple (match, score) and the only tuple that evaluates to False is an emtpy tuple (,). Even if every choice results in a matching score of 0, extractOne will return a tuple containing the best match and the score.
Proof that only an empty tuple is False.
You cannot use the process.extractOne() return value as a True/False. extractOne returns a tuple (match, score) and the only tuple that evaluates to False is an emtpy tuple (,). Even if every choice results in a matching score of 0, extractOne will return a tuple containing the best match and the score.
Proof that only an empty tuple is False.
def evaluate(thing): if thing: print(f'{thing} is True') else: print(f'{thing} is False') evaluate((False, False)) evaluate((False,)) evaluate(tuple())
Output:(False, False) is True
(False,) is True
() is False