t = (1,2)
a, b = t # a=1, b=2 이를 언패킹이라고 함
 
 
favorite_snacks = {
    '짭조름한 과자': ('프레즐', 100),
    '달콤한 과자': ('쿠키', 180),
    '채소': ('당근', 20),
}
# 복잡한 이터러블도 언패킹 가능
((type1, (name1, cals1)),
 (type2, (name2, cals2)),
 (type3, (name3, cals3))) = favorite_snacks.items()
 
x, y = y, x # 이런것도 가능
 
# 언패킹을 이용하면 enumerate()를 사용해서 인덱스를 통해 접근하는것보다 깔끔함
 
for index, (type, (name, calories)) in enumerate(favorite_snacks.items(), 1):
	print(f'#{index}: {type} 중에 {name}{calories} 칼로리다.')
 

또한 별표식을 통해 언패킹을 하면 슬라이싱보다 깔끔하게 할수있다.

a = [1,2,3,4,5,6,7,8,9]
# 아래의 슬라이싱은 매우 불편하다
small = a[0]
second_big = a[-2]
elses = a[1:-2] + a[-1]
 
 
# starred expression
small, *else1, second_big, else2 = a
elses = else1 + else2

참고자료 :