Arcane question regarding white space, editors, and code collapsing

W

Wells

I work in TextMate a lot, which I generally love, but it's code
collapsing confounds me. Essentially you have to indent blank lines to
the proper level for the current block. Then it will collapse that
section as one section. If you have simply a new line, it will see it
as a break, and not collapse, though the python interpreter doesn't
care- it only cares about lines of actual code.

Is it... pythonic, then, to have these lines of tabs/spaces to support
code collapsing? Is it proper, improper, or irrelevant?

Thanks.
 
S

Steven D'Aprano

It's quite improper (though syntactically null, in Python) to have
trailing whitespace on lines. That includes blank lines.

Blank lines are far from improper in Python, they're recommended by PEP 8.

One major reason is that trailing whitespace causes spurious invisible
differences between otherwise-identical lines when doing an automatic
comparison, which is done quite a lot in collaboration and version
control.

Then you need better comparison software that doesn't give so many false
matches due to insignificant differences.

Fix your text editor (which may entail switching to a better text
editor) to respect blank lines and the conventions of the language.

Yes, if the editor's handling of code collapsing is broken, it needs to
be fixed, or replaced.
 
A

Aahz

It's quite improper (though syntactically null, in Python) to have
trailing whitespace on lines. That includes blank lines.

Your parenthetical is not quite true, unfortunately. Trailing whitespace
after a continuation backslash generates a SyntaxError. That's the main
reason I loathe continuation lines.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top