Возможно, я что-то упускаю из виду, но нигде не могу найти решение предложение:
https://docs.python.org/3/whatsnew/3.10 ... n-matching
И еще немного об этом в PEP-636:
https://www.python.org/dev/peps/pep-063 ... -the-cloud -mappings
Мои данные выглядят так:
Код: Выделить всё
data = [{
"id" : "matchme-foo",
"message": "hallo this is a message",
},{
"id" : "matchme-bar",
"message": "goodbye",
},{
"id" : "anotherid",
"message": "completely diffrent event"
}, ...]
Что-то вроде это:
Код: Выделить всё
for event in data:
match event:
case {'id':'matchme-*'}: # Match all 'matchme-' no matter what comes next
log.INFO(event['message'])
case {'id':'anotherid'}:
log.ERROR(event['message'])
Подробнее здесь: https://stackoverflow.com/questions/701 ... -in-string