开发者

Add with statement in non verbose mode in fabric (Python)

I have the following code now

if (verbose):

   with hide('running', 'stdout', 'stderr'):
       line 1
       line 2
else:
    li开发者_如何学运维ne 1
    line 2

Is there any way to avoid the repetition of line1 and line 2?


def dothisstuff():
   line 1
   line 2

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

Though this might be overkill for only 2 repetitions of 2 lines. But I assume it are more then 2 lines :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜