Unpack list to variables
I have a list:
row = ["Title", "url", 33, "title2", "keyword"]
Is there a more pythonic way to unpack this values like:
title, url, price, title2, keyword = row[0], row[1], row[2], row[3], row[4]
Solution 1:
Something like this?
>>> row = ["Title", "url", 33, "title2", "keyword"]
>>> title, url, price, title2, keyword = row
Solution 2:
Also if you need only few first variables, in Python 3 you can use:
row = ["Title", "url", 33, "title2", "keyword"]
title, url, *_ = row
It's a nice way to extract few first values without using explicit indices