Trying to validate function parameter combinations. Such that (), (project), (project,field) and (project,field,well) are valid and every other combination (e.g. (field)) is not. If available, arguments will be strings otherwise defaults are None or empty string "". Currently doing poor man's bit mask check...
def make_thing(project=None, field=None, well=None):
# check for valid p-f-w combinations
check = (8 if project else 0) + (4 if field else 0) + (1 if well else 0)
if check not in (0, 8, 8 + 4, 8 + 4 + 1):
return None
# continue to do work
Question: What is a proper Pythonic way to do this?
Thank you!