On 09/10/2022 05:47, Chris Angelico wrote:
On Sun, 9 Oct 2022 at 15:39, Axy via Python-list <python-list@python.org> wrote:
Got it, thanks!

Actually the reason I never used "else" was the violation of the rule of
beauty "shortest block first". With if--else you can easily follow this
rule by inverting "if" expression, but with for--else you can't. The
loop body of the simplest example is already three lines, in real life
things are much worse.

That's not a rule I've ever been taught; how important is it?

ChrisA

It gets important if the lifetime of your project is more than three months and is extremely important if more than 10 years. But, it depends.

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.

Axy.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to