Feature request: subclassing FunctionType [Was: Some languageproposals]

Terry Reedy tjreedy at udel.edu
Tue Mar 2 16:29:53 CET 2004


"Michele Simionato" <michele.simionato at poste.it> wrote in message
news:95aa1afa.0403012224.506dd07c at posting.google.com...
> 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?

Guido has given things like the following as an intentional reason for the
current rule (and for for...else):

for item in seq:
  if acceptable(item): break
else:
  item = None
# item is now either the first acceptible item in seq or None

If you do not like the iteration var remaining bound, you can explicitly
delete it.  If it is automatically deleted, constructions like the above
are rendered more difficult.

A list comp encapulates a specialized for loop whose specific job is to
produce a list.  It makes more sense to delete the binding automatically
there since a) there is no way, when seq is empty, to force a binding to
*something*, with else and b) the last item of the list is readily
available anyway as result[-1].

Terry J. Reedy







More information about the Python-list mailing list