Better way to negate a boolean list?
paddy3118 at googlemail.com
Sun Feb 10 18:31:02 CET 2008
On Feb 10, 1:41 pm, Steve Holden <st... at holdenweb.com> wrote:
> Paddy wrote:
> > On Feb 10, 7:46 am, David Trémouilles <david.t... at gmail.com> 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
> > Try [not x for x in boolean_list]
> This six-character shortening by renaming the comprehension's bound
> variable was a joke, right?
Of course not!
It's much worse - I completely missed the line beginning negated_....
first and second reading.
I am indeed getting older, although I had thought I was way off my
More information about the Python-list