Re: puzzled by name binding in local function

2013-02-07 Thread Ulrich Eckhardt
Heureka! Am 06.02.2013 15:37, schrieb Dave Angel: > def myfunc2(i): def myfunc2b(): print ("myfunc2 is using", i) return myfunc2b Earlier you wrote: There is only one instance of i, so it's not clear what you expect. Since it's not an argument to test(), it has to be found

Re: puzzled by name binding in local function

2013-02-06 Thread Dave Angel
On 02/06/2013 05:19 AM, Ulrich Eckhardt wrote: Dave and Terry, Thanks you both for your explanations! I really appreciate the time you took. Am 05.02.2013 19:07, schrieb Dave Angel: The main place where I see this type of problem is in a gui, where you're defining a callback to be used by

Re: puzzled by name binding in local function

2013-02-06 Thread Ulrich Eckhardt
Dave and Terry, Thanks you both for your explanations! I really appreciate the time you took. Am 05.02.2013 19:07, schrieb Dave Angel: If you need to have separate function objects that already know a value for i, you need to somehow bind the value into the function object. One way to do it,

Re: puzzled by name binding in local function

2013-02-05 Thread Terry Reedy
Code examples are Python 3 On 2/5/2013 10:18 AM, Ulrich Eckhardt wrote: Below you will find example code distilled from a set of unit tests, usable with Python 2 or 3. I'm using a loop over a list of parameters to generate tests with different permutations of parameters. Instead of calling util

Re: puzzled by name binding in local function

2013-02-05 Thread Dave Angel
On 02/05/2013 10:18 AM, Ulrich Eckhardt wrote: Hello Pythonistas! Below you will find example code distilled from a set of unit tests, usable with Python 2 or 3. I'm using a loop over a list of parameters to generate tests with different permutations of parameters. Instead of calling util() with

puzzled by name binding in local function

2013-02-05 Thread Ulrich Eckhardt
Hello Pythonistas! Below you will find example code distilled from a set of unit tests, usable with Python 2 or 3. I'm using a loop over a list of parameters to generate tests with different permutations of parameters. Instead of calling util() with values 0-4 as I would expect, each call uses