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/2008-May/079560.html below:

[Python-Dev] Conditional For Statements

[Python-Dev] Conditional For Statements [Python-Dev] Conditional For StatementsLennart Regebro regebro at gmail.com
Mon May 19 12:42:29 CEST 2008
On Mon, May 19, 2008 at 5:55 AM, Terry Reedy <tjreedy at udel.edu> wrote:
>
> "Ryan Hitchman" <hitchmanr at gmail.com> wrote in message
> news:e60c31470805181845u7fb0cafdsb0878db491eb7a3c at mail.gmail.com...
> | I'd like to propose an addition to the for statement's syntax:
> |
> | for {variable} in {iterable} if {condition}:
> |    {block}
> |
> | which is equivalent to
> |
> | for {variable} in {iterable}:
> |    if not {condition}:
> |        continue
> |    {block}
>
> Is this different from
> for var in filter(lambda x: condition(x), iterable)):
> ?
>
> | and
> |
> | for {variable} in filter(lambda: {condition}, iterable):
> |    {block}
>
> IDLE 3.0a5
>>>> for i in filter(lambda i: i%2, range(10)):
>  print(i)
>
>
> 1
> 3
> 5
> 7
> 9

How was it again? "One and only one way"? :-)

-- 
Lennart Regebro: Zope and Plone consulting.
http://www.colliberty.com/
+33 661 58 14 64
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