OR in python?

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

OR in python?

Post by Fiasco » Tue Feb 23, 2010 12:58 am

Silly question (perl programmer here)

How do I do

if x == 1 or x == 2:
execute this

in python?

User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

Re: OR in python?

Post by Fiasco » Tue Feb 23, 2010 1:01 am

Figures it out 10 seconds later

if (x == 1) | (x==2):

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: OR in python?

Post by Bartman » Tue Feb 23, 2010 6:05 pm

You could have it written exactly as in the question

Code: Select all

if x == 1 or x == 2:
In your answer you actually do a bitwise combination of to boolean values.

Post Reply