I have a Python code with a mixture of 2 and 4 spacing. I would like to make it consistent. Is there any software that can

  • automatically adjust to a consistent spacing
  • ideally, it can adjust for a given range of lines, e.g., 1-300. So I can test the adjustment segment by segment
  • Linux or Windows platform

An example of a code with mixed spacing

n = 2
m = 3
for i in range(n):
  for j in range(m):
    print(i, j)

for i in range(n + 1):
    for j in range(m + 2):
        print(i, j)      
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Nov 28, 2021 at 11:04

1 Answer 1


reindent can at least adjust to all 4 spaces https://pypi.org/project/reindent/

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 29, 2021 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.