Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unpacking applies to iterables. That seems obvious and easy, but the feature is commonly called "tuple unpacking" in the Python world despite the fact that more than tuples can be unpacked. I resolve the apparent conflict by thinking of the term as referring to the most common form of the literal on the left side of the statement, the same syntax as a tuple. If that's not the actual origin, fine, you win the pissing match. But where the name came from has zero bearing on the actual behavior of the language feature, and the point remains that the language feature is simple, consistent, and basic enough that if you don't understand it when you see it, you need to learn the language better.

The only other thing frequently unpacked is a list

Which isn't a tuple. You're the one trying to be pedantic, but you want to ding me for making this distinction?

it does not stretch the imagination that a read-only feature of tuples would work on their mutable cousin as well.

I agree, it doesn't. I don't see how it stretches the imagination that it works on general iterables, either.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: