<br><br><div class="gmail_quote">On Fri, Jan 30, 2009 at 10:36 AM, Noam Aigerman <span dir="ltr"><noama@answers.com></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">








<div link="blue" vlink="purple" lang="EN-US">

<div>

<p>Hi,</p>

<p>I want to create an array of functions, each doing the same
thing with a change to the parameters it uses… something like:</p></div></div></blockquote><div>I'm not really sure what you're trying to accomplish so there may be a better answer, but in this case if you just pass the name as a keyword arg to the function you're defining it'd work. That way you're saving the current state of 'name' when defining the function, instead of having it look it up at runtime.<br><br>I.e.<br><br>arr = ['john', 'terry', 'graham']<br>funcs = []<br>for name in arr:<br>    def func(name=name):<br>        print 'Hi', name<br>    funcs.append(func)<br><br>for f in funcs:<br>    f()<br><br>--Stephen<br></div></div><br>