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


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to