From e49af341518ba22186fc523ec23ccff462ab439e Mon Sep 17 00:00:00 2001 From: Alexander Belopolsky Date: Sun, 1 Mar 2015 15:08:17 -0500 Subject: Issue #7830: Flatten nested functools.partial. --- Lib/functools.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib/functools.py') diff --git a/Lib/functools.py b/Lib/functools.py index 20a26f9a2c..91e9685b98 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -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) -- cgit v1.2.1