On Wed, Aug 22, 2012 at 3:06 AM, Peter Otten <__pete...@web.de> wrote: > > wanted = [line.strip("\n") for line in lines > if "vn" not in line and "vt" not in line and line != "\n"]
Here's an equivalent expression with the negation factored out: not ("vn" in line or "vt" in line or line == "\n") http://en.wikipedia.org/wiki/De_Morgan%27s_laws If you have a lot of tests all using the same operator (e.g. "in"), you can use "any" (OR) or "all" (AND) with a generator expression: vals = ["vn", "vt", "vu", "vv", "vw", "vx", "vy", "vz"] wanted = [line for line in lines if not any(v in line for v in vals)] _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor