Re: Better way to negate a boolean list?

2008-02-10 Thread Gary Herron
David Trémouilles wrote: Hi, Is there any better (shorter) way to negate a boolean list than: negated_boolean_list = [not elem for elem in boolean_list] ? I tried: map(not, boolean_list) but it seems that not is not a function. Thanks in advance, David But import module

Re: Better way to negate a boolean list?

2008-02-10 Thread Paddy
On Feb 10, 7:46 am, David Trémouilles [EMAIL PROTECTED] wrote: Hi, Is there any better (shorter) way to negate a boolean list than: negated_boolean_list = [not elem for elem in boolean_list] ? I tried: map(not, boolean_list) but it seems that not is not a function. Thanks in

Re: Better way to negate a boolean list?

2008-02-10 Thread Steve Holden
Paddy wrote: On Feb 10, 7:46 am, David Trémouilles [EMAIL PROTECTED] wrote: Hi, Is there any better (shorter) way to negate a boolean list than: negated_boolean_list = [not elem for elem in boolean_list] ? I tried: map(not, boolean_list) but it seems that not is not a function.

Re: Better way to negate a boolean list?

2008-02-10 Thread Stargaming
On Sun, 10 Feb 2008 08:46:24 +0100, David Trémouilles wrote: [snip] I tried: map(not, boolean_list) but it seems that not is not a function. `not` is not a function, indeed. It is a keyword, allowing you to write ``not x`` instead of ``not(x)``. You can of course write a function that

Re: Better way to negate a boolean list?

2008-02-10 Thread David Trémouilles
Thanks to all of you for the prompt answer to my question. Just a short feedback: map(not_, boolean_list) looks more readable to me but: [not elem for elem in boolean_list] seems to be slightly faster (ipython timeit results) (python 2.5.1 MacOS X) Not a big deal anyway! Most important for

Re: Better way to negate a boolean list?

2008-02-10 Thread Paddy
On Feb 10, 1:41 pm, Steve Holden [EMAIL PROTECTED] wrote: Paddy wrote: On Feb 10, 7:46 am, David Trémouilles [EMAIL PROTECTED] wrote: Hi, Is there any better (shorter) way to negate a boolean list than: negated_boolean_list = [not elem for elem in boolean_list] ? I tried:

Better way to negate a boolean list?

2008-02-09 Thread David Trémouilles
Hi, Is there any better (shorter) way to negate a boolean list than: negated_boolean_list = [not elem for elem in boolean_list] ? I tried: map(not, boolean_list) but it seems that not is not a function. Thanks in advance, David -- http://mail.python.org/mailman/listinfo/python-list