Would someone please point me to a discussion or documentation on the 'unindent' error in Python. I am using ipython notebook, 2.7 python. The right arrow test (to locate spaces and tabs) is not a good test for the notebook as every right arrow moves just one space even where I used tabs as in a def definition. I would really like to know exactly what causes these errors. Thanks Ron
Asked
Active
Viewed 420 times
1 Answers
1
Do not mix spaces and tabs. PEP8 says to use spaces. Convert your tabs to 4 spaces (again, from PEP8). Here is a decent discussion on the thoughts behind spaces vs tabs.
Therefore, it is generally a good idea not to mix tabs and spaces for indentation. If you use tabs only or spaces only, you're fine.
Furthermore, it can be a good idea to avoid tabs alltogether, because the semantics of tabs are not very well-defined in the computer world, and they can be displayed completely differently on different types of systems and editors. Also, tabs often get destroyed or wrongly converted during copy&paste operations, or when a piece of source code is inserted into a web page or other kind of markup code.
-
Thanks Andy. Do you know an easy way to display spaces and tabs in ipython notebook? – Ron Mar 11 '14 at 02:41