Last active
August 29, 2015 14:06
-
-
Save hahastudio/e1319c1c837d4f9ea35b to your computer and use it in GitHub Desktop.
Test functools.partial for https://www.v2ex.com/t/134401
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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