Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Peter Otten
Robert P. J. Day wrote: > On Sat, 7 Nov 2009, Peng Yu wrote: > >> On Fri, Nov 6, 2009 at 5:57 PM, Dave Angel wrote: > >> > But if you have an expression you want to match each dir against, >> > the list comprehension is the best answer. And the trick to >> > stuffing that new list into the ori

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Robert P. J. Day
On Sat, 7 Nov 2009, Peng Yu wrote: > On Fri, Nov 6, 2009 at 5:57 PM, Dave Angel wrote: > > But if you have an expression you want to match each dir against, > > the list comprehension is the best answer.  And the trick to > > stuffing that new list into the original list object is to use > > sli

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Peng Yu
On Fri, Nov 6, 2009 at 5:57 PM, Dave Angel wrote: > > > Peng Yu wrote: >> >> On Fri, Nov 6, 2009 at 10:42 AM, Robert P. J. Day >> wrote: >> >>> >>> On Fri, 6 Nov 2009, Peng Yu wrote: >>> >>> On Fri, Nov 6, 2009 at 3:05 AM, Diez B. Roggisch wrote: > > Peng Yu schrieb:

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Peng Yu
On Sat, Nov 7, 2009 at 8:54 AM, Steven D'Aprano wrote: > On Fri, 06 Nov 2009 10:16:58 -0600, Peng Yu wrote: > >> What is a list-comprehension? > > Time for you to Read The Fine Manual. > > http://docs.python.org/tutorial/index.html > > >> I tried the following code. The list 'l' will be ['a','b','

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Steven D'Aprano
On Fri, 06 Nov 2009 10:16:58 -0600, Peng Yu wrote: > What is a list-comprehension? Time for you to Read The Fine Manual. http://docs.python.org/tutorial/index.html > I tried the following code. The list 'l' will be ['a','b','c'] rather > than ['b','c'], which is what I want. It seems 'remove'

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-06 Thread Diez B. Roggisch
Peng Yu schrieb: Suppose I have a list of strings, A. I want to compute the list (call it B) of strings that are elements of A but doesn't match a regex. I could use a for loop to do so. In a functional language, there is way to do so without using the for loop. Nonsense. For processing over ea

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Lie Ryan
Peng Yu wrote: Suppose I have a list of strings, A. I want to compute the list (call it B) of strings that are elements of A but doesn't match a regex. I could use a for loop to do so. In a functional language, there is way to do so without using the for loop. In functional language, there is n

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Gabriel Genellina
En Fri, 06 Nov 2009 02:23:12 -0300, Peng Yu escribió: On Thu, Nov 5, 2009 at 10:25 PM, Chris Rebert wrote: On Thu, Nov 5, 2009 at 8:19 PM, Peng Yu wrote: Suppose I have a list of strings, A. I want to compute the list (call it B) of strings that are elements of A but doesn't match a regex.

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Chris Rebert
On Thu, Nov 5, 2009 at 9:23 PM, Peng Yu wrote: > On Thu, Nov 5, 2009 at 10:25 PM, Chris Rebert wrote: >> On Thu, Nov 5, 2009 at 8:19 PM, Peng Yu wrote: >>> Suppose I have a list of strings, A. I want to compute the list (call >>> it B) of strings that are elements of A but doesn't match a regex.

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Peng Yu
On Thu, Nov 5, 2009 at 10:25 PM, Chris Rebert wrote: > On Thu, Nov 5, 2009 at 8:19 PM, Peng Yu wrote: >> Suppose I have a list of strings, A. I want to compute the list (call >> it B) of strings that are elements of A but doesn't match a regex. I >> could use a for loop to do so. In a functional

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Chris Rebert
On Thu, Nov 5, 2009 at 8:19 PM, Peng Yu wrote: > Suppose I have a list of strings, A. I want to compute the list (call > it B) of strings that are elements of A but doesn't match a regex. I > could use a for loop to do so. In a functional language, there is way > to do so without using the for loo

What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Peng Yu
Suppose I have a list of strings, A. I want to compute the list (call it B) of strings that are elements of A but doesn't match a regex. I could use a for loop to do so. In a functional language, there is way to do so without using the for loop. I'm wondering what is the best way to compute B in p