[Python-ideas] Adding an "export" decorator in (e.g.) functools

Nick Coghlan ncoghlan at gmail.com
Sat May 10 14:02:52 CEST 2014


On 10 May 2014 09:16, "Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote:
>
> Nick Coghlan wrote:
>>
>> You essentially have to use some
>> form of dynamic scoping in order to modify __all__ in the right
>> module, and then that limits your ability to wrap the export decorator
>> inside other helper functions.
>
>
> The version that uses the function's f_globals directly
> doesn't have that problem.

It has a different problem: f_globals may come from a wrapper function
applied by a decorator that lives in a different module (or replace it with
a callable that has no "f_globals" at all).

An export decorator like this is a neat idea that might work within the
confines of a single project or organisation, but it's inherently too
fragile to make it a generally available part of the standard library.

Cheers,
Nick.

>
> --
> Greg
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140510/9fd57317/attachment.html>


More information about the Python-ideas mailing list