[Python-ideas] PEP 533 Redux?

2020-12-31 Thread Paul Bryan via Python-ideas
I've now encountered an issue I believe that PEP 533 was intended to address: When an asynchronous context manager is created within an asynchronous generator, if the generator is not iterated fully, the context manager will not exit until the event loop cancels the task by raising a CancelledErro

[Python-ideas] Re: PEP 533 Redux?

2020-12-31 Thread Paul Bryan via Python-ideas
d that changing the default > behavior of for loops would break too much code. > > I wonder if the new PEG parser would allow us to decorate for loops > with context sensitive keywords to override this default behavior > without requiring code restructuring (adding a with statement). >

[Python-ideas] Re: Add a "closed for" loop (was "PEP 533 Redux?")

2021-01-06 Thread Paul Bryan via Python-ideas
Reading through the PEP again and some of the discussion, I think I now better understand the issue. If we were to undertake a change in for's behavior, unless the generator is actually explicitly scoped to the for statement (and doesn't survive outside of the loop, which is not how it works today

[Python-ideas] dataclass: __init__ kwargs and Optional[type]

2021-01-24 Thread Paul Bryan via Python-ideas
I've created a helper class in my own library that enhances the existing dataclass: a) __init__ accepts keyword-only arguments, b) Optional[...] attribute without a specified default value would default to None in __init__. I think this could be useful in stdlib. I'm thinking a dataclass decorato

[Python-ideas] Re: dataclass: __init__ kwargs and Optional[type]

2021-01-24 Thread Paul Bryan via Python-ideas
The main benefits of this proposal: - the order of fields (those with defaults, those without) is irrelevant - don't need to pedantically add default = None for Optional values On Sun, 2021-01-24 at 19:46 +0000, Paul Bryan via Python-ideas wrote: > I've created a helper class in m

[Python-ideas] Re: dataclass: __init__ kwargs and Optional[type]

2021-01-25 Thread Paul Bryan via Python-ideas
Eric > On 1/24/2021 3:07 PM, Paul Bryan via Python-ideas wrote: > > The main benefits of this proposal: > > - the order of fields (those with defaults, those without) is > irrelevant > - don't need to pedantically add default = None for Optional values > &