Feature suggestions: "Using declarations" i.e. context managers ("with" blocks) tied to scope/lifetime of the variable rather than to nesting

Rhodri James rhodri at kynesim.co.uk
Tue Feb 19 06:26:19 EST 2019


This is probably better discussed on python-ideas, but here goes:

On 19/02/2019 04:15, mnl.post at gmail.com wrote:
> I thought this new C# feature would be a good thing to add to Python:
> https://vcsjones.com/2019/01/30/csharp-8-using-declarations/
> 
> I find the nesting required by context managers to be at odds with the
> broad intent.

You're going to have to expand on this somewhat, because at the moment I 
100% disagree with you.  I would much rather be explicit about the code 
that a context manager applies to than have it magically add itself to 
some other block.

-- 
Rhodri James *-* Kynesim Ltd



More information about the Python-list mailing list