Is there an accepted convention on whether it is better to return diagnostic information with the results as a tuple or pass it as parameter?
<code>def fn(a):
...
return res, diag_info
</code>
<code>def fn(a):
...
return res, diag_info
</code>
def fn(a):
...
return res, diag_info
or:
<code>def fn(a, diag_info=None):
...
if diag_info is not None:
diag_info |= { 'elapsed': elapsed, 'cache': cache }
return res
</code>
<code>def fn(a, diag_info=None):
...
if diag_info is not None:
diag_info |= { 'elapsed': elapsed, 'cache': cache }
return res
</code>
def fn(a, diag_info=None):
...
if diag_info is not None:
diag_info |= { 'elapsed': elapsed, 'cache': cache }
return res
I find that the second pattern seems cleaner to me as you are not obligated to receive the results using two variables to tie the tuple values, but I was wondering if there is an accepted convention around that.
0