Is there a function to make the Python file again according to pep8?

Asked 2 years ago, Updated 2 years ago, 23 views

I was teaming up, but when I made it, some people used tabs and some people indented it with spaces (even the number of tabs I wanted to...) I want to fix all of these according to pep8.

I want to fix the indentation while maintaining the original code, but please let me know if there is a related site or Python module.

python pep8

2022-09-22 15:38

1 Answers

Write autopep8

$ pip install --upgrade autopep8

$ autopep8 --in-place --aggressive --aggressive <filename>

From what I've run on the terminal,

$ cat mine.py
if True:
  print("2 spaces apart!")
$ $ autopep8 --in-place --aggressive --aggressive mine.py
$ $ cat mine.py
if True:
    print("2 spaces apart!")
$


2022-09-22 15:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.