Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a single construct which both does async with and then async for #753

Closed
evhub opened this issue May 27, 2023 · 0 comments
Closed

Add a single construct which both does async with and then async for #753

evhub opened this issue May 27, 2023 · 0 comments

Comments

@evhub
Copy link
Owner

evhub commented May 27, 2023

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.

@evhub evhub added the feature label May 27, 2023
@evhub evhub added this to the v3.0.2 milestone May 27, 2023
evhub added a commit that referenced this issue May 27, 2023
@evhub evhub added the resolved label May 27, 2023
@evhub evhub closed this as completed May 27, 2023
@evhub evhub mentioned this issue May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant