次のようなコードがあります。
if(func_cliche_start(line)):
a=func_cliche_start(line)
#... do stuff with 'a' and line here
elif(func_test_start(line)):
a=func_test_start(line)
#... do stuff with a and line here
elif(func_macro_start(line)):
a=func_macro_start(line)
#... do stuff with a and line here
...
各 func_blah_start 関数は、(入力行に基づいて) None または文字列を返します。func_blah_start の冗長な呼び出しは無駄に思えるので好きではありません (func_blah_start は「純粋」であるため、副作用はないと想定できます)。この種のより良いイディオムはありますか、またはそれを行うためのより良い方法はありますか?
おそらく私は間違っています (私の C は錆びています) が、C でこれを行うことができると思いました:
int a;
if(a=myfunc(input)){ /*do something with a and input here*/ }
pythonに相当するものはありますか?