/ // kianhean.com / blog

random ramblings about technology in singapore

topics
about



Cool Python Snippets

April 5, 2021

Some Cool Snippets Collected Over the Years

# Merge 2 Python Dictionaries
x = {'a': 1}
y = {'b': 2}

z = x | y          # NOTE: 3.9+ ONLY
z = {**x, **y}     # NOTE: >3.5 ONLY