Re: Slicing every element of a list

2005-07-13 Thread bruno modulix
Alex Dempsey wrote: > Recently I tried to slice every element of a list of strings. First I tried: > > f = open("export.xls", "r") http://www.python.org/doc/2.4.1/lib/module-csv.html (snip, see other posts in this thread) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for

Re: Slicing every element of a list

2005-07-12 Thread John Machin
Alex Dempsey wrote: > Recently I tried to slice every element of a list of strings. First I tried: "slice"? Interesting terminology. Next problem you have, try posting an example of your input, and your expected output. E.g. repr(input_string): '"foo"\t"barre"\t"zot"\t"X"\n' repr(output_list): [

Re: Slicing every element of a list

2005-07-12 Thread Thomas Lotze
Alex Dempsey wrote: > for line in lines: > line = line[1:-5] > line = line.split('\"\t\"') > > This went without returning any errors, but nothing was sliced or split. > Next I tried: > > for i in range(len(lines)): > lines[i] = lines[i][1:-5] > lines[i] = lines[i].split('\"\t\"'

Re: Slicing every element of a list

2005-07-12 Thread Scott David Daniels
Alex Dempsey wrote: > Recently I tried to slice every element of a list of strings. First I tried: > > f = open("export.xls", "r") > lines = f.readlines() > > for line in lines: > line = line[1:-5] > line = line.split('\"\t\"') > > This went without returning any errors, but nothing was

Re: Slicing every element of a list

2005-07-12 Thread Christopher Subich
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

Re: Slicing every element of a list

2005-07-12 Thread Gary Herron
Alex Dempsey wrote: >Recently I tried to slice every element of a list of strings. First I tried: > >f = open("export.xls", "r") >lines = f.readlines() > >for line in lines: >line = line[1:-5] >line = line.split('\"\t\"') > > This, in fact, did do the operation you expected, but after cr

Slicing every element of a list

2005-07-12 Thread Alex Dempsey
Recently I tried to slice every element of a list of strings. First I tried: f = open("export.xls", "r") lines = f.readlines() for line in lines: line = line[1:-5] line = line.split('\"\t\"') This went without returning any errors, but nothing was sliced or split. Next I tried: for i in