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

I think it only works out that way when you're unpacking the same number of variables as there are elements in c, which is the same as (a,b) = c and c = (a,b).

If you tried something like c = (('d','e','f'),('g','h')) and then a,b = zip(*c) you'd get a = ('d','g') and b = ('e','h'). The 'f' that was originally at c[0][2] is dropped so you can't zip back to the original value of c, unless that's how inverses work for this scenario and my math is rusty.



It works only because zip drops extra items. I explained how it works in the reply below.




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

Search: