Better way to negate a boolean list?
steve at holdenweb.com
Sun Feb 10 14:41:34 CET 2008
> On Feb 10, 7:46 am, David Trémouilles <david.t... at gmail.com> wrote:
>> 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,
> Try [not x for x in boolean_list]
This six-character shortening by renaming the comprehension's bound
variable was a joke, right?
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list