Compare source code

Alain Ketterlin alain at dpt-info.u-strasbg.fr
Fri Nov 5 06:21:57 EDT 2010


Terry Reedy <tjreedy at udel.edu> writes:

> If you add the normally redundant information in the form of explicit
> dedents (anything starting with '#' and distinguishable from normal
> comments), then it is not too hard to re-indent even after all indents
> have been removed.

I actually use such a trick in emacs, not with comments but with "pass"
(emacs' python mode knows that pass end return end the current block).
It's extrememly useful in heavily nested code, or if I need to paste
some piece of code from one level to another. This lets my editor's
auto-indenter do the right thing. And I see immediately if/when I did
the nesting wrong.

I really like "indentation as structure" (code is more compact and
clearer), but I really hate that it relies on me putting the right
spaces at the right place. I would love to be able to put, e.g., a
period at the end of a line, to indicate that the next line is one level
upper. Something like:

for i in ... :
    for j in ... :
        whatever(i,j).
    .

No lost vertical space (except when I decide it), no ambiguity. It looks
to me like the exact opposite of ':'. End-of-line periods (or
exclamation marks) would let tools reindent correctly in all cases. I
don't think it conflicts with any other syntax.

-- Alain.



More information about the Python-list mailing list