On Wed, Oct 22, 2014 at 8:05 PM,  <busca...@gmail.com> wrote:
> Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast  escreveu:
>> Hello
>>
>>
>>
>> Is there in Python something like:
>>
>>
>>
>> j = (j >= 10) ? 3 : j+1;
>>
>>
>>
>> as in C language ?
>>
>>
>>
>> thx
>
> without not:
> j = [j+1, 3][j>=10]
> with not:
> j = [3, j+1][not (j>=10)]

There's a distinct semantic difference there, though. Compare these:

/* C */
int x = (y != 0) ? 65536/y : 0;

# Python
x = 65536/y if y else 0

# Python, your way
x = [0, 65536/y][y!=0]

Do you see where the problem is?

Plus, subscripting a literal list is far less readable than the
ternary operator.

Also: Please can you avoid Google Groups, or if you must use it,
please at least clean up the excessive blank lines before you post.
I've left them so you can see what we have to cope with. Thanks!

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to