Cleaning up conditionals

BartC bc at freeuk.com
Sun Jan 1 18:56:25 EST 2017


On 01/01/2017 14:32, Rustom Mody wrote:
> On Sunday, January 1, 2017 at 7:51:12 PM UTC+5:30, Rustom Mody wrote:
>> On Sunday, January 1, 2017 at 3:39:14 PM UTC+5:30, Deborah Swanson wrote:
>>> Sorry guys. I've read all your responses and I kind of get their general
>>> drift, but I'm about four sheets to the wind right now, and no way would
>>> I make it more than a step or two in playing around with these things
>>> and trying to get my head around them before it would all descend into a
>>> cacaphony of gibberish.
>>
>> Its true that in most programming languages one is likely to see,
>> a conditional (if) statement is likely harder to grok than a conditional
>> expression ie if the expression is allowed at all!!
>
> Er... Meant the other way round!

Python's version is certainly a little harder to understand!

What is it again:  X if C else Y ?

Here, if C is false, then only Y is evaluated, even though the first 
thing encountered is X! More than a little unintuitive.

-- 
Bartc




More information about the Python-list mailing list