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
Post a Comment