I have multiple conditions, like this:
if condition:
flag1 = True
flag2 = testfunc()
flag3 = bool(variable)
if not flag1 and not flag2 and not flag3:
do0
elif flag1 and flag2:
do1
elif flag2 and flag3:
do2
Can I change it to something like this:
flags = 0
if condition:
flags += 1
if testfunc():
flags += 2
if bool(variable):
flags += 4
if flags == 0:
do0
elif flags == 3:
do1
elif flags == 6:
do2
As you can understand there can be values 0, 1, 2, 4, 8, 16, 32, ... for conditions. Is it possible to do something like this in Python? Thanks!
UPDATE. This is something like conditions in re and PyQt4 modules (where you can set something like re.UNICODE | re.DOTALL).
Example from re module:
DOTALL = 16
I = 2
IGNORECASE = 2
L = 4
LOCALE = 4
M = 8
MULTILINE = 8
S = 16
U = 32
UNICODE = 32
VERBOSE = 64
X = 64