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/2005-September/056587.html below:

[Python-Dev] Adding a conditional expression in Py3.0

[Python-Dev] Adding a conditional expression in Py3.0 [Python-Dev] Adding a conditional expression in Py3.0Thomas Lotze tl at gocept.com
Wed Sep 21 00:59:49 CEST 2005
Barry Warsaw wrote:

>> x = (if a then
>>         b
>>      elif c then
>>         d
>>      else
>>         e
>>     )
[...]
> 
> I guess that's my point.  To me, your latter is actually worse than
> 
> if a:
>     x = b
> elif c:
>     x = d
> else:
>     x = e

Can't see a difference as far as readability is concerned. But then,
tastes differ.

> I think the conditional stuff gets the most bang for the buck in
> situations like:
> 
> d[foo] = if a then b else c

And I think similar holds for LCs and GEs. Unwinding a complex sequence of
for and if clauses is certainly no fun unless one is really used to it.
(Which doesn't take long, though.)

But your example poses another question: Up until now, I had the
impression that parentheses should be mandatory around a conditional
expression. There's certainly no avoiding them in situations like
(if x then 1 else 2) + 3. But what about unambiguous cases like your
example line?

-- 
Thomas


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