This topic created in 5012 days ago, the information mentioned may be changed or developed.
大家早上好,问题是这样的:
修改前是三个函数:
funA()
funB()
funC()
其中
def funC():
...#若干嵌套
if X:
cry_out
if Y:
do_sth
现在想要改成:funA、funB、funC一路跑下来,第一次遇到if X为True的时候不执行cry_out,而是倒回去把funA、funB、funC再跑一遍,再次遇到if X为True再cry_out,当然if X为False的行为不变。
我有很多笨办法比如设flag之类但自己感觉不好,所以想求教一下各位高手怎么改比较漂亮?
3 replies 1970-01-01 08:00:00 +08:00  | | 1 lilydjwg Aug 15, 2012 1 这样? rerun = False while True: funA() funB() if not funC(rerun): break
def funC(rerun): #... if X and not rerun: return True if X: cry_out |
 | | 2 lilydjwg Aug 15, 2012 ,忘记置位 rerun 了…… 另外,缩进没了怎么办? |
 | | 3 ThunderEX Aug 15, 2012 @ lilydjwg 我差不多也是这样想的,就是觉得既改动definition又改动reference不太雅观。还是谢谢~ |