In ruby I can do something like:
key, *rest = ["key1", 1, 2, 3]
and the result will be:
key = "key1"
rest = [1, 2, 3]
Is there a way to do the same in python?
In ruby I can do something like:
key, *rest = ["key1", 1, 2, 3]
and the result will be:
key = "key1"
rest = [1, 2, 3]
Is there a way to do the same in python?
key,rest = my_list[0],my_list[1:]
is as close as you can get I think (in Python <= 2.7). In Python 3 your code works as is.