Skip to content

Instantly share code, notes, and snippets.

@hahastudio
Last active August 29, 2015 14:06
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 hahastudio/e1319c1c837d4f9ea35b to your computer and use it in GitHub Desktop.
Save hahastudio/e1319c1c837d4f9ea35b to your computer and use it in GitHub Desktop.
Test functools.partial for https://www.v2ex.com/t/134401
from functools import partial
def func(a, b, c):
print a, b, c
func_fix_b = partial(func, b="what you want,")
func_fix_b(a="Here is", c="take it")
# Here is what you want, take it
func_fix_b("Here is", c="take it")
# Here is what you want, take it
# This is from Python Doc
# https://docs.python.org/2/library/functools.html
basetwo = partial(int, base=2)
basetwo.__doc__ = 'Convert base 2 string to an int.'
basetwo('10010')
# 18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment