From fa6e46cb0109ce95df9317269941e37ed4b1d3af Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Thu, 4 Jul 2019 13:46:14 +0200 Subject: [PATCH] star kwargs and kwargs for say function --- adventurelib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adventurelib.py b/adventurelib.py index 0aa0907..73b47f6 100644 --- a/adventurelib.py +++ b/adventurelib.py @@ -287,7 +287,7 @@ def take_random(self): return obj -def _register(command, func, context=None, kwargs={}): +def _register(command, func, context=None, **kwargs): """Register func as a handler for the given command.""" pattern = Pattern(command, context) sig = inspect.signature(func) @@ -536,7 +536,7 @@ def start(help=True): _handle_command(cmd) -def say(msg): +def say(msg, **kwargs): """Print a message. Unlike print(), this deals with de-denting and wrapping of text to fit @@ -551,7 +551,7 @@ def say(msg): width = get_terminal_size()[0] paragraphs = re.split(r'\n(?:[ \t]*\n)', msg) formatted = (textwrap.fill(p.strip(), width=width) for p in paragraphs) - print('\n\n'.join(formatted)) + print('\n\n'.join(formatted), **kwargs) commands = [