indentation
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Oct 19 10:34:45 EDT 2008
On Sun, 19 Oct 2008 07:16:44 -0700, Gandalf wrote:
> every time I switch editor all the script indentation get mixed up, and
> python start giving me indentation weird errors. indentation also hard
> to follow because it invisible unlike brackets { }
Indentation is not invisible.
Can you really not see that this text
is indented? If so, your news program
is seriously broken.
> is there any solution to this problems?
Discipline. Choose a standard indent and stick to it.
You can use tabs, or spaces. If you use spaces, you can choose 4 spaces,
or 8, or any number, but whatever you choose, stick to it no matter what
editor you use. Good editors will let you use the tab key to indent with
spaces. Bad editors (e.g. Windows Notepad, and I feel your pain if you
have to use it) force you to manually insert spaces.
Especially never mix tabs and spaces in the same file. If you're editing
an existing file, you must follow whatever indent standard is already in
use.
You can also pass the -t option when launching the Python interpreter to
warn about mixed tabs and spaces.
See also the standard module tabnanny:
http://effbot.org/librarybook/tabnanny.htm
--
Steven
More information about the Python-list
mailing list