class CommandManager:
def __init__(self):
self.commands = []
def add_command(self, command: Command):
if command is None:
return None
for target in self.commands:
if target.name is command.name:
return None
print(command.name, command.description, command.usage, command.min_arguments) # debug
self.commands.append(command)
return command
def get_command(self, name):
if name is None:
return None
for target in self.commands:
if name is target.name:
return target
return None
このコードには何が問題なのですか?配列に追加してadd_command
メソッドでそれを探しても問題ありませんが、get_command
には見つかりません。値はNone
ではありません。一覧で検索する
を。 –
あなたは何をお勧めしますか? – kacperduras