B
Barney Frank
I am writing my first application using Python, and there are a
couple points in code at which I need a fairly complex if-else block.
I've discovered that you can nest compound conditions in parentheses, but
I haven't found a way to break a really complex if condition up into
multiple lines.
For example, take this little fake snippet:
#############
a = 1
b = 2
c = 3
d = 4
if a == 1 and b < 4 and (c == 2 or d == 4):
print "Conditions met!"
#############
... if the "if" condition gets too long and unweildy for a single
line, is there any way to format it along these lines?:
#############
a = 1
b = 2
c = 3
d = 4
if a == 1
and b < 4
and (c == 2 or d == 4):
print "Conditions met!"
#############
couple points in code at which I need a fairly complex if-else block.
I've discovered that you can nest compound conditions in parentheses, but
I haven't found a way to break a really complex if condition up into
multiple lines.
For example, take this little fake snippet:
#############
a = 1
b = 2
c = 3
d = 4
if a == 1 and b < 4 and (c == 2 or d == 4):
print "Conditions met!"
#############
... if the "if" condition gets too long and unweildy for a single
line, is there any way to format it along these lines?:
#############
a = 1
b = 2
c = 3
d = 4
if a == 1
and b < 4
and (c == 2 or d == 4):
print "Conditions met!"
#############