I'm taking a stab at multiprocessing and I need one process to tell the other to run a given function. On the receiving end, I'm trying to figure out how to interpret the message it gets. I could set up a big nest of if/elif to test for every possible function:
def Bacon ():
print ( "Lean!" )
def Eggs ():
print ( "Scrambled!" )
def Toast ():
print ( "Butter!" )
Function = "Eggs"
if Function == "Bacon" :
Bacon ()
elif Function == "Eggs" :
Eggs ()
elif Function == "Toast" :
Toast ()
But it would be a lot nicer if I could just convert the string to a function reference directly. Something like this:
def Bacon ():
print ( "Lean!" )
def Eggs ():
print ( "Scrambled!" )
def Toast ():
print ( "Butter!" )
Function = "Eggs"
Call_Function_From_String ( Function )
Does anyone know if that's possible?
Thanks!