Late editing
Now, one year wiser and understanding the question ... I would suggest a simple
raw_data = [tuple(ssp[:2]) for s in all_lines for ssp in [s.split(',')] if ssp[1]!='"NaN"']
which works correctly because [s.split(',')] is a list whose only element is the list returned by s.split(',') , and righmost / inner loop, for ssp in [s.split(',')] - roughly equivalent to temporary assignment, ssp = s.split('',)
My initial answer
<sub> I have some problem in understanding the question, but if you want to use a temporary variable in understanding the list, put the value (or expression) that you need in the list, all alone! and use a different sub list comprehension >
In [1]: [a*b for b in [10] for a in [1,2,3,4,5]] Out[1]: [10, 20, 30, 40, 50] In [2]:
<sub> The rightmost understanding is what is in the inner loop, so if you have a function that uses a lot of time to calculate the time value that should be used in list comprehension, e; g; next ;-) sub>
In [2]: def long_computation(x): print 1 ; return x
<sub> then the next two constructs return exactly the same list, but ... sub>
In [3]: [a*b for b in [long_computation(10)] for a in [1,2,3,4,5]] 1 Out[3]: [10, 20, 30, 40, 50] In [4]: [a*b for a in [1,2,3,4,5] for b in [long_computation(10)]] 1 1 1 1 1 Out[4]: [10, 20, 30, 40, 50]