for -- else: what was the motivation?

Axy axy at declassed.art
Sun Oct 9 02:25:01 EDT 2022


> 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.


More information about the Python-list mailing list