Re: problem with variable and function

2010-03-14 Thread Alex Hall
>> #we now have the default mode to be used, but what if it is disabled? >> if(sys.modules[modeNames[mode]].enabled=='False'): >> nextMode() > >How is this call supposed to work when `funcs` (which nextMode() uses) >hasn't been defined yet?! That seems to have done it, thanks. Sorry about top-pos

Re: problem with variable and function

2010-03-14 Thread Chris Rebert
> On 3/14/10, Chris Rebert wrote: >> On Sun, Mar 14, 2010 at 10:26 AM, Alex Hall wrote: >>> Hi all, >>> I have a file with a dictionary and a function. The dictionary holds >>> the name of the function, and the function references the dictionary. >>> If I put the dictionary first, the function is

Re: problem with variable and function

2010-03-14 Thread Alex Hall
Below is pasted the function which is looking for the "funcs" dictionary, as well as the dictionary. They appear in my py file in this order, yet I get an error in nextMode() that "global name 'funcs' is not defined". Oddly, the keys dictionary works fine; it is defined above the nextMode function.

Re: problem with variable and function

2010-03-14 Thread Chris Rebert
On Sun, Mar 14, 2010 at 10:26 AM, Alex Hall wrote: > Hi all, > I have a file with a dictionary and a function. The dictionary holds > the name of the function, and the function references the dictionary. > If I put the dictionary first, the function is happy but the > dictionary says the function

Re: problem with variable and function

2010-03-14 Thread Jason Tackaberry
Hi Alex, On Sun, 2010-03-14 at 14:26 -0400, Alex Hall wrote: > Reverse it, though: > > def myFunc(): > myOtherVar=myVar > > myVar={ > 1:myFunc > } > > and the function myFunc does not see the dictionary. The code you provided works just fine (as one would expect). If you can provide an exam