Skip to content

Instantly share code, notes, and snippets.

@bjacobel
Last active August 29, 2015 14:27
Show Gist options
  • Save bjacobel/84aaf25f70e4d253db5d to your computer and use it in GitHub Desktop.
Save bjacobel/84aaf25f70e4d253db5d to your computer and use it in GitHub Desktop.
splat-unpack in python 2
def unpack(arr, unpack_into):
rets = ()
for i in xrange(len(arr)):
if i < unpack_into - 1:
rets += (arr.pop(0),)
else:
rets += (arr,)
break
return rets
a, b, rest = unpack("1\t2\t3\t4".split("\t"), 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment