[Info] PEP 308 accepted - new conditional expressions

Michael ms at cerenity.org
Sun Oct 2 21:22:22 EDT 2005


Rocco Moretti wrote:

> That is, what would happen with the following constructs:
> 
> A if B else C if D else F
> A if B if C else D else F

The correct answer should be the person who wrote it would get told off
for writing code that a person reading would have no idea what the code
was doing (without understanding the precedence).

Whilst it's good to have clear understandable, well defined rules for
these things, that's no excuse for having unreadable code that other
people can't read and understand without having to remember obscure
rules.

Personally, I'd hope that any code-linting tools would flag such expressions
as potentially bad because they're not clear. (Whereas bracketed expressions
instantly help here).

Best Regards,


Michael




More information about the Python-list mailing list