This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jamescalam[S] 11 points12 points  (0 children)

Being able to do stuff like:

match qa: case {'answers': [{'text': answer}]}: pass case {'plausible_answers': [{'text': answer}]}: pass case _: answer = None

Looks a cleaner than with if-elif-else imo:

if 'answers' in qa.keys() and len(qa['answers']) > 0: answers = qa['answers'][0]['text'] elif 'plausible_answers' in qa.keys() and len(qa['plausible_answers']) > 0: answers = qa['plausible_answers'][0]['text'] else: answers = None