Это должно работать, если хотя бы один вход является списком:
def refine_arguments(a, b, c, a_changes, b_changes, c_changes):
# get the max len of one of the list (should be all the same listlenght)
maxlen = max(len(i) for i in (a, b, c) if isinstance(i, list))
# if the X_changes is true use the float value times maxlen, else leave as is
a = [a] * maxlen if not a_changes and not isinstance(a, list) else a
b = [b] * maxlen if not b_changes and not isinstance(b, list) else b
c = [c] * maxlen if not c_changes and not isinstance(c, list) else c
return a, b, c
a_changes = True
b_changes = True
c_changes = False
a = [0.21, 0.25, 0.29]
b = [0.13, 0.13, 0.13]
c = 0.78
print(*refine_arguments(a, b, c, a_changes, b_changes, c_changes))
a_changes = True
b_changes = False
c_changes = False
a = [0.21, 0.25, 0.29]
b = 0.78
c = 0.78
print(*refine_arguments(a, b, c, a_changes, b_changes, c_changes))
Выход:
[0.21, 0.25, 0.29] [0.13, 0.13, 0.13] [0.78, 0.78, 0.78]
[0.21, 0.25, 0.29] [0.78, 0.78, 0.78] [0.78, 0.78, 0.78]
Используйте a,b,c = refine_arguments(a, b, c, a_changes, b_changes, c_changes)
для работы с a, b, c позже по.