Re: [Tutor] Removing lines in string-table

2005-05-17 Thread Olli Rajala
My code: > > for line in fileNames: > > if line[-10:] == '_thumb.jpg': > > fileNames.remove(line) Chris wrote: > The above will not work if two successive lines contain the target > text. When you remove the one, its neighbor "slides over" to take the > place of the one removed and the

Re: [Tutor] Removing lines in string-table

2005-05-17 Thread Chris Smith
On Tuesday, May 17, 2005, at 08:35 America/Chicago, [EMAIL PROTECTED] wrote: > I have a string table (don't recall the right word used in Python > right now) and would like to remove every 'cell' that contains a > string '_thumb.jpg'. There are 1-> digits before the string if that > matters. I m

Re: [Tutor] Removing lines in string-table

2005-05-17 Thread Olli Rajala
> Looks like a job for a list comprehension: > > fileNames = [element for element in fileNames if not element.endswith > ("_thumb.jpg")] Thanks Max! It seem to work, but now I have to do some reading, because I have no idea why it works or what it really does. :) But thanks anyway. Yours,

Re: [Tutor] Removing lines in string-table

2005-05-17 Thread Max Noel
On May 17, 2005, at 08:52, Olli Rajala wrote: > Okay, > I have a string table (don't recall the right word used in Python > right now) It's called a list, or an array. > and would like to remove every 'cell' that contains a > string '_thumb.jpg'. There are 1-> digits before the string if t

[Tutor] Removing lines in string-table

2005-05-17 Thread Olli Rajala
Okay, I have a string table (don't recall the right word used in Python right now) and would like to remove every 'cell' that contains a string '_thumb.jpg'. There are 1-> digits before the string if that matters. I made a for-loop that does what I want to: for line in fileNames: if line[-10:]