Gary Herron wrote:
> Alex Dempsey wrote:
>> for line in lines:
>> line = line[1:-5]
>> line = line.split('\"\t\"')
> This, in fact, did do the operation you expected, but after creating the
> new value and assigning it to line, you promptly threw it away. (Because
> the loop then went back to the top and (re)assigned the next thing in
> lines to line wiping out your nicely sliced computation in lines.) You
> need to *do* something with the value in line before you end the loop --
> but what?
As an intermediate tip, the entire loop can be written as a single list
comprehension:
stuff = [li[1:-5].split('"\t"') for li in lines]
(You don't need to escape single quotes inside double-quoted strings,
and vice versa.)
--
http://mail.python.org/mailman/listinfo/python-list