Skip to content

Instantly share code, notes, and snippets.

@sapamja
Created July 10, 2014 16:23
Show Gist options
  • Select an option

  • Save sapamja/21c7ef3c8f40d361cefc to your computer and use it in GitHub Desktop.

Select an option

Save sapamja/21c7ef3c8f40d361cefc to your computer and use it in GitHub Desktop.
Use case for partial function:
from functools import partial
def log_template(level, message):
print("{}: {}".format(level, message))
log_info = partial(log_template, "info")
log_warning = partial(log_template, "warning")
log_error = partial(log_template, "error")
>>> log_info("test test test 1 2 3")
info: test test test 1 2 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment