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

Joao S. O. Bueno jsbueno at python.org.br
Fri May 9 13:07:49 CEST 2014


On 9 May 2014 05:53, Chris Angelico <rosuav at gmail.com> wrote:
> On Fri, May 9, 2014 at 6:45 PM, Peter Otten <__peter__ at web.de> wrote:
>> I'm mostly posting to suggest an alternative implementation for your
>> personal use ;)
>>
>> def export(f):
>>     sys._getframe(1).f_globals.setdefault("__all__", []).append(f.__name__)
>>     return f

in this case it could be
      ....
      f.__globals__.setdefault ...

 (instead of the sys._getframe)

anyway, I also dislike the idea on the basis that __all__ is not
that usefull in itself, and people coming from static languages
(and worse, people building "pylinters") might come to find this
a "good practice" to the point of being mandatory
(else, fail the linter): and voilá: a lot of noise
to the language.

   js
 -><-
>
> sys._getframe, in my opinion, isn't so much code "smell" as
> "Mythbusters' 1987 Chevrolet"... :)
>
> ChrisA
> _______________________________________________
> 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/


More information about the Python-ideas mailing list