If I have a function or method that takes a parameter that can be only one of two values, is it more pythonic to explicitly specify both known conditions and abstract ones in the else clause? For instance:
Option 1:
def main(group_name):
if group_name == 'request':
do_something()
else:
do_something_else()
Or option 2:
def main(group_name):
if group_name == 'request':
do_something()
elif group_name == 'response':
do_something_else()
else:
raise Exception
source
share