5 Best Practices of Destructuring Assignments in Python

Assign the expected values easily

Yang Zhou
Yang Zhou
Jun 21 · 4 min read

Assigning values to variables is a basic operation of programming. Some programming languages, such as Python, have some syntax sugar to make the process more elegant.

Let’s see a simple example:

a, *mid, b = [1, 2, 3, 4, 5, 6]
print(a, mid, b)
# 1 [2, 3, 4, 5] 6