[Tutor] Regular expression re.search() object . Please help

jfouhy at paradise.net.nz jfouhy at paradise.net.nz
Thu Jan 13 22:32:38 CET 2005


Quoting Jeff Shannon <jeff at ccvcorp.com>:

> If the intent is simply to remove all lines that begin with "Name=", 
> and setting those lines to an empty string is just shorthand for that, 
> it'd make more sense to do this with a filtering list comprehension:
[...]
> If one wants to avoid list comprehensions, you could instead do:
[...]

Or, since we're filtering, we could use the filter() function!

probe_pairs = filter(lambda x: not x.startswith('Name='), probe_pairs)

(hmm, I wonder which is the faster option...)

-- 
John.


More information about the Tutor mailing list