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

Python __call__ special method practical example -

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -