PEP308: Yet another syntax proposal

Dave Brueck dave at pythonapocrypha.com
Mon Feb 10 17:26:44 EST 2003


On Mon, 10 Feb 2003, Andrew Dalke wrote:

> Dave Brueck
> > Several of the previous examples have already illustrated this:
> >
> > z = iif(x, x.getPref(), 'Not specified')
> >
> > is broken without short-circuiting.
>
> Indeed.  And my best meta-analysis of the code analysis done by
> me and others suggests that this form is needed about once every
> 5,000 lines of code, while a non-short-circuiting function would be
> used much more frequently.  (I didn't do the analysis of the uses
> if an iff() statement, but based on the other results it would be
> at least 1 per 1,000 lines, and more likely more often than that,
> so my educated guess is about 1 every 400 lines or so.)

Yes, I've read with interest your analysis - thanks for doing it.

Adding a new builtin (for the non-short-circuiting version) would get a -1
from me because (1) it would introduce inconsistencies - you have a
pseudo-conditional operator that works a lot of the time but occasionally
bites you if you forget and (2) I already can, and do, add little
"utility" functions all the time as needed so having Python ship it for me
doesn't really add any value.

In C there are lots of people who never use it but for all we know it's
because the language they used before C didn't have one either.

-Dave





More information about the Python-list mailing list