Re: Help me dig my way out of nested scoping

2005-04-04 Thread Terry Reedy
"Brendan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >F -is- in fact an iterative optimizer that minimizes A on x (B is the > derivative of A). So yes, F will call A and B on mulitple 'x's. In > that case, it seems the mutable object trick is the way to go. Thanks. As long a

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Ron_Adam
On 3 Apr 2005 16:21:10 -0700, "Brendan" <[EMAIL PROTECTED]> wrote: >Thanks for the tips. Making FW a callable class (choice 5) seems to be >a good (if verbose) solution. I might just wrap my temporary values in >a list [lastX, lastA, lastB] and mutate them as Michael suggests. >Thanks to Michael

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Brendan
>James Stroud Apr 3, 3:18 pm: >I think you might want to look at "python generators". I've seen discussion of generators before, but haven't invested the time to understand them yet. This might be a good excuse. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Brendan
F -is- in fact an iterative optimizer that minimizes A on x (B is the derivative of A). So yes, F will call A and B on mulitple 'x's. In that case, it seems the mutable object trick is the way to go. Thanks. I didn't follow your last sentence. What about the Python Cookbook? -- http://mail.

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Brendan
Thanks for the tips. Making FW a callable class (choice 5) seems to be a good (if verbose) solution. I might just wrap my temporary values in a list [lastX, lastA, lastB] and mutate them as Michael suggests. Thanks to Michael especially for the explanation of the name-binding process that's at th

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Terry Reedy
"Brendan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a function, call it F(x), which asks for two > other functions as arguments, say A(x) and B(x). ... If I understand this and the rest, a third party library whose code you cannot modify (easily) has a function F wit

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Ron_Adam
On 3 Apr 2005 14:12:48 -0700, "Brendan" <[EMAIL PROTECTED]> wrote: >Hi everyone > >I'm new to Python, so forgive me if the solution to my question should >have been obvious. I have a function, call it F(x), which asks for two >other functions as arguments, say A(x) and B(x). A and B are most >ef

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Terry Hancock
On Sunday 03 April 2005 04:12 pm, Brendan wrote: > from ThirdPartyLibrary import F > from MyOtherModule import AB > > def FW(x): > lastX = None > aLastX = None > bLastX = None I'm pretty sure your method will work if you just specify that these are global: def FW(x): global lastX

Re: Help me dig my way out of nested scoping

2005-04-03 Thread James Stroud
I wish I had time to dig into your specific problem because it looks interesting. But I think you might want to look at "python generators". I beleive there is no reason that they can't yield a function. http://www.python.org/peps/pep-0255.html http://docs.python.org/ref/yield.html http://linuxg

Re: Help me dig my way out of nested scoping

2005-04-03 Thread Michael Spencer
Brendan wrote: Hi everyone I'm new to Python, so forgive me if the solution to my question should have been obvious. ... Good question. For a thorough explanation see: http://www.python.org/dev/doc/devel/ref/naming.html Simple version follows: OK, here's my problem: How do I best store and cha

Help me dig my way out of nested scoping

2005-04-03 Thread Brendan
Hi everyone I'm new to Python, so forgive me if the solution to my question should have been obvious. I have a function, call it F(x), which asks for two other functions as arguments, say A(x) and B(x). A and B are most efficiently evaluated at once, since they share much of the same math, ie, A