1 | initial version |
Indeed, this is missing from the documentation, and I found it confusing. With some fiddling, I learned that @parallel
will pass tuples as arguments:
@parallel
def func(n,color='red'):
sleep(2)
return [n^2,color]
L=[2,(4,'blue'),5,(6,'green'),7]
r = func(L)
returns
func(2) = [4, 'red']
func(4) = [16, 'blue']
func(5) = [25, 'red']
func(6) = [36, 'green']
func(7) = [49, 'red']
2 | No.2 Revision |
Indeed, this is missing from the documentation, and I found it confusing. With some fiddling, I learned that @parallel
will pass tuples as arguments:
@parallel
def func(n,color='red'):
sleep(2)
return [n^2,color]
L=[2,(4,'blue'),5,(6,'green'),7]
r = func(L)
returnsThe output is as expected:
for s in r:
print "func(%s) = %s"%(s[0][0][0],s[1])
func(2) = [4, 'red']
func(4) = [16, 'blue']
func(5) = [25, 'red']
func(6) = [36, 'green']
func(7) = [49, 'red']
3 | finally getting the output right |
Indeed, this is missing from the documentation, and I found it confusing. With some fiddling, I learned that @parallel
will pass tuples as arguments:
@parallel
def func(n,color='red'):
sleep(2)
return [n^2,color]
L=[2,(4,'blue'),5,(6,'green'),7]
r = func(L)
The output is as expected:
for s in r:
print "func(%s) = %s"%(s[0][0][0],s[1])
func(2) func((2,)) = [4, 'red']
func(4) func((4, 'blue')) = [16, 'blue']
func(5) func((5,)) = [25, 'red']
func(6) func((6, 'green')) = [36, 'green']
func(7) func((7,)) = [49, 'red']
4 | No.4 Revision |
Indeed, this is missing from the documentation, and I found it confusing. With some fiddling, I learned that @parallel
will pass tuples as arguments:
@parallel
def func(n,color='red'):
sleep(2)
return [n^2,color]
L=[2,(4,'blue'),5,(6,'green'),7]
r = func(L)
The output is as expected:
for s in r:
print "func(%s) = %s"%(s[0][0][0],s[1])
func((2,)) = [4, 'red']
func((4, 'blue')) = [16, 'blue']
func((5,)) = [25, 'red']
func((6, 'green')) = [36, 'green']
func((7,)) = [49, 'red']
UPDATE: Ok, I guess I have time to at least create the ticket ;) This is now ticket 11462!