【发布时间】:2014-11-21 17:04:12
【问题描述】:
重写以更清楚用例并更好地回答 Anentropic 的问题。
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)
use_all 是处理这些步骤的主要“执行者”(确切地说是pxssh 用于安装)。它不应被装饰带有启动/停止 cmets,因为可能会从一个过程中多次调用(例如 step_many 这是重新启动 - 没有 wait_complete 的原因),但单步应该是。
由于用例是特定的,我可能会看到将*args 处理为包含元组的_single 命名变量的解决方案,例如
def use_all (step_todo, wait_complete=True, args_list=()):
这是正确的(和推荐的)解决方案吗?
这在某种程度上与问题 python function *args and **kwargs with other specified keyword arguments 或 Using default arguments before positional arguments 相关联。是否可以不解析kwargs和keep Python R2.7?
谢谢 一月
【问题讨论】:
标签: python python-2.7 args