On Sat, 07 Apr 2012 14:15:09 -0700, KRB wrote:

> I would like to be able to pass a list of variables to a procedure, and
> have the output assigned to them.

Use a dictionary or an object.

If the variables are globals (i.e. attributes of the current module), you
can pass the result of globals() into the function, or have the function
return a dictionary which the caller merges into globals().

There isn't no way to do anything similar for local variables. The parser
has to "see" the name being used a local variable in order for it to
actually exist as a local variable.

> otherwise I have to do:
> x=somefunction(1)
> y=somefunction(2)
> z=somefunction(3)

Or you could do:

        x, y, z = [somefunction(i) for i in [1,2,3]]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to