Skip to content

Instantly share code, notes, and snippets.

@dschep
Created October 1, 2020 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dschep/87d25830e8782075e978f404af3e8432 to your computer and use it in GitHub Desktop.
Save dschep/87d25830e8782075e978f404af3e8432 to your computer and use it in GitHub Desktop.
A decorator version of functools.partial
def partially(*args, **kwargs):
"""
A decorator version of functools.partial
eg, this:
def _foo(x, y):
pass
foo = partial(_foo, 1)
is the same as:
@partially(1)
def foo(x, y):
pass
"""
return lambda func: partial(func, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment