Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10508

Re: Is it bad practise to write __all__ like that

Date 2011-07-29 11:54 +0200
From Karim <karim.liateni@free.fr>
Subject Re: Is it bad practise to write __all__ like that
References (1 earlier) <j0rkml$a43$1@r03.glglgl.eu> <4E315D5C.7080604@free.fr> <CA+qAmVi8QkWCGfkUktx=ZXm_W_c25vmdvhDg3a1O+GKb_W3QBw@mail.gmail.com> <mailman.1584.1311876111.1164.python-list@python.org> <j0tkfv$9n0$1@r03.glglgl.eu>
Newsgroups comp.lang.python
Message-ID <mailman.1610.1311933286.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 07/29/2011 08:37 AM, Thomas Rachel wrote:
> Am 28.07.2011 20:01 schrieb Ian Kelly:
>
>> The advantage of Thomas's decorator here is that it lets you place the
>> denotation of whether a function is exported alongside its definition,
>> whereas simply declaring the __all__ list forces you to separate them.
>>   It also avoids the problem of possibly mistyping the function's name
>> in the list.
>
> Thank you. For the ones who do not like @__all__ because it might look 
> ugly, here is an alternative:
>
> __all__ = []
>
> def export(obj):
>     __all__.append(obj.__name__)
>     return obj
>
> It is nearly the same, but without an extra class and with the more 
> readable
>
> @export
> def func(): pass
>
>
> Thomas

I did not plan that this topic introduce so many great ideas.
It started from a simple question and ended up with new
and beautiful solution.
Very pleased of the collective spirit of this mailing list.
It changed from non-sense verbal fightings I saw earlier in some discussions
like perl versus python related topic.

Karim

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is it bad practise to write __all__ like that Karim <karim.liateni@free.fr> - 2011-07-28 13:32 +0200
  Re: Is it bad practise to write __all__ like that Ben Finney <ben+python@benfinney.id.au> - 2011-07-28 21:52 +1000
  Re: Is it bad practise to write __all__ like that Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-07-28 14:29 +0200
    Re: Is it bad practise to write __all__ like that Karim <karim.liateni@free.fr> - 2011-07-28 15:00 +0200
    Re: Is it bad practise to write __all__ like that Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-28 12:01 -0600
      Re: Is it bad practise to write __all__ like that Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-07-29 08:37 +0200
        Re: Is it bad practise to write __all__ like that Karim <karim.liateni@free.fr> - 2011-07-29 11:54 +0200
    Re: Is it bad practise to write __all__ like that Erik Max Francis <max@alcyone.com> - 2011-07-28 22:22 -0700
    Re: Is it bad practise to write __all__ like that "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-07-29 18:49 +0000

csiph-web