2018-06-08 20:27 GMT-07:00 Alex Walters <tritium-l...@sdamon.com>: > Why not... > > cool_namespace = SomeNamespaceContextManager() > > with cool_namespace: > def foo(): > pass > > advantage being it introduces no new keyword. The 'disadvantage' is it > would change semantics of the with statement (as would be required to get > the names defined in the suite of the context manager) > > Actually, this is probably doable now. You can get the globals of the calling code by doing sys._getframe(), then check which names are added while the context manager is active.
> > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/