473,386 Members | 1,815 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,386 software developers and data experts.

boolian logic

HI all, I'm a bit stuck with how to work out boolian logic.

I'd like to say if A is not equal to B, C or D:
do something.

I've tried

if not var == A or B or C:
and various permutations but can't seem to get my head around it. I'm
pretty sure I need to know what is calulated first i.e the not or the
'OR/AND's

thanks, Marc.
Jun 27 '08 #1
6 1185
if a != b and a != c and a != d:
doStuff()
else:
doOtherStuff()

Cheers,

Drea

>HI all, I'm a bit stuck with how to work out boolian logic.

I'd like to say if A is not equal to B, C or D:
do something.

I've tried

if not var == A or B or C:
and various permutations but can't seem to get my head around it. I'm
pretty sure I need to know what is calulated first i.e the not or the
'OR/AND's

thanks, Marc.
Jun 27 '08 #2
marc wyburn wrote:
HI all, I'm a bit stuck with how to work out boolian logic.

I'd like to say if A is not equal to B, C or D:
do something.

I've tried

if not var == A or B or C:
and various permutations but can't seem to get my head around it. I'm
pretty sure I need to know what is calulated first i.e the not or the
'OR/AND's

thanks, Marc.
You mean like a ternary operation?
>>True and 1 or 0
1
>>False and 1 or 0
0

This of course depends on the 'true' result also being true.. it fails
if it is false...

if that's not what you mean, then maybe this is what you want

if not var==A or not var==B or not var==C:
# do something
Jun 27 '08 #3
On 13 Jun, 10:34, Aidan <awe...@gmail.comwrote:
marc wyburn wrote:
HI all, I'm a bit stuck with how to work outboolianlogic.
I'd like to say if A is not equal to B, C or D:
* *do something.
I've tried
if not var == A or B or C:
and various permutations but can't seem to get my head around it. *I'm
pretty sure I need to know what is calulated first i.e the not or the
'OR/AND's
thanks, Marc.

You mean like a ternary operation?

*>>True and 1 or 0
1
*>>False and 1 or 0
0

This of course depends on the 'true' result also being true.. it fails
if it is false...

if that's not what you mean, then maybe this is what you want

if not var==A or not var==B or not var==C:
* * *# do something
the not var==A or not var==B or not var==C was what I was after.I
was being too literal with my script and trying not (A or B or C)
which doesn't work.

Thanks for the help.
Jun 27 '08 #4
marc wyburn wrote:
HI all, I'm a bit stuck with how to work out boolian logic.

I'd like to say if A is not equal to B, C or D:
do something.

I've tried

if not var == A or B or C:
and various permutations but can't seem to get my head around it. I'm
pretty sure I need to know what is calulated first i.e the not or the
'OR/AND's

thanks, Marc.
There's a number of ways of coding it. How about,

if not var in [A, B, C]:
#do stuff
Duncan
Jun 27 '08 #5
marc wyburn schreef:
HI all, I'm a bit stuck with how to work out boolian logic.

I'd like to say if A is not equal to B, C or D:
do something.

I've tried

if not var == A or B or C:
and various permutations but can't seem to get my head around it. I'm
pretty sure I need to know what is calulated first i.e the not or the
'OR/AND's
if var not in (A, B, C):
do_something()

--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
-- Isaac Asimov

Roel Schroeven
Jun 27 '08 #6
>
if var not in (A, B, C):
do_something()
And this is why I love python.
Jun 27 '08 #7

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

Similar topics

0
by: Al Fatykhov | last post by:
Using MABLE logic engine with existing .NET applications. MABLE web services provide an interface to MABLE business objects and logic. Let us review some technical details of the MABLE web...
0
by: Wim Vanhoof | last post by:
----------------------------------------------------------- WLPE' 06 - CALL FOR PAPERS Workshop on Logic-based Methods in Programming Environments (satellite workshop of ICLP’06) August...
9
by: csharpula csharp | last post by:
Hello, I want to lock a boolian variable but it's not possible in c#,is there a way to convert it to something that is possible to lock? Thank you! *** Sent via Developersdex...
16
by: MS newsgroup | last post by:
I don't have clear reasons why we need business logic layer and data logic layer instead of having only data logic layer. Are there any good reasons for that?
0
by: fiona | last post by:
FOR IMMEDIATE RELEASE Catalyst release low cost logic processing tool 87% of defects in software are errors in logic Yucca Valley, CA, September 2006 - Catalyst Development Corporation,...
14
by: rabbitrun | last post by:
Hi Everyone, I work for a financial company. I am planning to give a presentation to rest of the development team (15 people) here on moving server side logic to client-side javascript for an...
2
by: Chris Zopers | last post by:
Hello, I would like to know what's the best way to implement a business logic layer between my user interface and my database. I would say I'd make a dll-project for the business logic layer...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
15
by: bruno.desthuilliers | last post by:
On 27 juin, 18:09, "John Salerno" <johnj...@NOSPAMgmail.comwrote: For which definitions of "content" and "logic" ??? The point of mvc is to keep domain logic separated from presentation logic,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.