On Thu, Nov 5, 2009 at 8:19 PM, Peng Yu <pengyu...@gmail.com> 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. > > I'm wondering what is the best way to compute B in python.
Since this sounds rather homework-y, I'll only give you a pointer: http://docs.python.org/tutorial/datastructures.html#list-comprehensions Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list