problem with variable and function

Alex Hall mehgcap at gmail.com
Sun Mar 14 14:26:18 EDT 2010


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 first, the function says the dictionary does not
exist. Does anyone have an idea as to how I can make both of them
happy? Thanks!

Example:

myVar={
 1:myFunc
}

def myFunc():
 myOtherVar=myVar

would result in myVar saying myFunc does not exist. Reverse it, though:

def myFunc():
 myOtherVar=myVar

myVar={
 1:myFunc
}

and the function myFunc does not see the dictionary. I basically
cannot win either way, and I need a way to resolve this. If you are
curious, the dictionary holds function names and maps to a second
dictionary of keystrokes, allowing me to map a keystroke to call a
function. Thanks!

-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap



More information about the Python-list mailing list