Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

star kwargs and kwargs for say function #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions adventurelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 = [
Expand Down