(test) ? a:b

Ned Batchelder ned at nedbatchelder.com
Wed Oct 22 22:11:45 CEST 2014


On 10/22/14 12:28 PM, Steven D'Aprano wrote:
> Ned Batchelder wrote:
>
>> On 10/22/14 5:05 AM, buscacio at gmail.com wrote:
>
>>> without not:
>>> j = [j+1, 3][j>=10]
>>> with not:
>>> j = [3, j+1][not (j>=10)]
>>>
>>
>> Why on earth would you recommend this outdated hack, when there's a true
>> conditional operator?
>>
>>       j = 3 if j >= 10 else j+1
>
> I think that's a bit harsh. Especially since this appears to have been
> Buscacio's first post here. Hopefully not his(?) last post!

You are right, it sounds a bit harsh. Sorry.

-- 
Ned Batchelder, http://nedbatchelder.com




More information about the Python-list mailing list