[Scipy-svn] r3131 - trunk/Lib/sandbox/pyem
scipy-svn@scip...
scipy-svn@scip...
Mon Jul 2 03:03:52 CDT 2007
Author: cdavid
Date: 2007-07-02 03:03:38 -0500 (Mon, 02 Jul 2007)
New Revision: 3131
Modified:
trunk/Lib/sandbox/pyem/misc.py
Log:
Add curry class to misc tools
Modified: trunk/Lib/sandbox/pyem/misc.py
===================================================================
--- trunk/Lib/sandbox/pyem/misc.py 2007-07-02 06:03:36 UTC (rev 3130)
+++ trunk/Lib/sandbox/pyem/misc.py 2007-07-02 08:03:38 UTC (rev 3131)
@@ -1,4 +1,4 @@
-# Last Change: Thu Jun 28 06:00 PM 2007 J
+# Last Change: Mon Jul 02 04:00 PM 2007 J
#========================================================
# Constants used throughout the module (def args, etc...)
@@ -27,3 +27,18 @@
## # Default min delta for regularization
## _MIN_DBL_DELTA = 1e-5
##
+
+class curry:
+ def __init__(self, fun, *args, **kwargs):
+ self.fun = fun
+ self.pending = args[:]
+ self.kwargs = kwargs.copy()
+
+ def __call__(self, *args, **kwargs):
+ if kwargs and self.kwargs:
+ kw = self.kwargs.copy()
+ kw.update(kwargs)
+ else:
+ kw = kwargs or self.kwargs
+
+ return self.fun(*(self.pending + args), **kw)
More information about the Scipy-svn
mailing list