1

私は今、次のコードを持っています

if (verbose):

   with hide('running', 'stdout', 'stderr'):
       line 1
       line 2
else:
    line 1
    line 2

line1 と line2 の繰り返しを避ける方法はありますか?

4

1 に答える 1

1
def dothisstuff():
   line 1
   line 2

if (verbose):
   with hide('running', 'stdout', 'stderr'):
       dothisstuff()
else:
    dothisstuff()

ただし、これは 2 行を 2 回繰り返すだけではやり過ぎかもしれません。しかし、2行以上だと思います:)

于 2011-04-08T12:26:53.347 に答える