DEV Community

Discussion on: Lessons From Advent of Code: Tuple Unpacking

Collapse
 
philipstarkey profile image
Phil Starkey

Given the data is in a list, and sequential, it would be clearer to just directly unpack the list, rather than using an intermediate tuple:

opcode, loc1, loc2, loc3 = program[pos:pos+4]

I think that's readable. But if there isn't an existing relationship between the values, assigning across multiple lines is definitely better for the reasons Ben suggested.

Thread Thread
 
datadeverik profile image
Erik Anderson

Thanks.

That's clever, and I agree it's readable.