How to correct syntax error due to tab order in python? -


i experience problem tab when programming python (when editing .py file different editor possibly).

it frustrating! want manually put tabs first line end of file if need edit.

is there better way of solving problem?

yes, not use tabs when indenting. too easy mix tabs , spaces.

quoting pep 8 python style guide:

never mix tabs , spaces.

the popular way of indenting python spaces only. second-most popular way tabs only. code indented mixture of tabs , spaces should converted using spaces exclusively. when invoking python command line interpreter -t option, issues warnings code illegally mixes tabs , spaces. when using -tt these warnings become errors. these options highly recommended!

for new projects, spaces-only recommended on tabs. editors have features make easy do.

emphasis mine.

first, detect inconsistent indentation running code python -tt scriptname.py. fix errors.

then convert tabs spaces, , configure editor use spaces indentation. python style guide recommends 4 spaces per indentation level, , i.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -