Could you supply some real life examples of the proposed feature? A thing to 
consider here is that the with block in python doesn't introduce a scope so 
after:

with foo() as bar:
    a = 2
    b = 3

now bar, a and b are all available in the scope.

> On 13 Oct 2019, at 15:23, Steve Jorgensen <ste...@stevej.name> wrote:
> 
> it would be nice to be able to use the "with" block syntax to do things like 
> implement a builder. To do this, the with block must be able to return a 
> final value to the surrounding context ass part of its __exit__ behavior.
> 
>    obj = with builder() as b: …
> 
> This would be a little like what can be done in Ruby by passing a {…} block 
> argument to a function.
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/A7VPZ7HO27ZTBAT3ICVK5QKYUA2ALHKU/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MGHDUNM45VX4EGBPPU6KWOBNVN5CNKJX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to