Skip to content

comprehension syntax should respect the local variables defined in if clause #32905

@yatra9

Description

@yatra9

It will be nice if comprehension syntax respects the local variables defined in if clause.

For example, filter_map of Ruby 2.7 or Rust will be implemented as follows

filter_map(f, a) = (y for x in a if (y=f(x)) !== nothing)

Python 3.8 will introduce the assignment expressions which makes this possible.
https://docs.python.org/3.8/whatsnew/3.8.html
https://www.python.org/dev/peps/pep-0572/#simplifying-list-comprehensions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions