osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


On 21/02/2019 18:35, mnl.post at gmail.com wrote:
> (I sent this a few days ago but got bounced without a reason?don?t see it
> posted, so I?m trying one more time.)

It was posted, and commented on.  You can see the thread in the mailing 
list archives, if you don't believe me: 
https://mail.python.org/pipermail/python-list/2019-February/739548.html

> 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/
> 
> The nesting required by context managers can be at odds with a program?s
> real structure.

Really?  I thought in your example, particularly as revised here, the 
context managers showed up the real structure of the code nicely.

-- 
Rhodri James *-* Kynesim Ltd