A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-March/062120.html below:

[Python-Dev] conditional expressions - add parens?

[Python-Dev] conditional expressions - add parens? [Python-Dev] conditional expressions - add parens?Fredrik Lundh fredrik at pythonware.com
Tue Mar 7 06:38:55 CET 2006
Alex Martelli wrote:

> On Mar 6, 2006, at 9:17 AM, Jim Jewett wrote:
>     ...
> > I think that adding parentheses would help, by at least signalling
> > that the logic is longer than just the next (single) expression.
> >
> >     level = (0 if "absolute_import" in self.futures else -1)
>
> +1 (just because I can't give it +3.1415926...!!!).  *Mandatory*
> parentheses make this form MUCH more readable.

but which parens ?

 level = 0 if "absolute_import" in self.futures else -1

 level = 0 if ("absolute_import" in self.futures) else -1

 level = (0 if "absolute_import" in self.futures else -1)

 level = (0 if ("absolute_import" in self.futures) else -1)

 level = ((0) if ("absolute_import" in self.futures) else (-1)) # ...

if you're asking me, I'd say that the second alternative is most
readable here.

at least as long as

 level = if ("absolute_import" in self.futures) then 0 else -1

is not on the list...

 level = 0 or -1 depending on "absolute_import" in self.futures

</F>



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4