>
> > A class + decorator gets so almost there that it might be possible
> > with just a tiny bit of language support. What if there could be a way
> > to change a function's __globals__?


Forgive me if this doesn't make sense, but what about a way to make a copy
of a function's locals while it is being called?

Maybe something like:

@namespace
def ns():
    x = 1
    def f(): ...

Inside the decorator, you simply call the function, make a copy of the
locals, and assign it to the function name as a module?
_______________________________________________
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/WJAOEIM5MF3BVEWRCM7QAJTF5O64GZUE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to