如何将args和kwargs重新发送给其他函数? [英] howto resend args and kwargs to other func?
问题描述
我需要这样的东西:
def func1(* args,** kwargs):
if some_cond:
返回func2(* args,** kwargs)
else:
返回func3(some_other_args,** kwargs)
提前谢谢你,D.
I need something like this:
def func1(*args, **kwargs):
if some_cond:
return func2(*args, **kwargs)
else:
return func3(some_other_args, **kwargs)
Thank you in advance, D.
推荐答案
dmitrey< op ***** @ ukr.netwrote:
dmitrey <op*****@ukr.netwrote:
我需要这样的东西:
def func1(* args,** kwargs):
if some_cond:
返回func2(* args,** kwargs)
else:
返回func3(some_other_args,** kwargs)
提前谢谢你,D。
I need something like this:
def func1(*args, **kwargs):
if some_cond:
return func2(*args, **kwargs)
else:
return func3(some_other_args, **kwargs)
Thank you in advance, D.
你需要这样的东西,所以写点像那个。
您打算提问吗?
You ''need something like this'', so write something like that.
Did you intend to ask a question?
7月1日中午12点,Duncan Booth< duncan.bo。 .. @ invalid.invalidwrote:
On Jul 1, 12:00 pm, Duncan Booth <duncan.bo...@invalid.invalidwrote:
你需要一些东西这个'',所以写出类似的东西。
你打算提问吗?
You ''need something like this'', so write something like that.
Did you intend to ask a question?
我很乐意写一个,但是这个例子不起作用,我
不知道任何简单的方法(无论如何)让它正常工作。
D.
I would gladly write the one, but the example doesn''t work, and I
don''t know any easy way (moreover any way) to make it work correctly.
D.
dmitrey< op ***** @ ukr.netwrote:
dmitrey <op*****@ukr.netwrote:
7月1日中午12点,Duncan Booth< duncan.bo ... @ invalid.invalidwrote:
On Jul 1, 12:00 pm, Duncan Booth <duncan.bo...@invalid.invalidwrote:
>你需要这样的东西,所以写点类似的东西。
你打算提问吗?
>You ''need something like this'', so write something like that.
Did you intend to ask a question?
我很乐意写一个,但这个例子不起作用,而且我不知道b $ b不知道任何简单的方法(无论如何)让它正常工作。
D.
I would gladly write the one, but the example doesn''t work, and I
don''t know any easy way (moreover any way) to make it work correctly.
D.
这个例子不起作用,因为它不是真实的例子(什么是
some_cond或some_other_args?)。一个相同的例子运行但是没有
给出你期望的输出会更有意义。
如果你真的写了一个可运行的例子,并解释那你怎么样?b $ b认为不行,那么我可能会告诉你如何解决这个问题,而不必花费我的心灵感应。
我唯一能看到你的假设示例的错误就是你可能会在某些事情之前打算a * b $ b,但是因为它不是一个真实的例子
这可能只是一个错字而不是你的问题。
The example doesn''t work because it isn''t a real example (what are
some_cond or some_other_args?). An identical example which runs but doesn''t
give the output you expect would be more meaningful.
If you actually wrote a runnable example, and explained what about it you
think doesn''t work, then I could probably tell you how to fix it without
having to engage my telepathy.
The only thing I can see wrong with your made-up example is that you may
have intended a * before some_other_args, but since it isn''t a real example
it is probably just a typo rather than being your question.
这篇关于如何将args和kwargs重新发送给其他函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!