To play the devil's advocate... (1) Using the (possible, future) PEG parser <https://github.com/gvanrossum/pegen/> this would be easy to add to the grammar, as long as it's optional.
(2) It can actually help readability in some cases, especially when e.g. 'for' and 'if' alternate. (3) I have been known to hold a ruler against my screen to double-check indentation. On Mon, Dec 2, 2019 at 8:51 PM Andrew Barnert via Python-ideas < python-ideas@python.org> wrote: > On Mon, Dec 2, 2019 at 3:12 PM Jan Bakuwel <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. > > 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 -- 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/LHUENJGBJUVPH7IKYUF3QOSSZHH2E67G/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ 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/TFXRSUKSUO3D32KM475JNAAZTPM6LV4Q/ Code of Conduct: http://python.org/psf/codeofconduct/