mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #7830: Flatten nested functools.partial.
This commit is contained in:
parent
e2e178e081
commit
e49af34151
4 changed files with 68 additions and 7 deletions
|
@ -241,6 +241,14 @@ def partial(func, *args, **keywords):
|
|||
"""New function with partial application of the given arguments
|
||||
and keywords.
|
||||
"""
|
||||
if hasattr(func, 'func'):
|
||||
args = func.args + args
|
||||
tmpkw = func.keywords.copy()
|
||||
tmpkw.update(keywords)
|
||||
keywords = tmpkw
|
||||
del tmpkw
|
||||
func = func.func
|
||||
|
||||
def newfunc(*fargs, **fkeywords):
|
||||
newkeywords = keywords.copy()
|
||||
newkeywords.update(fkeywords)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue