From ea24fc5026cc85ba363c9a6496789a018498ece4 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 17 Aug 2013 20:10:20 +0200 Subject: Small performance & clarity improvement --- ponysay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ponysay.py b/ponysay.py index f5f0f66..adb92c0 100644 --- a/ponysay.py +++ b/ponysay.py @@ -73,5 +73,6 @@ def render_pony(name, text, balloonstyle, width=80, center=False, centertext=Fal ponywidth = max([ len(re.sub(r'\x1B\[[0-9;]+m|\$.*\$', '', line)) for line in pony ]) indent = ' '*int((width-ponywidth)/2) wre = re.compile('((\x1B\[[0-9;]+m)*.){0,%s}' % width) - return ''.join([ indent+wre.search(line).group()+'\n' for line in pony ]) + reset = '\n' + return indent+(reset+indent).join([ wre.search(line).group() for line in pony ])+reset -- cgit