Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerate instead of range/len. (AntiOCD) #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion usbexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def command(self, request_data, response_length):

def execute(self, response_length, *args):
cmd = str()
for i in range(len(args)):
for i in enumerate(args):
Copy link

@cclauss cclauss Sep 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? enumerate() returns a tuple.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this PR makes no sense.

Copy link

@cclauss cclauss Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this change is a nice optimization but it’s implementation is incomplete...

for i, arg in enumerate(args):
    # and then change all instances of "args[i]" with "arg".

if isinstance(args[i], (int, long)):
cmd += struct.pack('<%s' % self.cmd_arg_type(), args[i])
elif isinstance(args[i], basestring) and i == len(args) - 1:
Expand Down