Page MenuHomePhabricator

refactor: test: use _ variable for unused loop counters

Authored by PiRK on Tue, Sep 7, 15:16.


Group Reviewers
Restricted Project
rABC7b81a4a8aac4: refactor: test: use _ variable for unused loop counters

substitutes "for x in range(N):" by "for _ in range(N):"
indicates to the reader that a block is just repeated N times, and
that the loop counter is not used in the body

Backport notes:

  • this PR also replaces a few occurences of range(0, x) with range(x)
  • test/functional/ has been included in test/functional/, and was already up to date

This is a backport of core#19674

Test Plan

ninja check-functional-extended

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Tue, Sep 7, 15:16

Additional note: I had a quick look to see if there is an automated linter solution (autopep8...) for this. I couldn't find any.

Using _ as a throwaway variable is an often used idiom in python, but it is not universally considered a good practice. It can conflict with _ used as an internationalization function name. An alternative would be _i.

This revision is now accepted and ready to land.Tue, Sep 7, 15:56