[Python-ideas] Re: Context managers in expressions

2021-10-30 Thread Serhiy Storchaka
25.10.21 21:26, jcg.stu...@gmail.com пише: > I've been thinking for a while that it would be good to be able to use > context managers in an expression context, and I haven't been able to come up > with any arguments against it (although it may not be to everyone's taste) > and I can't see any

[Python-ideas] Re: Context managers in expressions

2021-10-30 Thread John Sturdy
Thanks, Mark... I had missed that aspect entirely. I think there might be a way round it... which actually was something I had been thinking of including in the same suggestion but thought was perhaps too obscure, but now I've realized it would integrate well with it. That is to have a

[Python-ideas] Re: Context managers in expressions

2021-10-25 Thread Mark Gordon
What should happen if the context manager attempts to suppress a raised exception? In cases where you applied the context manager to an entire line, e.g. data = fail() with contextlib.suppress(Exception) Then it would make sense to treat it like with contextlib.suppress(Exception): data =