(test) ? a:b
Rustom Mody
rustompmody at gmail.com
Wed Oct 22 09:16:10 EDT 2014
On Wednesday, October 22, 2014 5:01:08 PM UTC+5:30, Ned Batchelder wrote:
> On 10/22/14 5:05 AM, buscacio 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)]
> Why on earth would you recommend this outdated hack, when there's a true
> conditional operator?
To learn a bit about the interchangeability of control and data structures?
[Just playing devil's advocate]
Doesn't change the fact that as a practice it should not be done
More information about the Python-list
mailing list