A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2001-August/016684.html below:

[Python-Dev] RFC: generator combinator syntax

[Python-Dev] RFC: generator combinator syntax [Python-Dev] RFC: generator combinator syntaxPaul 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



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