ternary operator
David LeBlanc
whisper at oz.net
Fri Feb 7 09:05:38 EST 2003
I think that's POOR programming practice!
David LeBlanc
Seattle, WA USA
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Carlos Ribeiro
> Sent: Friday, February 07, 2003 3:23
> To: David LeBlanc; python-list at python.org
> Subject: Re: ternary operator
>
>
> On Friday 07 February 2003 04:15 am, David LeBlanc wrote:
> > if a > b and c < d():
> > print e
> >
> > d() might never get called. Not good if d() does something you
> depend on.
>
> But is just perfect in some cases (common in programs that rely on short
> circuiting) where the evaluation of d() depends upon some
> condition that is
> tested first. The usual case is something like this:
>
> if a <> 0 and c < (b/a):
> print e
>
> That's just to point out why short-circuiting might be useful.
> Anyway, it's a
> religious debate over the choice of short-circuiting x full
> evaluation, and
> there are *lots* of good arguments from both sides. Performance
> wise, short
> circuiting will be faster, and probably a bit safer in 'normal'
> situations.
>
>
> Carlos Ribeiro
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list