any() and all() shorthand

castironpi at gmail.com castironpi at gmail.com
Mon Jan 7 14:45:28 EST 2008


On Jan 7, 1:29 pm, "Guilherme Polo" <ggp... at gmail.com> wrote:
> 2008/1/7, castiro... at gmail.com <castiro... at gmail.com>:
>
> > > You are too late, any and all are built-in into python 2.5
>
> > Hi, excellent.  Now how about something more generic, possibly:
>
> > [ x.y() for x or _next_ in c ]
>
> > where the context of _next_ is limited in complexity, and/or can only
> > occur in a generator?
>
> Would you care to explain what that syntax supposedly means ? By
> _next_ you mean something like the next method in generators ? _next_
> executes if x is false ? so whatever _next_ returns is named as x, so
> you can call x.y() ? I really didn't get your new syntax inside that
> list comprehension, neither its uses.
>

The idea is a shorthand for reduce.  Here, _next_ meant the next item
in the iterable c.




More information about the Python-list mailing list