A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039085.html below:

[Python-Dev] listcomps vs. for loops

[Python-Dev] listcomps vs. for loopsMichael Chermside mcherm at mcherm.com
Mon Oct 20 14:06:52 EDT 2003
Alex:
> We are indeed sure (sadly) that list comprehensions leak control
> variable names.

Guido:
> But they shouldn't.  It can be fixed by renaming them (e.g. numeric
> names with a leading dot).

Aahz:
> ?!?!  When listcomps were introduced, you were strongly against [...]
> Are you changing your position[...]?

Guido:
> Did I say it was a feature that
> 
>   L = [x for x in R]
>   print x
> 
> would print the last item of R?

Well, I don't care much about the history of what you may have said...
let's get it out in the open: The fact that listcomps leak their
variable (thus providing a handy name-binding expression for the evil-minded
among us) is a BAD THING.

I'd love to see that (mis)feature removed someday. I'd love to have that
made possible by Guido's _immediately_ and _officially_ declaring it to be
an unsupported (and deprecated) feature. Then maybe *someday* we could
get rid of them. Even now, people are writing code that (ab)uses this,
and making it ever harder to ever change this in the future.

-- Michael Chermside


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4