"Laura Creighton" <[email protected]> a écrit dans le message de news:[email protected]...
You may be looking for dictionary dispatching.You can translate the key into a callable. def do_ping(self, arg): return 'Ping, {0}!'.format(arg) def do_pong(self, arg): return 'Pong, {0}!'.format(arg) dispatch = { 'ping': do_ping, 'pong': do_pong } and then at some point do dispatch[command](arg) It is useful to know that tuples make perfectly good dictionary keys, in case you need to store more state somewhere. Laura
hello Why "self" is as parameter of functions do_ping and do_pong ? thx -- https://mail.python.org/mailman/listinfo/python-list
