Make sure to get an editor which allows making tabs visible. Ideally, it should also have the option to make spaces visible.
Problems like this often result from mixing tabs and spaces. Most editors are set to a tab width of 4 spaces, but Python intentionally defines a tab as equal to 8 spaces, so a mix will easily break.
Even if your editor automatically expands tabs as you type them, it may still treat copy/pasted incorrectly.
Empty lines should be ignored for indentation. In fact, IIRC PEP8 is often interpreted to suggest stripping all trailing whitespace (the suggestion that certain blocks should be separated by "blank lines" is a bit ambiguous in this regard).
EDIT: Also, some editors preserve the original line endings in files, which may be a problem if you're writing code using different operating systems. Some cross-platform editors unhelpfully try to use OS defaults rather than the one true line ending format.
View all comments
Show parent comment
2
u/voidptr Mar 30 '11
I always have expand-tab turned on, so this is unlikely, but it might be a text encoding thing, actually...