开发者

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

开发者 https://www.devze.com 2023-02-23 04:59 出处:网络
I have the following code now if (verbose): with hide(\'running\', \'stdout\', \'stderr\'): line 1 line 2

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

精彩评论

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