Equivalent to (a ? b : c) ?

James Logajan JamesL at Lugoj.Com
Mon Dec 20 23:01:20 EST 1999


"Magnus L. Hetland" wrote:
> 
> "Jesper Hertel" <jh at cddk.dk> writes:
> 
> > I hope this was a joke. That kind of constructions is impossible to read for
> > other programmers, making the program hard to maintain.
> >
> 
> It is idiomatic python, really...

I think you spelled "idiotic" incorrectly. (Sorry, cheap shot.) I don't have
a dictionary in front of me, but I'm pretty sure that by definition an idiom
can not be unilaterally declared.

By the way, I would agree that my function solution is not the same at all
as the "C" "?:" operation. I've been programming in "C" for almost 20 years
now and have been moving away from using that operator. I use its
short-circuit evaluation now mostly in printf debug statements for such
things like:

char *var = 0; /* Or NULL if you're old fashioned like me. */
/* something happens to var...maybe. */
printf("[%s]\n", var ? var : "<NULL>");



More information about the Python-list mailing list