Is it pythonic for a function to return multiple values? have a great explanation in this.
But in your case, it depends on your use-case. If you know how to handle returning data, then there is no problem in using this. Like:
def func():
if(condition_1):
return a,b
if(condition_2):
return (a, )
if(condition_3):
return c,d,e,f
if(condition_4):
return a,b
vals = func()
if len(vals) == 2:
# We are sure that we will get `a,b` in return
do something ...
elif len(vals) == 3:
...
In example above, function that will process vals
tuple knows how to handle returning data according to some criteria. It have 2 return
possibilities that returns the same data!
If you know exactly how to handle data, then it is ok to go with different number of returns. The key point in here is functions do a single job. If your have problems in recognizing the return values, then your function is doing more than one job or you must avoid using different number of arguments.