Open this example in the interactive library
Source code
event = {'type':'created','id':7}
match event:
case {'type':'created','id':identifier}:
print('Created', identifier)
case _:
print('Unknown')Sample output
Created 7

Use structural pattern matching. A self-contained example using the Python standard library.
Open this example in the interactive library
event = {'type':'created','id':7}
match event:
case {'type':'created','id':identifier}:
print('Created', identifier)
case _:
print('Unknown')Created 7