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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to