[Python-ideas] Re: Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-06-23 Thread Steven D'Aprano
On Sat, Jun 22, 2019 at 12:14:02PM -0400, James Lu wrote: > If a function that tends to return a context manager returns None, > that should not mean an error occurred. I suppose that *technically* this is true. It might be designed to return a context manager or None. But: 1. Because of the

[Python-ideas] Re: Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-06-23 Thread Chris Angelico
On Mon, Jun 24, 2019 at 4:03 AM James Lu wrote: > > If a function that tends to return a context manager returns None, that > should not mean an error occurred. If an error or unexpected condition > occurred, an exception should be thrown. Errors and exceptions should result > in the code

[Python-ideas] Re: Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-06-23 Thread James Lu
If a function that tends to return a context manager returns None, that should not mean an error occurred. If an error or unexpected condition occurred, an exception should be thrown. Errors and exceptions should result in the code within the with statement not executing. We could add a new