Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'python': 0.08; 'decorator': 0.09; 'header:In-reply-to:1': 0.09; 'readable': 0.09; 'discussions': 0.12; 'am,': 0.13; 'wrote:': 0.15; '__all__': 0.16; 'declaring': 0.16; 'definition,': 0.16; 'from:addr:free.fr': 0.16; 'func():': 0.16; "function's": 0.16; 'rachel': 0.16; 'subject:bad': 0.16; 'versus': 0.16; 'possibly': 0.16; 'def': 0.16; 'perl': 0.19; 'solution.': 0.19; 'topic.': 0.23; 'verbal': 0.25; 'changed': 0.25; 'function': 0.26; 'pass': 0.28; 'skip:_ 20': 0.28; 'problem': 0.29; 'alongside': 0.30; 'class': 0.31; 'separate': 0.31; 'earlier': 0.32; 'list': 0.32; 'topic': 0.33; 'list.': 0.33; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; 'forces': 0.35; 'thank': 0.35; 'question': 0.35; 'some': 0.37; 'but': 0.37; 'subject:: ': 0.38; 'mailing': 0.38; 'to:addr:python.org': 0.39; 'might': 0.39; 'did': 0.40; 'you.': 0.62; 'pleased': 0.63; 'saw': 0.64; 'here': 0.66; 'received:62': 0.67; 'collective': 0.67; 'subject:like': 0.67; 'ideas.': 0.73; 'beautiful': 0.77; 'introduce': 0.79; 'schrieb': 0.84; 'subject:write': 0.84; 'ugly,': 0.84 Date: Fri, 29 Jul 2011 11:54:41 +0200 From: Karim Subject: Re: Is it bad practise to write __all__ like that In-reply-to: To: python-list@python.org MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <4E315D5C.7080604@free.fr> User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311933286 news.xs4all.nl 23896 [2001:888:2000:d::a6]:33721 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10508 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