擅长:python、mysql、java
<p>这种情况很普遍,我很惊讶你还没有像其他人那样做。在</p>
<p>重构函数以将其分解为更小的函数。在</p>
<p>函数是对象,可以作为参数传递给其他函数。在</p>
<pre><code>def step1():
whatever
def step2():
whatever
def step2_alternative():
whatever
def original( args ):
step1()
step2()
def revised( args, step2_choice ):
step1()
step2_choice()
</code></pre>
<p>现在你可以这样做了。在</p>
^{pr2}$
<p>它只是用函数对象进行OO编程。在</p>