[Tutor] Aschenputtel problem
Christopher Arndt
chris.arndt at web.de
Fri Sep 16 17:11:17 CEST 2005
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
More information about the Tutor
mailing list