Ask Your Question

passing multiple variables and @parallel

asked 2011-01-25 14:24:27 -0500

mhfrey gravatar image

updated 2011-01-25 14:29:49 -0500

The @parallel examples all show f(x).
Is it possible to use f(x,y,z) where x is the list to be iterated over?
Are there any examples of @parallel that do not use list?

edit retag flag offensive close merge delete


Can you post a sample code to explain what you are trying to do? The most natural solution would be to pass an array.

Shashank gravatar imageShashank ( 2011-01-25 14:34:22 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2011-06-08 23:39:51 -0500

niles gravatar image

updated 2011-06-10 07:37:11 -0500

Indeed, this is missing from the documentation, and I found it confusing. With some fiddling, I learned that @parallel will pass tuples as arguments:

def func(n,color='red'):
    return [n^2,color]

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!

edit flag offensive delete link more


So open a ticket for this doc patch! :) You will become the new @parallel expert :)

kcrisman gravatar imagekcrisman ( 2011-06-09 10:03:50 -0500 )edit

ha! Yes I'd like to, but I don't quite have time for it right now -- maybe in a month or so . . .

niles gravatar imageniles ( 2011-06-09 10:07:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-01-25 14:24:27 -0500

Seen: 239 times

Last updated: Jun 10 '11