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 :)
精彩评论