0
def dotask():
    print "Task done..."

def returnvalue():
     return "Awesome"

cmd = raw_input("Your command: ")
eval(cmd + "()")

I know that you can't use eval to assign a value to a variable. but is it the best way to have user input be performing a function?

For example:
I put "dotask" in raw input, it will print "Task done..."

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Gribouillis
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.