ternary operator

Carlos Ribeiro cribeiro at mail.inet.com.br
Fri Feb 7 19:37:48 EST 2003


On Friday 07 February 2003 02:05 pm, David LeBlanc wrote:
> I think that's POOR programming practice!

David,

I'll just repeat what I said: the option to rely (or not - after all, it 
depends on the actual language and/or implementation) on short circuit 
evaluation is pretty much a religious debate. Some people think it's poor 
programming practice, others think that it is the obvious way of doing stuff. 
As for myself, being an old Pascal/Delphi addict, I'm used to (relying on) 
short-circuiting expressions, but I avoid it if I feel it will make the code 
less clear.


Carlos Ribeiro
cribeiro at mail.inet.com.br

> 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