-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiWrap.py~
executable file
·48 lines (38 loc) · 1.16 KB
/
MultiWrap.py~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import mapfn
import resultfn
# def FunWrap(thisfun):
# def FunOut(args):
# return thisfun(*args)
# return FunOut
def MakeWrap(thisfun,constarg):
def NewFun(iterarg):
return thisfun(*(constarg+(iterarg,)))
return NewFun
def MakeWrapD2(thisfun,constarg):
def NewFun(iterarg):
return thisfun(*(constarg+(iterarg[0],iterarg[1])))
return NewFun
def makeContextFunctions(*fns):
for f in fns:
newName = f.__name__
def mapper(x):
return f(x)
mapper.__name__ = newName
mapper.__module__ = 'mapfn'
setattr(mapfn, newName, mapper)
f.mapper = mapper
def resultFn(x):
print "%s returned result %s" % (f.__name__, x)
resultFn.__name__ = newName
resultFn.__module__ = resultfn
setattr(resultfn, newName, resultFn)
f.resultFn = resultFn
# def MakeCWrap(thisfun,constargs):
# funout = MakeWrap(thisfun,constargs)
# makeContextFunctions(funout)
# return funout
# def MakeCWrapD2(thisfun,constargs):
# funout = MakeWrapD2(thisfun,constargs)
# makeContextFunctions(funout)
# return funout