[Python-ideas] Accessing the result of comprehension's expression from the conditional
lie.1296 at gmail.com
Sun Jun 21 08:32:35 CEST 2009
Stephen J. Turnbull wrote:
> Lie Ryan writes:
> > The proposal enables comprehension to become filter+map+filter,
> > map+filter, filter+map, or map-only; eliminating the redundant map in
> > (map+filter)+(map+filter).
> The problem with the proposal is that that is *all* it does. I don't
> see how you plan to disambiguate in cases where the desired operation
> "really is" (map+filter)+(map+filter). So what you're stuck at is "I
> want this one operation to be a one-liner." The reply to that is "not
> every two-line function needs to have special syntax."
The regular map+filter is still available by not using the `as` keyword
(or by not calling F). Thus when what you really wanted is two maps, you
need to use two comprehensions. The number of maps should == The number
of comprehension; currently it is not always possible to do so, when the
assumed map and filter ordering doesn't match our required ordering.
More information about the Python-ideas