On Mon, Dec 2, 2019 at 3:12 PM Jan Bakuwel <[email protected]> wrote:

> Code example:
> 
> def func (i: int, j: int, k: int) -> None:
>      if (i == 3):
>          while (i < 15):
>              i += 1
>              if (k == 8):
>                  lots of other code (think a page or more)

This is your actual problem: you have a whole page of code nested four times. 
That’s not going to be readable no matter what editor support you have; you 
need to refactor it.

With smaller blocks of code where the whole thing does fit easily on the 
screen, you usually don’t get lost—and if you do, most editors already help 
you. They can draw a different colored line down the left side of each block, 
or have a keystroke to briefly highlight the start of the current block (I use 
that in emacs whenever I’m forced to edit code that someone insisted on writing 
with 2 or even 1 space per indent—or, worse, inconsistent indents), or collapse 
the current block to an outline (which would actually be less useful if the 
outline had to show 3 lines instead of 2).

Sure, none of that is sufficient with huge blocks of code, but I don’t see how 
an “end if” would help. Who cares if they’re the same color when you can’t see 
them both anyway (which, by definition, you can’t when there’s a page or more 
of code between them)? All the “end if” really tells you is that some block 
whose start you can’t see ends here, which you can already tell from the 
dedent. (And, unlike C, where you need a closing brace because the dedent could 
be a lie, in Python it syntactically means the very thing you hope it means.)
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/LHUENJGBJUVPH7IKYUF3QOSSZHH2E67G/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to