If I want to generate a list of tuples based on elements of lines of a document, i can do :
[(line.split()[0], line.split()[-1][3:8]) for line in open("doc.txt")]
for example (i added the slicing to show that I might want use some operations on the elements of the split).
Still I would like to avoid using split two times, because that's unefficient.
So I wanted to use something like unpacking, with
[(linesplit0, linesplit1[3:8]) for line in open("doc.txt") for (linesplit0, linesplit1) in line.split()]
but that can't work since there are no tuples in the split, so at each element of the split we will be lacking one element.
What I would like is something that allows to use a placeholder name for the list resulting of the split (like splittedlist or whatever), and that could be used with indexing (splittedlist[0]), or unpacking or both), and that would be compatible with the comprehension list syntax.
Is it feasible?