problem with variable and function

2010-03-14 Thread Alex Hall
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 is not defined. If I switch the two and put 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 example

Re: problem with variable and function

2010-03-14 Thread Chris Rebert
On Sun, Mar 14, 2010 at 10:26 AM, Alex Hall mehg...@gmail.com 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

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 3/14/10, Chris Rebert c...@rebertia.com wrote: On Sun, Mar 14, 2010 at 10:26 AM, Alex Hall mehg...@gmail.com 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

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-posting;