Scoping loops (was Re: Feature request: subclassing FunctionType)

Aahz aahz at pythoncraft.com
Tue Mar 2 05:55:42 EST 2004


In article <95aa1afa.0403012224.506dd07c at posting.google.com>,
Michele Simionato <michele.simionato at poste.it> wrote:
>
>1. Assuming all "for" loops and list comprehensions are replaced
>   with Haskell bindings rules, what about backward compatibility
>   problems? For instance: is there enough code relying on the loop 
>   variable being available outside the loop?

Yes.  Guido has Pronounced that this will stay, but...

>2. If, due to compatibility issues, it is not possible to change the
>   binding rules of existing loops, would it make sense to propose
>   these binding rules for Python 2.4 generator comprehension?
>   This would not be backward incompatible, but would it generate
>   confusion?

....while the rules for generator expressions have not been finalized,
Guido has agreed that they will have their own scope and that listcomps
will be changed in Python 3 to have their own scope.  You should read the
python-dev thread on generator expressions yourself to understand what's
being proposed.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list