The class statement works in this fashion. foo = 1 class Bar: foo = 2
assert foo = 1 assert Bar.foo = 2 On Fri, Jul 26, 2019, 12:19 AM Batuhan Taskaya <isidenti...@gmail.com> wrote: > I am proposing namespace context managers with implementing `__enter__` > and `__exit__` on dict objects. It would make closures possible in python > with a pythonic syntax. > > a = 4 > namespace = {} > > with namespace: > a = 3 > > assert a == 4 > assert namespace["a"] == 3 > _______________________________________________ > 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/TAVHEKDZVYKJUGZKWSVZVAOGBPLZVKQG/ > 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/SL2VZACTCSYB76BZI5QFP2CE3WSUFXPA/ Code of Conduct: http://python.org/psf/codeofconduct/