Rewritten to make more clear the use-case and answer better Anentropic's question.
def use_all (step_todo, wait_complete=True, *args):
execute_step1 (step-todo)
handle_args (*args)
if not wait_complete:
do_somehing ()
return
execute_stepN ()
@decorate
def use_from (step_todo, *args):
use_all (step_todo, args)
@decorate
def use_many ():
use_all (step_todo1, wait_complete=False)
use_all (step_todo2, args2)
use_all (step_todo3)
The use_all
is the main "executive" to process the steps (exactlypxssh
for installation). It shall not be decorated with start/stop comments as may be called several times from a procedure (e.g. step_many
which is reboot - reason for no wait_complete
), but single step shall be.
As the use-case is specific, I may see solution to handle the *args
as _single named variable containing tuple, e.g.
def use_all (step_todo, wait_complete=True, args_list=()):
Is this correct (and recommended) solution?
This is somehow linked to questions python function *args and **kwargs with other specified keyword arguments or Using default arguments before positional arguments . Is it possible not to parse kwargs
and keep Python R2.7?
Thanks Jan
You need to do this:
...otherwise you are calling
use_all
with a single arg containing a list of values, instead of calling it with the multiple argsalso, don't put a space between your function and the parentheses, it's bad style :)
to get around the problem of
wait_complete
taking value of your first arg you need to pass it explicitly, eg: