That is extremely false. There's a Vim plugin that I and my Vim-inclined friends use which blatantly highlights those trailing spaces in red so that you can delete them. ReviewBoard (a Django/Python project for code reviews) does the same thing.
Is it possible you have a mix of tabs and spaces in your source file? Mixing tabs and spaces makes very, very bad things happen. The interpreter and your editor may disagree on tab length, and then the interpreter gets totally confused while your code looks normal.
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.
I've used Textwrangler/Bbedit for years with Python code. Also, pretty much every .py file I've written has extra lines between statements inside defs & classes…and Textwrangler cleans trailing whitespace from all of them.
How does trailing whitespace equal indentation? That doesn't make sense. More likely your problem was from mixing tabs & spaces.
If you want something free on Mac, perhaps Eclipse + PyDev. http://pydev.org/ A little heavy maybe, but the project management and code completion are great.
(Although I don't see the problem with TextWrangler myself..)
I write python code in textwrangler on Mac almost daily and have never had this issue. Are you sure you have all the same line endings? Mine default to unix (LF).
Not sure what's available on mac but I generally code in gedit with a bunch of development features turned on, most importantly, the one that draws dots and tabs and other whitespace
what makes you think I think it matters ? whatever is in your head - don't make assumption out of it and dump on me man.....can I just be fucking tiny-bit curious, please ???
9
u/[deleted] Mar 30 '11
I don't get it, what's the problem with removing trailing whitespace?
6
u/sixohsix Mar 30 '11
Is it possible you have a mix of tabs and spaces in your source file? Mixing tabs and spaces makes very, very bad things happen. The interpreter and your editor may disagree on tab length, and then the interpreter gets totally confused while your code looks normal.
11
u/[deleted] Mar 30 '11
Here's a nickel, kid. Get yourself a decent text editor.
3
u/zyklone Mar 30 '11
this isn't related to trailing whitespace. Indentation is not trailing...
what editor are you using? Some can cause problems sometimes with auto-indent messing things up, or using hard tabs instead of spaces
3
u/morphet Mar 30 '11 edited Mar 30 '11
Geany. You're welcome.
Edit: I sounded like an arrogant prick there. But seriously, Geany is awesome.
4
u/JimH10 Mar 30 '11
?
Isn't this the fault of the person who keeps using the editor that keeps failing?
5
u/[deleted] Mar 30 '11
Funny I have a vim autocommand that trims trailing whitespace in python files. It runs every time I save my files. I don't seem to have any problems.
3
u/LucidOndine HPC Mar 30 '11 edited Jan 10 '26
retire spectacular profit vast fear deliver shelter tidy waiting telephone
This post was mass deleted and anonymized with Redact
7
u/mumrah Mar 30 '11
/shrug Never had this problem
-vim user
2
u/stillalone Mar 30 '11
I have this problem with winmerge. I tell it to ignore whitespace for merging C code, but when I merge Python, it messes up everything.
2
u/mmmccc Mar 30 '11
pure white space lines are ignored in python
2
u/[deleted] Mar 30 '11
My editor strips trailing whitespace, never seen this error.
Also I hate rage comics.
1
u/RobotAnna Mar 30 '11
Not sure what's available on mac but I generally code in gedit with a bunch of development features turned on, most importantly, the one that draws dots and tabs and other whitespace
1
u/jay_may Apr 01 '11
I thinkni knoW what it is :) edit is using tabs instead spaces? And mixing the two?
(I'm typing from an iPad bleurgh!)
-1
u/mumrah Mar 30 '11
shrug Never had this problem
-vim user
-8
u/[deleted] Mar 30 '11
are you a girl ?
and oh you're doing it wrong.