8000 Add a single construct which both does `async with` and then `async for` · Issue #753 · evhub/coconut · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000
Add a single construct which both does async with and then async for #753
Closed
@evhub

Description

@evhub

When working with async generators, it is often advised, using something like aclosing or trio_async_generator to implement a pattern like:

async with my_generator() as values:
    async for x in values:
        ...

which unnecessarily creates two nested blocks in a relatively non-ergonomic way. Instead, we could have a single syntax like

async with for x in my_generator():
    ...

that compiles to the code above.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0