I'm using the Cmd
class of Python's cmd module to create an interpreter for a game in Text Adventure. However, I came up with a problem regarding the words I use as methods for the interpreter to execute.
See this example example:
import cmd
class Comando(cmd.Cmd):
prompt = ">"
def do_olhar(self, valor):
print('Olhar em volta')
def do_ver(self, valor):
print('Olhar em volta')
def do_pegar(self, valor):
print('Pegar algo')
def do_pega(self, valor):
print('Pegar algo')
def do_obter(self, valor):
print('Pegar algo')
c = Comando()
c.cmdloop()
Notice that some words are similar and have the same purposes, such as obter
, pegar
, pega
, olha
, olhar
and ver
.
So, I would like to know if it is possible to create a method that is associated with a set of words and not just one as is the case above i.e. do_palavra()
?