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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top