On Sun, Oct 13, 2019 at 03:59:19PM +0200, Anders Hovmöller wrote: > 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.
That's not a problem. We could introduce a rule that when the with block is part of an assignment, the with block runs in a seperate scope. A bigger problem is that this would be the first statement which returns a value (as opposed to having an effect via side-effects, like the class and def statements), and it would only be usable in assignments: spam = with eggs() as cheese: ... but not: items = [x, y, with eggs() as cheese: ... , z] -- Steven _______________________________________________ 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/4WEHUSDPLTVPTBVE5G2DGT5QORJ3XJ6F/ Code of Conduct: http://python.org/psf/codeofconduct/