473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Better way to negate a boolean list?

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
Feb 10 '08 #1
3 7792
On Feb 10, 7:46 am, David Trémouilles <david.t...@gmail.comwrote:
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]

- Paddy.
Feb 10 '08 #2
Paddy wrote:
On Feb 10, 7:46 am, David Trémouilles <david.t...@gmail.comwrote:
>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?

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Feb 10 '08 #3
On Feb 10, 1:41 pm, Steve Holden <st...@holdenweb.comwrote:
Paddy wrote:
On Feb 10, 7:46 am, David Trémouilles <david.t...@gmail.comwrote:
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?
No,
Of course not!
It's much worse - I completely missed the line beginning negated_....
on
first and second reading.
I am indeed getting older, although I had thought I was way off my
dotage.

- Paddy.
Feb 10 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: ham-z | last post by:
I have written the following Win app in VB.NET 2003 . The class is simply picture boxes that behave in a random order after they have been instantiated and added to a form. When I create 15 or more...
16
by: Steve Peterson | last post by:
Hi I'm curious - which is the better ".NET" method to use if needing to know if an object is Nothing? 1: If IsNothing(myobject) ... or 2. If myobject Is Nothing ...
6
by: wij | last post by:
Hi: What is the protable way to negate an arithmetic integer? template<typename T> T negate(T t) { return -t; // <-- problem } On my Intel machines, taking negation like the above is...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
1
by: shilpi.rustagi | last post by:
hi again.. i have a basic regular expression problem. we can negate a single charecter like this . but i want to negate a whole group e.g (<\tag>) hw can i do that can anyone help on it. ...
1
by: Mike | last post by:
I' d like to list all inactive clients. Inactive client is a client who hasn't had invoice for 2 months. I use INNER JOIN to join invoice view (vwDok4FSFZGrid) and clients addresses table...
8
by: Summercool | last post by:
somebody who is a regular expression guru... how do you negate a word and grep for all words that is tire but not snow tire or
3
by: jaxx0rr | last post by:
This will probably look like a really stupid piece of code.. but it works My question is, how can I write the last part so there is only one extended Canvas class that can recieve a parameter for...
7
by: raylopez99 | last post by:
I find that I am using bool variables a lot when I code in Forms. I know how to overload event handlers, and that's great for offloading code from the 'base' event handler and/or creating helper...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.