[Info] PEP 308 accepted - new conditional expressions

Michael ms at cerenity.org
Mon Oct 3 20:38:11 CEST 2005

Christophe wrote:

> Michael a écrit :
>> 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).
> Actually, you don't need to know operator precedence here because the
> notation isn't ambiguous in those 2 examples. Of course, it takes some
> time to understand the thing but it has more to do with the excessive
> amount of "logic" in one line than with the syntax.

I noted that. However it *does* slow people down which increases the chances
of misconception (which is why I'd be in favour of bracketing these


More information about the Python-list mailing list