Do you mean something like this?
a = 1
b = 2
c = 3
assert b > a and c > b and a > c, 'Error: a is not greater than c'
Output:
Traceback (most recent call last):
File "main.py", line 6, in <module>
assert b > a and c > b and a > c, 'Error: a is not greater than c'
AssertionError: Error: a is not greater than c
something like this:- check c only when b > a is true and check a > c only both are true. And after assertion executes multiple statements like:- log the info and print the info etc..
You can use several assert statements one after another, like you'ld write several if statements under each other, except you've to take into account that your asserts can raise an exception, which you need to take care of. This way you can simply control the execution flow, and print/log whatever you need... For example something like this:
def make_comperations(a, b, c = None): # note c is optional
assert c is not None, 'Error: c is None'
assert b > a, 'Error: a is not greater than b'
assert c > a, 'Error: c is not greater than a'
try:
make_comperations(1, 2, 3) # ok
make_comperations(1, 2) # error
make_comperations(1, 2, 0) # error, but won't be executed since the line above will throw an exception
print("All good!")
except AssertionError as err:
if str(err) == 'Error: c is None':
print("Log: c is not given!")
if str(err) == 'Error: a is not greater than b':
print("Log: b > a error!")
elif str(err) == 'Error: c is not greater than a':
print("Log: c > a error!")
Output:
Log: c is not given!
assertis only for basic sanity checking and debug purposes. It should not form an integral part of your business logic!if..elseor similar tools.