Pierre Barbier de Reuille schrieb: > Well, in the specific case of numeric arrays, you can use Numeric or > numarray : > > from Numeric import array, compress > > ol = array(original_list) > selection = array([condition(i) for i in original_list) > list1 = compress(selection, ol) > list2 = compress(!selection, ol)
This ! syntax isn't working for me (throws a syntax error). Is this defined by Numeric somewhere? This works (but see my upcoming post about benchmarking the different solutions): selection = [condition(i) for i in original_list] list1 = compress(selection, original_list) list2 = compress([not x for x in selection], original_list) Chris _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor