[Python-ideas] Variations on a loop

Bruce Leban bruce at leapyear.org
Sat Aug 30 02:25:35 CEST 2008

On Fri, Aug 29, 2008 at 1:47 PM, David Blaschke <dwblas at gmail.com> wrote:

> This idea
> elif x == funky_empty:
>       result = 'no data'
> Can be accomplished with
> if not len(items):
>       result = 'no data'
> which means that part of the proposal can be scratched IMHO.

Not quite: len(items) requires iterating across the entire list which may
not be necessary or desirable. Plus you may need an intermediate variable to
store it. I think that's inferior.

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20080829/9ac32da7/attachment.html>

More information about the Python-ideas mailing list