for -- else: what was the motivation?

Michael Speer knomenet at gmail.com
Sun Oct 9 07:05:48 EDT 2022


>Well, the value is productivity. No need to save puzzles "what this
>hanging else belongs to?"

if you get to the point where it's hard to tell which else lines up with
which if or for statement, I would suggest breaking things out into
well-named helper functions rather than worrying over ordering by block size


On Sun, Oct 9, 2022 at 2:26 AM Axy via Python-list <python-list at python.org>
wrote:

>
> > Yes, I'm aware that code readability becomes irrelevant for
> > short-duration projects. Beside the point. I'm wondering how important
> > it really is to have the shortest block first.
> >
> >> I also might be wrong in terminology, anyway, there are many rules that
> >> make programmer's life easier, described in the literature from the old
> >> good "How to write unmaintainable code" to "The Art of Readable Code".
> >> And I hope there are a lot of recent books on this subject I did not
> >> track and read yet.
> > Also not really a justification for "shortest block first". Wanting
> > some elaboration on that. What's the value in it?
>
> Well, the value is productivity. No need to save puzzles "what this
> hanging else belongs to?" regardless of semantic, which ideally should
> not be a puzzle as well. Code small things first and return early, same
> as taking a test: do easy and quick things first and boring and
> difficult ones later.
>
> Axy.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list