Hi Andrew,

On 3/12/19 5:48 pm, Andrew Barnert wrote:
On Mon, Dec 2, 2019 at 3:12 PM Jan Bakuwel <jan.baku...@gmail.com <mailto:jan.baku...@gmail.com>> 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.
This is of course a silly example.
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.)

I've been doing software engineer for a few decades... I like to think I know a little bit about it :-) ... believe me I have more than one use case where this would be very useful for me.

cheers,
Jan
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KXVSYEMNG5H2VLHQ2W3QMNE5EAUUWEQP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to