TGViewer
Python Learning Python Learning @python_bds · 5.75K subscribers
Post #973 965
Looks neat, right? But let’s slow down.

The *b syntax is called extended iterable unpacking. It grabs everything in the middle of the list, leaving the first item (a) and the last (c) outside the star. This pattern is super handy, but can also behave unexpectedly if you assume it’ll grab just one item or not consider the structure of the data.

The starred variable always gets a list, and it can be empty so plan accordingly when unpacking, especially in function arguments or loops.
For example: Consider the following code
x, *y = [42]
print(y)  # []


No error, but y is just an empty list! Unpacking doesn’t always fill every name the way you might guess.
  • ❤ 1
  • 👍 1
More from @python_bds
  1. Oct 10, 2026document post
  2. Oct 10, 2026This Book Explains more than 400 Concepts with codes.
  3. Oct 8, 2026🐛 This Python Bug Looks Random, But It Isn't Look at this: functions = [] for i in range(…
  4. Oct 6, 2026🐍 Python Performance Optimization Python Performance Optimization: Make Your Code Faster…
  5. Oct 4, 2026Python Set Methods ✍️
  6. Oct 3, 2026Post #1310
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →