Ask Your Question

passing multiple variables and @parallel

asked 2011-01-25 21:24:27 +0200

mhfrey gravatar image

updated 2011-01-25 21:29:49 +0200

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 21:34:22 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-06-09 06:39:51 +0200

niles gravatar image

updated 2011-06-10 14:37:11 +0200

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 17:03:50 +0200 )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 17:07:33 +0200 )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 21:24:27 +0200

Seen: 503 times

Last updated: Jun 10 '11