how can I make a list of callable commands python? -


i wondering how go making list of commands user can enter. example, user types in "who" list of on in mud. done using if, elif , else in pythons?

i using python 3.1 btw.

nope. dispatch dictionary.

def who(*args, **kwargs):    ...  commands = {   'who': who,    ... }  ... if command in commands:   commands[command](*args, **kwargs) else:   print('bad command or file name') 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -