2đź‘Ť
âś…
Sometimes, a function’s gotta take a lot of arguments. There is nothing wrong with this, per se. Here are some tips on making it a little cleaner:
Don’t name the bool, “bool”:
def create_rule(profile, lifestyles, is_something, title, input, output):
rule = Rule.objects.create(
....
bool=is_something,
)
Unpack your tuples for clarity:
input_val, input_command = input
input_cls = models.get(model=input_val).model_class()
input_cls.objects.create(*input_command, rule=rule)
output_val, output_command, output_third_arg = output
....
👤rxmnnxfpvg
Source:stackexchange.com