[Python-mode] edit-style considering empty line

Barry Warsaw barry at python.org
Tue Sep 24 15:45:14 CEST 2013


On Sep 23, 2013, at 09:57 PM, Andreas Röhler wrote:

>The OP wanted the Editor intends the second "print" to column 0.  IMO it's
>possibly establishing an edit rule saying: if an empty line follows a block,
>consider this block closed.

As Diez mentioned, an option defaulting to off would be interesting to play
with.  I generally discourage using vertical whitespace inside methods, and
mostly use it for structural separation, so I think this might be reasonable.
It could only apply to actual blank lines, i.e. comments wouldn't trigger it.

>def find(seq, target):
>     for i, value in enumerate(seq):
>         if value == tgt:
>             break
>     else:
>         return -1
>     return i

Actually, that else gets lined up under 'if' right now.

>If an empty line after "break" is inserted:
>
>def find(seq, target):
>     for i, value in enumerate(seq):
>         if value == tgt:
>             break
>
>     else:
>         return -1
>     return i

So I guess you're saying the blank line would add an extra dedent level?  I
hate to have people start to rely on this behavior to add non-structural
vertical whitespace.  If this feature is more helpful for top-level
structures, then it might be useful, otherwise I'm skeptical.  But as I say,
it might be interesting to play with.

-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-mode/attachments/20130924/ac06fdc7/attachment.sig>


More information about the Python-mode mailing list