def logReSubn(subnExpr, preComment, postComment, errorMsg='') -> str:
"""
Takes in the result of a re.subn call, subnExpr, and
logs preComment to stdout, then logs postComment and specifies the
number of subs.
Prints errorMsg in case of 0 subs.
Returns the string from subnExpr with replacements made.
"""
out = subnExpr[0]
subs = subnExpr[1]
print(preComment)
print(str(subs) + ' ' + postComment)
if (subs == 0 and errorMsg != ''):
print(errorMsg)
return out
评论列表
文章目录