[Python-Dev] RFC: generator combinator syntax

Paul Prescod paulp@ActiveState.com
Fri, 03 Aug 2001 16:07:51 -0700


"Steven D. Majewski" wrote:
> 
> 
>         Files('.') | isGif
> 
> Files( '.' ) is a generator that recursively enumerates all the files
>              starting from the current (unix) working directory.
> 
> isGif = lambda s : s.lower().find( '.gif' ) >= 0

I propose:

[yield file for file in Files('.') 
       if file.lower.find(.'gif')>=0]

By reusing the yield keyword we can get rid of the need for the new "|"
or "&" syntax.

Any kind of combination that can be done with list comprehensions would
be possible with generator comprehensions.
-- 
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.ActiveState.com/pythoncookbook