From: Kefu Chai Date: Thu, 2 May 2019 14:20:16 +0000 (+0800) Subject: pybind/mgr: use enumerate() for accessing index in a loop X-Git-Tag: v15.1.0~2715^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aadb8ec856659a015f16d319efe4d4588362f97f;p=ceph.git pybind/mgr: use enumerate() for accessing index in a loop for better readability Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index a2d6793eaf2d..cad8fe581e57 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -79,16 +79,16 @@ class CommandsRequest(object): # Gather the results (in parallel) results = [] - for index in range(len(commands)): + for index, command in enumerate(commands): tag = '%s:%s:%d' % (__name__, self.id, index) # Store the result result = CommandResult(tag) - result.command = common.humanify_command(commands[index]) + result.command = common.humanify_command(command) results.append(result) # Run the command - context.instance.send_command(result, 'mon', '', json.dumps(commands[index]), tag) + context.instance.send_command(result, 'mon', '', json.dumps(command), tag) return results