for -- else: what was the motivation?

Peter J. Holzer hjp-python at hjp.at
Sun Oct 9 04:12:27 EDT 2022


On 2022-10-09 05:37:59 +0100, Axy via Python-list wrote:
> Actually the reason I never used "else" was the violation of the rule
> of beauty "shortest block first".

That's a weird rule.

I can see justifications for "most common case first" and "most special
case first", but ordering the cases in an if/elif/else statement by
length seems like ordering books by color: It may be pretty, but it
doesn't make them easy to find.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20221009/884d7785/attachment.sig>


More information about the Python-list mailing list