[Python-Dev] listcomps vs. for loops
Jp Calderone
exarkun at intarweb.us
Tue Oct 21 10:28:16 EDT 2003
On Tue, Oct 21, 2003 at 12:41:00PM +0100, Michael Hudson wrote:
> Guido van Rossum <guido at python.org> writes:
>
> > I don't recall what I said then. Did I say it was a feature that
> >
> > L = [x for x in R]
> > print x
> >
> > would print the last item of R?
>
> A problem with such code irrespective of anything else is that it
> fails when R is empty.
>
Not when x is properly initialized. Anyway, this is no different from the
problem of:
for x in R:
...
print x
In any case, are there plans to also have the compiler emit warnings about
potential reliance on this feature?
Jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/python-dev/attachments/20031021/31c2666d/attachment.bin
More information about the Python-Dev
mailing list