Better way to negate a boolean list?
gherron at islandtraining.com
Sun Feb 10 09:23:44 CET 2008
David Trémouilles 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,
But import module operator, and find operator.not_ which is a function
and does what you want.
More information about the Python-list