filter2
Oleg Broytmann
phd at phd.pp.ru
Thu Jun 13 09:33:13 EDT 2002
Hello!
I want to have new python builtin - filter2. It is exactly like filter,
but it returns also a list of items that didn't pass the test.
Of course I can do it with just "for" loop:
l1 = []
l2 = []
for item in alist:
if test(item):
l1.append(item)
else:
l2.append(item)
but this way I am missing filter's loop written in C.
Running filter two times (with test and inverted test) is not an option,
as test could be a costly function.
Opinions?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list