Re: [Info] PEP 308 accepted - new conditional expressions
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: [Info] PEP 308 accepted - new conditional expressions

From: Michael <ms@cerenity.org>
Date: Mon Oct 03 2005 - 03:22:22 CEST

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
Received on Sat Oct 15 04:03:54 2005