python – inconsistent use of tabs and spaces in indentation
python – inconsistent use of tabs and spaces in indentation
Dont use tabs.
- Set your editor to use 4 spaces for indentation.
- Make a search and replace to replace all tabs with 4 spaces.
- Make sure your editor is set to display tabs as 8 spaces.
Note: The reason for 8 spaces for tabs is so that you immediately notice when tabs have been inserted unintentionally – such as when copying and pasting from example code that uses tabs instead of spaces.
Using the autopep8
command below fixed it for me:
autopep8 -i my_file.py
Documentation for autopep8
linked here.
python – inconsistent use of tabs and spaces in indentation
For VSCode users
Ctrl+Shift+P or View->Command Palette.
Type
>Convert Indentation to Spaces
press Enter.