Skip to content

Commit bff978b

Browse files
committed
Add dictionary merge explanation
1 parent 85cabee commit bff978b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

examples/04_operators/operators_dict.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Merging and updating dictionaries
2+
# -----------------------------------------------------------------------------
3+
# Python 3.9 introduced the | and |= operators to combine dictionaries. The |
4+
# operator creates a new dictionary containing keys from both operands, while
5+
# |= updates the dictionary on the left in place. This provides a concise
6+
# alternative to using the update() method or ** unpacking for merging.
7+
18
a = {'a': 1, 'b': 2, 'c': 3}
29
b = {'d': 4, 'e': 5}
310

0 commit comments

Comments
 (0)