Working in Python 3.8.
I prefer to have one return per function as it makes debugging easier.
Current code which I can live with:
if foo:
return redirect(url_for('what.what'))
else:
return render_template('who.who', form=my_form)
Desired code though:
if foo:
ret_func = redirect
ref_func_args = url_for("what.what")
else:
ret_func = render_template
ret_func_args = ('who.html', form=my_form) # syntax help needed here
return ret_func(ret_func_args) # and probably some syntax help here also
Python understandably doesn't like the ret_func_args = ('who.html', form=my_form)
and in particular form=my_form
.
render_template is expecting a keyword argument named 'form'.
What is the proper syntax for ret_func_args = ('who.html', form=my_form)
and perhaps the ret_func(ret_func_args)
line? The ret_func(ret_func_args)
does work if foo is true but can not figure out how to pass named parameters when foo is false in this case.